Hi, I want to persist data persist when our Kubernetes StatefulSets are destroyed and recreated. I have one master node and one data node.
I think, like this problem, the issue is setting path.data
, but I'm not completely sure how to set the variable. I've tried a few different methods like manually setting the value in elasticsearch.yml
but I've had zero success. Ideally, I would love to set the path on startup. Any advice is much appreciated!
Here's the StatefulSet yaml for our data node:
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: elastic-data
labels:
app: elastic-data
area: devs
role: nosql
version: "6.3.1"
environment: elastic
spec:
serviceName: elastic-data
replicas: 1
updateStrategy:
type: RollingUpdate
template:
metadata:
labels:
app: elastic-data
area: devs
role: nosql
version: "6.3.1"
environment: elastic
annotations:
pod.beta.kubernetes.io/init-containers: '[
{
"name": "sysctl",
"image": "busybox",
"imagePullPolicy": "IfNotPresent",
"command": ["sysctl", "-w", "vm.max_map_count=262144"],
"securityContext": {
"privileged": true
}
}
]'
spec:
terminationGracePeriodSeconds: 10
securityContext:
runAsUser: 1000
fsGroup: 1000
containers:
- name: elastic-data
image: docker.elastic.co/elasticsearch/elasticsearch:6.3.1
env:
- name: ES_JAVA_OPTS
value: -Xms512m -Xmx512m
command: ["/bin/bash", "-c", "~/bin/elasticsearch-plugin remove x-pack; sed -i.bak -e /xpack.license.self_generated.type/d config/elasticsearch.yml; elasticsearch"]
args:
- -Ecluster.name=elastic-devs
- -Enode.name=${HOSTNAME}
- -Ediscovery.zen.ping.unicast.hosts=elastic-master.default.svc.cluster.local
- -Enode.master=false
- -Enode.data=true
- -Enode.ingest=false
- -Enetwork.host=0.0.0.0
- -Expack.security.enabled=false
resources:
requests:
memory: "512Mi"
limits:
memory: "1024Mi"
ports:
- containerPort: 9300
name: transport
- containerPort: 9200
name: http
volumeMounts:
- name: data-volume
mountPath: /usr/share/elasticsearch/data
readinessProbe:
tcpSocket:
port: 9300
initialDelaySeconds: 30
periodSeconds: 30
timeoutSeconds: 3
livenessProbe:
tcpSocket:
port: 9300
initialDelaySeconds: 30
periodSeconds: 30
timeoutSeconds: 3
volumes:
- name: data-volume
persistentVolumeClaim:
claimName: pv-claim-es