I have a gcePersistentDisk with an elasticsearch index. When I delete and recreate the statefulset, I want to reuse this disk so the same index is available on the new statefulset.
I've managed to rebind the disk, my-es-disk
, to a new statefulset, but when I connect to the container and check for the index, there are no indices.
I've reviewed Google and k8s docs, and it seems like the yamls are correct, but I still cannot retain the index. I am sure it's something simple! Thanks for your help!
My workflow:
1 - Create storage class
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: ssd
provisioner: kubernetes.io/gce-pd
parameters:
type: pd-ssd
zone: us-central1-a
reclaimPolicy: Retain
allowVolumeExpansion: true
2 - Create PersistentVolume and PersistentVolumeClaim
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-es
spec:
storageClassName: ssd
capacity:
storage: 3G
accessModes:
- ReadWriteOnce
gcePersistentDisk:
pdName: my-es-disk
fsType: ext4
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pv-claim-es
spec:
storageClassName: ssd
volumeName: pv-es
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 3G
3 - Deploy statefulSet
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: elastic-data
labels:
app: elastic-data
area: devs
role: nosql
version: "6.1.4"
environment: elastic
spec:
serviceName: elastic-data
replicas: 1
updateStrategy:
type: RollingUpdate
template:
metadata:
labels:
app: elastic-data
area: devs
role: nosql
version: "6.1.4"
environment: elastic
spec:
terminationGracePeriodSeconds: 10
securityContext:
runAsUser: 1000
fsGroup: 1000
containers:
- name: elastic-data
image: docker.elastic.co/elasticsearch/elasticsearch:6.1.4
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
volumes:
- name: data-volume
persistentVolumeClaim:
claimName: pv-claim-es