Elasticsearch Operator logo Elasticsearch Operator

Elasticsearch Operator
for Kubernetes

by UPMC Enterprises

The Elasticsearch operator provisions and configures an Elasticsearch cluster on top of Kubernetes. Elasticsearch is a distributed, JSON-based search and analytics engine designed for horizontal scalability, maximum reliability and easy management.

In addition to Elasticsearch the operator also includes additional pieces of the Elastic stack, like Kibana.

Documentation

description README

Install, update and remove

description DEPLOY

Deploy Elasticsearch

Install the Elasticsearch Operator

info_outline

Below instructions explain how to install the Elasticsearch operator in a repository bootstrapped using the Kubestack quickstart. But you can adapt the workflow to any kustomize directory layout easily.

  1. Vendor the base

    # Run these commands from the root of your Kubestack infra repository
    wget https://storage.googleapis.com/catalog.kubestack.com/elasticsearch-v0.3.0-kbst.0.zip
    unzip -d manifests/bases/ elasticsearch-v0.3.0-kbst.0.zip
    rm elasticsearch-v0.3.0-kbst.0.zip
    
  2. Include in bases

    cd manifests/overlays/common
    kustomize edit add base ../../bases/elasticsearch/clusterwide
    
  3. Commit and push

    cd -
    git checkout -b add-elasticsearch
    git add manifests/bases/elasticsearch manifests/overlays/common/kustomization.yaml
    git commit -m "Add elasticsearch v0.3.0-kbst.0 base"
    git push origin add-elasticsearch
    
  4. Review PR and merge

    Finally, review and merge the PR into master. Once it's been successfully applied against the Ops-Cluster set a prod-deploy tag to also apply the change against the Apps-Cluster.


Update the Elasticsearch Operator

info_outline

The UPDATE instructions assume the operator has been installed by following the INSTALL instructions. If not, adjust accordingly.

To update the operator delete the previously vendored base and then vendor the new version.

  1. Delete the previous vendored version

    # Run these commands from the root of your Kubestack infra repository
    rm -r manifests/bases/elasticsearch
    
  2. Vendor the new version

    # Run these commands from the root of your Kubestack infra repository
    wget https://storage.googleapis.com/catalog.kubestack.com/elasticsearch-v0.3.0-kbst.0.zip
    unzip -d manifests/bases/ elasticsearch-v0.3.0-kbst.0.zip
    rm elasticsearch-v0.3.0-kbst.0.zip
    
  3. Commit and push

    git checkout -b update-elasticsearch
    git add manifests/bases/elasticsearch
    git commit -m "Update elasticsearch base to v0.3.0-kbst.0"
    git push origin update-elasticsearch
    

Remove the Clusters and the Operator

info_outline

Please be advised, the removal instructions for the Elasticsearch operator require manual steps to cleanly remove both eventually provisioned Elasticsearch clusters and the operator itself from your Kubernetes cluster.

  1. List and deprovision Elasticsearch clusters

    # Make sure your context is pointing to the correct cluster
    kubectl get Elasticsearchcluster --all-namespaces
    

    Make sure you want to delete the instances listed above, then delete them using kubectl -n NAMESPACE delete Elasticsearchcluster NAME.

  2. Delete the vendored base from your repository

    # Run these commands from the root of your Kubestack infra repository
    rm -r manifests/bases/elasticsearch
    
  3. Commit and push

    git checkout -b remove-elasticsearch
    git add manifests/bases/elasticsearch
    git commit -m "Remove elasticsearch base"
    git push origin remove-elasticsearch
    
  4. Delete operator

    When manifests are applied using kubectl apply, resources that have been removed from the manifests, are not removed from the clusters. So, as a last step, we need to delete the operator from our clusters, which we can do by simply deleting the namespace.

    kubectl delete namespace operator-Elasticsearch
    

Deploy a Elasticsearch Cluster

Once the operator has been deployed to the Kubernetes cluster, you can use it to provision and operate one or more Elasticsearch clusters by creating a custom object.

Elasticsearch Custom Object

Below is an example of a ElasticsearchCluster resource to instruct the operator to provision a Elasticsearch cluster with one client-, one data- and one master-node.

Please refer to the upstream documentation regarding available configuration options.

To get started, put the example below into a file called elasticsearch.yaml and add it to your application's manifests. Then apply the manifests including the elasticsearch.yaml as usual.

apiVersion: enterprises.upmc.com/v1
kind: ElasticsearchCluster
metadata:
  name: example-es-cluster
spec:
  kibana: {}
  cerebro: {}
  client-node-replicas: 1
  master-node-replicas: 1
  data-node-replicas: 1
  network-host: 0.0.0.0
  zones: []
  data-volume-size: 10Gi
  java-options: "-Xms512m -Xmx512m"
  snapshot:
    scheduler-enabled: false
    bucket-name: elasticsnapshots99
    cron-schedule: "@every 2m"
  storage:
    type: standard
    storage-class-version: volume.alpha.kubernetes.io/storage-class
    volume-reclaim-policy: Delete