Quickstart for Go-based Operators
This guide walks through an example of building a simple memcached-operator using tools and libraries provided by the Operator SDK.
- Install operator-sdk and its prequisites.
- Access to a Kubernetes v1.11.3+ cluster (v1.16.0+ if using CRDs).
Create and change into a directory for your project. Then call operator-sdk init
with the Go plugin to initialize the project.
Create a simple Memcached API:
operator-sdk create api --group cache --version v1 --kind Memcached --resource=true --controller=true
NOTE: To allow the cluster pull the image the repository needs to be set as public or you must configure an image pull secret.
Install the CRD and deploy the project to the cluster. Set IMG
with make deploy
to use the image you just pushed:
make deploy IMG=<some-registry>/<project-name>:<tag>
Create a sample CR:
kubectl logs deployment.apps/memcached-operator-controller-manager -n memcached-operator-system -c manager
Delete the CR to uninstall memcached:
Uninstall the operator and its CRDs:
kustomize build config/default | kubectl delete -f -
Read the for an in-depth walkthough of building a Go operator.