etcd Operator logo etcd Operator

etcd Operator
for Kubernetes

by CoreOS

The etcd operator provisions and configures etcd on Kubernetes. Etcd is a distributed, reliable key value store that uses the Raft protocol. It gracefully handles leader elections to recover from network partitions or node unavailability.

Etcd is prominently the main datastore of Kubernetes itself, but can also be used as a key value store for your own custom applications when strong consistency is required.

Documentation

description README

Install, update and remove

description DEPLOY

Deploy a etcd cluster

Install the etcd Operator

info_outline

Below instructions explain how to install the etcd 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/etcd-v0.9.4-kbst.1.zip
    unzip -d manifests/bases/ etcd-v0.9.4-kbst.1.zip
    rm etcd-v0.9.4-kbst.1.zip
    
  2. Include in bases

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

    cd -
    git checkout -b add-etcd
    git add manifests/bases/etcd manifests/overlays/common/kustomization.yaml
    git commit -m "Add etcd v0.9.4-kbst.1 base"
    git push origin add-etcd
    
  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 etcd 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/etcd
    
  2. Vendor the new version

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

    git checkout -b update-etcd
    git add manifests/bases/etcd
    git commit -m "Update etcd base to v0.9.4-kbst.1"
    git push origin update-etcd
    

Remove the Clusters and the Operator

info_outline

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

  1. List and deprovision etcd clusters

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

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

  2. Delete the vendored base from your repository

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

    git checkout -b remove-etcd
    git add manifests/bases/etcd
    git commit -m "Remove etcd base"
    git push origin remove-etcd
    
  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-etcd
    

Deploy a etcd Cluster

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

etcd Custom Object

Below is an example of a EtcdCluster resource to instruct the operator to provision a etcd cluster with three members.

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

apiVersion: "etcd.database.coreos.com/v1beta2"
kind: "EtcdCluster"
metadata:
  name: "example-etcd-cluster"
  # Adding this annotation make this cluster managed by
  # clusterwide operators, namespaced operators ignore it
  annotations:
    etcd.database.coreos.com/scope: clusterwide
spec:
  size: 3