Memcached Operator for Kubernetes - Kubestack
Memcached Operator logo Memcached Operator

Memcached Operator
for Kubernetes

by Kubestack

The Memcached operator provisions and configures Memcached in-memory cache clusters on Kubernetes. Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering.

Documentation

description README

Install, update and remove

description DEPLOY

Deploy a Memcached cluster

Install the Memcached Operator

info_outline

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

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

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

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

    git checkout -b update-memcached
    git add manifests/bases/memcached
    git commit -m "Update memcached base to v0.2.1-kbst.2"
    git push origin update-memcached
    

Remove the Database Clusters and the Operator

info_outline

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

  1. List and deprovision Memcached clusters

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

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

  2. Delete the vendored base from your repository

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

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

Deploy a Memcached Cluster

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

Memcached Custom Object

Below is an example of a Memcached resource to instruct the operator to provision a Memcache cluster consisting of one mcrouter and two memcached replicas.

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

apiVersion: kubestack.com/v1
kind: Memcached
metadata:
  name: memc
  namespace: default
spec:
  mcrouter:
    replicas: 1
    mcrouter_limit_cpu: "100m"
    mcrouter_limit_memory: "64Mi"
  memcached:
    replicas: 2
    memcached_limit_cpu: "50m"
    memcached_limit_memory: "128Mi"