I deploy influxdb v2.4 on GKE and mounted the path "/var/lib/influxdb2" to the persistent volume.
The problem is I lose data and all credentials after I manually kill the pod using kubectl and I have to setup initializations after a new pod created.
Here is my statefulset
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: influxdb-dev-deploy
namespace: dev
spec:
replicas: 1
selector:
matchLabels:
app: influxdb-dev-deploy
serviceName: influxdb-dev-deploy
template:
metadata:
labels:
app: influxdb-dev-deploy
spec:
terminationGracePeriodSeconds: 10
containers:
- name: influxdb2
image: influxdb:2.4
imagePullPolicy: "IfNotPresent"
ports:
- containerPort: 8086
envFrom:
- configMapRef:
name: influxdb-dev-config
- secretRef:
name: influxdb-dev-secret
volumeMounts:
- mountPath: /var/lib/influxdb2
name: influxvol
# - mountPath: /etc/influxdb2/configs/influxdb.conf
# name: influxdb-config
# subPath: influxdb.conf
# readOnly: true
resources:
limits:
cpu: 500m
memory: 256Mi
requests:
cpu: 100m
memory: 128Mi
# volumes:
# - name: influxdb-config
# configMap:
# name: influxdb-dev-config
affinity:
nodeAffinity:
# preferredDuringSchedulingIgnoredDuringExecution
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: topology.kubernetes.io/zone
operator: In
values:
- asia-east1-c
volumeClaimTemplates:
- metadata:
name: influxvol
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: "influxdb-dev-sc"
resources:
requests:
storage: 10Gi
storage class
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: influxdb-dev-sc
provisioner: kubernetes.io/gce-pd
parameters:
type: pd-standard
# fstype: ext4
volumeBindingMode: WaitForFirstConsumer
reclaimPolicy: Retain
What I expect is influxdb from the new pod will load all data and credentials from PV automatically.
Any help would be appriciated.
I solved the problem by updating mountPath to
volumeMounts:
- mountPath: /var/lib/influxdb2/engine/data
And set INFLUXD_BOLT_PATH to /var/lib/influxdb2/engine/data/influxd.bolt