1. Installing the operator #
CRDs and operator.
Installation #
kubectl create -f https://download.elastic.co/downloads/eck/2.16.1/crds.yaml
kubectl apply -f https://download.elastic.co/downloads/eck/2.16.1/operator.yaml
kubectl -n elastic-system logs statefulset/elastic-operatorGood to know: Replace the ECK version with the latest published one; it determines the supported Stack versions.
2. Declaring a cluster #
nodeSets and volumes.
Manifest #
apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata: { name: logs }
spec:
version: 8.17.0
nodeSets:
- name: master
count: 3
config: { node.roles: [ master ] }
volumeClaimTemplates:
- metadata: { name: elasticsearch-data }
spec: { accessModes: [ ReadWriteOnce ], resources: { requests: { storage: 10Gi } } }
- name: hot
count: 3
config: { node.roles: [ data_hot, data_content, ingest ] }
podTemplate:
spec:
containers:
- name: elasticsearch
resources: { requests: { memory: 8Gi, cpu: 2 }, limits: { memory: 8Gi } }
volumeClaimTemplates:
- metadata: { name: elasticsearch-data }
spec: { accessModes: [ ReadWriteOnce ], storageClassName: fast-ssd, resources: { requests: { storage: 500Gi } } }
---
apiVersion: kibana.k8s.elastic.co/v1
kind: Kibana
metadata: { name: logs }
spec: { version: 8.17.0, count: 1, elasticsearchRef: { name: logs } }kubectl get elasticsearch
kubectl get secret logs-es-elastic-user -o go-template='{{.data.elastic | base64decode}}' 3. Operating #
Upgrades and pitfalls.
Practices #
- Upgrade: change
spec.version; ECK restarts pods one by one while respecting cluster health. - Resize a nodeSet: change
count; ECK migrates data before deleting a pod. - TLS and the
elasticuser are generated automatically; custom certificates are possible. - Per-node anti-affinity and spreading across zones (
topologySpreadConstraints) for high availability.
Common mistake: A StorageClass withreclaimPolicy: Deletedestroys data when the cluster is deleted. For production, useRetainand snapshots.
