如何在minikube kubernetes环境中保留弹性指数

时间:2018-06-07 01:58:40

标签: kubernetes minikube

我正在运行弹性& kibana在kubernetes,minikube环境本地。我想保留minikube重启的弹性搜索索引。如果重新创建minikube vm,保留索引并不重要。

如何更改配置以使搜索索引存储在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

1 个答案:

答案 0 :(得分:1)

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但弹性搜索泊坞窗图片为USER elasticsearch(uid 1000,IIRC)和因此没有权限chown卷装入容器的目录。在开始弹性搜索之前,您需要运行chown命令,因此initContainer