This is a project to build a Kubernetes Controller from scratch using the Watcher method. It is a Controller that watches for the creation of new ConfigMaps.
This project has the following dependencies. Make sure to install these locally before proceeding.
- kind
- direnv is used (it's the
.envrc
file) to export the KUBECONFIG environment variable in your shell.
Follow the following steps to spin up this application.
-
Do
make up
to spin up a cluster calledplayground
using kind. -
Build the binary with
make build
. -
Run the application with
make run
. -
In a separate terminal, create a ConfigMap out of the manifest in
./manifests/configmap.yaml
and deploy it to your local kind cluster:
kubectl create configmap joke --from-file=./manifests/configmap.yaml
Here are some of the resources that helped me along the way that I would like to credit:
- https://github.com/aclevername/config-map-controller
- https://github.com/kubernetes/client-go/tree/master/examples#advanced-concepts
- https://engineering.bitnami.com/articles/a-deep-dive-into-kubernetes-controllers.html
- https://github.com/kubernetes/community/blob/8decfe4/contributors/devel/controllers.md
- https://github.com/kubernetes/sample-controller