2. Create API (resource and controller) for Memcached
-
Add controller
operator-sdk create api --group cache --version v1alpha1 --kind Memcached --resource --controller
result
Writing kustomize manifests for you to edit... Writing scaffold for you to edit... api/v1alpha1/memcached_types.go internal/controller/memcached_controller.go Update dependencies: $ go mod tidy Running make: $ make generate /Users/nakamasato/repos/nakamasato/memcached-operator/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..." Next: implement your new API and generate the manifests (e.g. CRDs,CRs) with: $ make manifests
-
Try running the empty operator
- Install CRD.
make install
- Run the controller.
make run
- Create a new custom resource
Memcached
.kubectl apply -f config/samples/cache_v1alpha1_memcached.yaml
- Check logs. (Just confirm the controller starts up successfully.)
- Cleanup.
- Delete CR.
kubectl delete -f config/samples/cache_v1alpha1_memcached.yaml
- Stop the controller by
ctrl-c
. - Uninstll the CRD.
make uninstall
- Delete CR.
- Install CRD.