I am trying to deploy 2 Replicas of Elasticsearch pods on gke using Statefulset with filestore as a volume , but after researching for few hours in every documentation It is suggested to provision persistent disk for Statefulset which it don't want , I want to utilize my filestore and store the data's of both replicas of Elasticsearch
so what changes should I do to achieve this:-
here is the pv file
apiVersion: v1
kind: PersistentVolume
metadata:
name: elasticsearch-pv
namespace: elk
spec:
capacity:
storage: 10Gi
accessModes:
- ReadWriteOnce
nfs:
path: /filestore_vol1/elastic-gke/
server: 10.x.x.122
here is the deployment file :-
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: elasticsearch-cluster
namespace: elk
spec:
serviceName: elasticsearch
replicas: 2
selector:
matchLabels:
app: elasticsearch
template:
metadata:
labels:
app: elasticsearch
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: app-elk
operator: In
values:
- "elastic-tomcat"
containers:
- name: elasticsearch
image: elasticsearch:7.17.5
imagePullPolicy: Always
resources:
limits:
cpu: 1000m
requests:
cpu: 200m
ports:
- containerPort: 9200
name: rest
protocol: TCP
- containerPort: 9300
name: inter-node
protocol: TCP
volumeMounts:
- name: data
mountPath: /usr/share/elasticsearch/data
env:
- name: cluster.name
value: elasticsearch-cluster
- name: node.name
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: discovery.seed_hosts
value: "elasticsearch-cluster-0.elasticsearch,elasticsearch-cluster-1.elasticsearch"
- name: cluster.initial_master_nodes
value: "elasticsearch-cluster-0"
- name: ES_JAVA_OPTS
value: "-Xms512m -Xmx512m"
- name: network.host
value: "0.0.0.0"
initContainers:
- name: fix-permissions
image: busybox
command: ["sh", "-c", "chown -R 1000:1000 /usr/share/elasticsearch/data"]
securityContext:
privileged: true
volumeMounts:
- name: data
mountPath: /usr/share/elasticsearch/data
- name: increase-vm-max-map
image: busybox
command: ["sysctl", "-w", "vm.max_map_count=262144"]
securityContext:
privileged: true
- name: increase-fd-ulimit
image: busybox
command: ["sh", "-c", "ulimit -n 65536"]
securityContext:
privileged: true
volumeClaimTemplates:
- metadata:
name: data
labels:
app: elasticsearch
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: ""
volumeName: elasticsearch-pv
resources:
requests:
storage: 3Gi