Hello ,
i need help to persist config file and keystore in k8s stateful set .
this version is 8.13, and somehow it is really okay to persist data directory but, it not works when trying to persist config directory.
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: elasticsearch
namespace: prod-es
spec:
serviceName: elasticsearch
replicas: 1
selector:
matchLabels:
app: elasticsearch
template:
metadata:
labels:
app: elasticsearch
spec:
securityContext:
runAsUser: 1000
runAsGroup: 3000
fsGroup: 2000
containers:
- name: elasticsearch
image: docker.elastic.co/elasticsearch/elasticsearch:8.13.4
resources:
limits:
memory: 2Gi
cpu: "2"
requests:
memory: 2Gi
cpu: "2"
ports:
- containerPort: 9200
name: es-http
- containerPort: 9300
name: es-internal
env:
- name: "discovery.type"
value: "single-node"
- name: "xpack.security.enabled"
value: "true"
# - name: "xpack.security.transport.ssl.enabled"
# value: "true"
- name: "ES_JAVA_OPTS"
value: "-Xms1g -Xmx1g"
- name: "ELASTIC_PASSWORD"
value: PASSWORD
# - name: "xpack.security.transport.ssl.enabled"
# value: "true"
# - name: "xpack.security.transport.ssl.verification_mode"
# value: "certificate"
# - name: "xpack.security.transport.ssl.client_authentication"
# value: "required"
# - name: "xpack.security.transport.ssl.keystore.path"
# value: "elastic-certificates.p12"
# - name: "xpack.security.transport.ssl.truststore.path"
# value: "elastic-certificates.p12"
volumeMounts:
- name: es-storage
mountPath: /usr/share/elasticsearch/data
- name: prod-es-config-pvc
mountPath: /usr/share/elasticsearch/config
volumes: # 컨테이너에서 사용할 볼륨 정의
- name: es-storage
persistentVolumeClaim:
claimName: prod-es-pvc
- name: prod-es-config-pvc
persistentVolumeClaim:
claimName: prod-es-config-pvc
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-app
operator: In
values:
- "es"
and the output log is like this
$ kubectl logs -n prod-es pod/elasticsearch-0 --follow
ERROR: Missing logging config file at /usr/share/elasticsearch/config/log4j2.properties, with exit code 78
and pv for this area is fully empty , i think there is some steps should be done before set pv on config directory,