/memcached-operator

A Kubernetes operator

Primary LanguageGoMIT LicenseMIT

Memcached-Operator

  • This is an Memcached-Operator (CRD+controller) using kubebuilder framework.
  • It provisions Memcached pods replicas and created a service to access them.

Overview

  • Kubernetes Controller: A controller is a loop that reads desired state(spec), observed cluster state (status) and external state and the reconciles cluster state and external state with the desired state, writing any observations down (to our own status).
  • Custom Resource definition(CRD): Defines a custom resource which is not available in default kubernetes implementation.
  • Groups,Versions and kinds:
    • A API group is a collection of related API types.
    • We call each API type a kind.
  • API YAML: It consists of Metadata + Spec + Status + List
    • Metadata holds name/namespace etc.
    • Spec holds desired state.
    • Status holds observed state.
    • List holds many objects.

example:

apiVersion: v1
kind: Pod
metadata:
  name: my-app
  namespace: default
  ...
  ...
spec:
  containers:
  - args: [sh]
    image: gcr.io/bowei-gke/udptest
    imagePullPolicy: Always
    name: client
    ...
  dnsPolicy: ClusterFirst
  ...
  ...
status:
  podIP: 10.8.3.11
  ...
  ...

How to run

  1. Generate CRD and install the CRD
$make manifests
$kubectl apply -f config/crd/bases/cache.example.com_memcacheds.yaml
  1. Apply the sample
$kubectl apply -f config/samples/cache_v1_memcached.yaml
  1. To start the controller
$make run