Elasticsearch operator for Kubernetes
This is a proof of concept shown at DC Hack & Tell. It is not ready for production use.
This is a Kubernetes Operator for Elasticsearch. It provides a declarative interface for managing Elasticsearch clusters and takes care of handling state transitions for you.
StatefulSets are a nice addition to Kubernetes and lay the groundwork for building stateful applications on top of Kubernetes. Unfortunately, they only provide a top down view of stateful applications and provide tools for migrating volumes alongside containers. In the case of many distributed systems, this is only one failure condition.
Scaling Elasticsearch can be tricky. At a high level you need to:
- Ensure that
minimum_master_nodes
is always set to the appropriate size for your cluster's quorum - Ensure that data loss (even temporary via relocating a shard with no replicas) is avoided
To this end, we attempt to fully drain a node of it's shards before de-registering it. Configurations are proxied to pods via ConfigMaps, removing the need for pods to have read privileges to the kubernetes api.
A cluster with various Node pools, each given a name and a selection of roles. This is the only type which should be specified. All others are created/updated/removed programmatically via the controller manager.
This is not to be handled by the end-user, but specifies a generated quorum definition based on master-eligible node pools in a cluster spec.
This is not to be handled by the end-user outside of subfields in the Cluster spec, but specifies a pool of elasticsearch nodes.
apiVersion: elasticsearch.k8s.io/v1beta1
kind: Cluster
metadata:
labels:
controller-tools.k8s.io: "1.0"
name: mycluster
spec:
nodePools:
- name: master
roles:
- master
replicas: 3
storageClass: "standard"
resources:
requests:
memory: "512Mi"
cpu: "200m"
- name: data
roles:
- data
replicas: 5
storageClass: "standard"
resources:
requests:
memory: "512Mi"
cpu: "200m"
Most actions are handled via make
make build
- runs code generationmake install
- generates custom resource definitions and installs them into current cluster viakubectl
make manager
- builds the controller managermake sidecar
- build executable which monitors and proxiesminimum_master_nodes
settings to a clustermake handler
- builds the executable which monitors schedulability of an elasticsearch node and deregisters (terminates) it when applicablemake seed
- build elasticsearch seeding tool (for seeding dummy data)make run
- runs the controller manager against current k8s installation (most likely minikube)