如何在minikube-kubernetes环境中保持弹性指数
我在本地minikube环境的kubernetes运行elastic&kibana。我想在minikube重新启动时保留弹性搜索索引。如果重新创建minikube vm,则保留索引并不重要 如何更改配置,使搜索索引存储在虚拟机或macbook主机上的永久磁盘中 这是弹性搜索的现有配置文件如何在minikube-kubernetes环境中保持弹性指数,kubernetes,minikube,Kubernetes,Minikube,我在本地minikube环境的kubernetes运行elastic&kibana。我想在minikube重新启动时保留弹性搜索索引。如果重新创建minikube vm,则保留索引并不重要 如何更改配置,使搜索索引存储在虚拟机或macbook主机上的永久磁盘中 这是弹性搜索的现有配置文件 apiVersion: apps/v1 kind: Deployment metadata: name: elasticsearch spec: selector: matchLabels:
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
spec:
容器:
-名称:elasticsearch
# 88
体积数量:
-名称:es数据
挂载路径:/var/lib/elasticsearch
初始化容器:
-姓名:chown
图片:busybox:latest
命令:
-乔恩
--R
-“1000”或您的“elasticsearch”用户id是什么
-/var/lib/elasticsearch
体积数量:
-名称:es数据
挂载路径:/var/lib/elasticsearch
卷数:
-名称:es数据
主机路径:
路径:/some/path/in/minikube
initContainers
业务是因为hostPath
将在99%的情况下拥有0:0
,但elasticsearch docker映像是用户elasticsearch
(uid 1000,IIRC),因此没有权限chown
卷装入容器的目录。在启动elasticsearch之前,您需要运行chown
命令,因此,initContainer
您还需要对ES或Postgres等对象使用statefolset
,因为您希望node-0
在运行“for real”(而不是minikube)时始终恢复node-0
的持久卷声明,而且,拥有稳定的DNS名称(免费提供StatefulSet
)可以让集群变得更加容易。感谢Matthew,当我阅读卷时,我错过了挂载点。通过将mountpath设置为/usr/share/elasticsearch/data
和hostPath设置为/data/elasticsearch
,我想这已经被minikube映射了,甚至可能映射到主机(我还没有检查)。另外,我没有使用initContainers的东西,它似乎在我的笔记本电脑环境中正常工作。干杯
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