Cluster information:
Kubernetes version: 1.14.
Cloud being used: bare-metal
Host OS: CentOS 7
CNI and version: Calico
CRI and version: Docker 18.09-CE
Hi, want to run elasticsearch in kubernetes. Since I having trouble running it with glusterFS I want to check it with local storage: Volumes - Kubernetes
As Example following is listed:
apiVersion: v1
kind: PersistentVolume
metadata:
name: example-pv
spec:
capacity:
storage: 100Gi
# volumeMode field requires BlockVolume Alpha feature gate to be enabled.
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Delete
storageClassName: local-storage
local:
path: /mnt/disks/ssd1
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- example-node
currently my elasticsearch statefulSet looks like this (currently using glusterFs via storageClass standard):
# statefulset
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: poc-es-master
labels:
role: master
cluster: poc
spec:
selector:
matchLabels:
app: elasticsearch
role: master
cluster: poc
serviceName: poc-es-master
replicas: 3
template:
metadata:
labels:
app: elasticsearch
role: master
cluster: poc
spec:
containers:
- name: es-master
image: docker-registry:443/docker.elastic.co/elasticsearch/elasticsearch:7.2.0
env:
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: node.name
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: cluster.name
value: "poc"
- name: discovery.seed_hosts
value: "poc-es-master-0.poc-es-master, poc-es-master-1.poc-es-master, poc-es-master-2.poc-es-master"
- name: cluster.initial_master_nodes
value: "poc-es-master-0, poc-es-master-1, poc-es-master-2"
- name: node.master
value: "true"
- name: node.ingest
value: "true"
- name: node.data
value: "true"
- name: ES_JAVA_OPTS
value: "-Xms1g -Xmx1g"
- name: bootstrap.memory_lock
value: "false"
- name: network.host
value: "0.0.0.0"
- name: PROCESSORS
valueFrom:
resourceFieldRef:
resource: limits.cpu
resources:
requests:
cpu: 0.25
memory: 1Gi
limits:
cpu: 2
memory: 4Gi
ports:
- containerPort: 9300
name: transport
- containerPort: 9200
name: http
livenessProbe:
tcpSocket:
port: transport
initialDelaySeconds: 20
periodSeconds: 10
volumeMounts:
- name: storage
mountPath: /usr/share/elasticsearch/data
- name: backup-storage
mountPath: /usr/share/elasticsearch/snapshots
volumes:
- name: backup-storage
persistentVolumeClaim:
claimName: nfs-elastic-backup-qdetjt
volumeClaimTemplates:
- metadata:
name: storage
spec:
storageClassName: standard
accessModes: [ ReadWriteOnce ]
resources:
requests:
storage: 30Gi
I have a few questions about the local storage and it’s example:
- As I understand it, the local storage is working with block devices.
- Do I need to partition and format this device before I can use it?
- In node affinity I can define one or more hostnames of my kubernetes nodes if I understand correctly. What Do I need to do if I have different devices available per node?
e.g:
node1: -> /dev/sdb
node2: -> /dev/sdc and /dev/sdd
How do I need to specify it?
- Do I need one PV with one PVC per elasticsearch pod (1PV to 1 PVC) or will multiple pods create their own PVC on a shared PV (1 PV to many PVC)?
- How do I specify the local storage in the volumeClaimTemplate of the statefulSet?
- just changing the storage class in my volumeClaimTemplate to local-storage?
- could you provide any example with local storage and a statefulSet?
Thanks, Andreas