如何在 minikube kubernetes 环境中保留弹性索引
how to preserve elastic indexes in minikube kubernetes environment
我是 运行 elastic & kibana in kubernetes, minikube 本地环境。我想在 minikube 重新启动时保留弹性搜索索引。如果重新创建 minikube 虚拟机,保留索引并不重要。
如何更改配置,以便将搜索索引存储在 vm 或我的 macbook 主机上的永久磁盘中?
这是 Elastic Search 的现有配置文件。
apiVersion: apps/v1
kind: Deployment
metadata:
name: elasticsearch
spec:
selector:
matchLabels:
component: elasticsearch
template:
metadata:
labels:
component: elasticsearch
spec:
containers:
- name: elasticsearch
image: docker.elastic.co/elasticsearch/elasticsearch:6.2.1
env:
- name: discovery.type
value: single-node
ports:
- containerPort: 9200
name: http
protocol: TCP
https://kubernetes.io/docs/concepts/storage/volumes
spec:
containers:
- name: elasticsearch
# 8<-- snip -->8
volumeMounts:
- name: es-data
mountPath: /var/lib/elasticsearch
initContainers:
- name: chown
image: busybox:latest
command:
- chown
- -R
- "1000" # or whatever your "elasticsearch" user-id is
- /var/lib/elasticsearch
volumeMounts:
- name: es-data
mountPath: /var/lib/elasticsearch
volumes:
- name: es-data
hostPath:
path: /some/path/in/minikube
initContainers
业务是因为 hostPath
将在 99% 的情况下被拥有 0:0
但 elasticsearch docker 图像是 USER elasticsearch
( uid 1000, IIRC),因此无权 chown
卷挂载到容器中的目录。在启动 elasticsearch 之前,您需要 运行 chown
命令,因此,initContainer
.
我是 运行 elastic & kibana in kubernetes, minikube 本地环境。我想在 minikube 重新启动时保留弹性搜索索引。如果重新创建 minikube 虚拟机,保留索引并不重要。
如何更改配置,以便将搜索索引存储在 vm 或我的 macbook 主机上的永久磁盘中?
这是 Elastic Search 的现有配置文件。
apiVersion: apps/v1
kind: Deployment
metadata:
name: elasticsearch
spec:
selector:
matchLabels:
component: elasticsearch
template:
metadata:
labels:
component: elasticsearch
spec:
containers:
- name: elasticsearch
image: docker.elastic.co/elasticsearch/elasticsearch:6.2.1
env:
- name: discovery.type
value: single-node
ports:
- containerPort: 9200
name: http
protocol: TCP
https://kubernetes.io/docs/concepts/storage/volumes
spec:
containers:
- name: elasticsearch
# 8<-- snip -->8
volumeMounts:
- name: es-data
mountPath: /var/lib/elasticsearch
initContainers:
- name: chown
image: busybox:latest
command:
- chown
- -R
- "1000" # or whatever your "elasticsearch" user-id is
- /var/lib/elasticsearch
volumeMounts:
- name: es-data
mountPath: /var/lib/elasticsearch
volumes:
- name: es-data
hostPath:
path: /some/path/in/minikube
initContainers
业务是因为 hostPath
将在 99% 的情况下被拥有 0:0
但 elasticsearch docker 图像是 USER elasticsearch
( uid 1000, IIRC),因此无权 chown
卷挂载到容器中的目录。在启动 elasticsearch 之前,您需要 运行 chown
命令,因此,initContainer
.