This project aims to follow the Kubernetes Operator pattern.
It uses Controllers which provides a reconcile function responsible for synchronizing resources untile the desired state is reached on the cluster.
More information can be found via the Kubebuilder Documentation.
You’ll need a Kubernetes cluster to run against. You can use KIND to get a local cluster for testing, or run against a remote cluster.
Note: Your controller will automatically use the current context in your kubeconfig file (i.e. whatever cluster kubectl cluster-info
shows).
Note: Run make --help
for more information on all potential make
targets.
- Deploy the requirements for tests in the cluster, i.e. cert-manager and the prometheus-operator:
make deploy-test-requirements
- Build and push your image to the location specified by
IMG
:
IMAGE=<some-registry>/sts-phased-rollout-operator:tag
make docker-build docker-push IMG=$IMAGE
Or, if you use kind you can push the image directly to the cluster with:
IMAGE=<some-registry>/sts-phased-rollout-operator:tag
make docker-build IMG=$IMAGE
kind load docker-image $IMAGE
- Deploy the controller to the cluster with the image specified by
IMG
:
make deploy IMG=$IMAGE
- Install Instances of Custom Resources:
kubectl apply -k config/samples/
Test it without running the operator in the cluster:
- Deploy the requirements for tests in the cluster, i.e. cert-manager and the prometheus-operator:
make deploy-test-requirements
- Port forward the prometheus endpoint so that it is reachable from your local development:
kubectl port-forward service/prometheus-prometheus -n monitoring 9090:9090
- Install the CRDs into the cluster:
make install
- Run your controller (this will run in the foreground, so switch to a new terminal if you want to leave it running):
# disable webhooks, otherwise you will need valid certs files ca.crt, tls.crt and tls.key in the /tmp/k8s-webhook-server/serving-certs/ directory
export ENABLE_WEBHOOKS=false
make run #or `make run-debug` for debug logs
- Run the sample:
kubectl apply -k config/samples/local-development
If you are editing the API definitions, generate the manifests such as CRs or CRDs using:
make manifests
To delete the CRDs from the cluster:
make uninstall
UnDeploy the controller from the cluster:
make undeploy