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
The easier way to test the operator locally is with a KIND cluster. Kind means Kubernetes In Docker and runs a complete 1-node cluster in your machine's Docker. Once installed, create a cluster with kind create cluster
. It will configure the .kubeconfig appropriately.
There are multiple make
targets available to ease development.
To do "normal" develop-test cycle running the operator locally:
- Make sure the CRD manifests are updated with
make bundle
; - Install CRDs in the cluster:
make install
; - Run the operator locally:
make run
; - By default the operator will try to send traces to a local Jaeger. Either check the tracing doc or ignore the timeout messages in the logs;
- Create the namespace, secret and ExternalLoadBalancer CRs in cluster
- Create the operator namespace with
kubectl create namespace lbconfig-operator-system
; - Create the secret (for example for dummy) with:
kubectl create secret generic -n lbconfig-operator-system dummy-creds --from-literal=username=admin --from-literal=password=admin
- Create the CRs (for example for dummy backend) with:
kubectl apply -n lbconfig-operator-system -f config/samples/lb_v1_externalloadbalancer-dummy.yaml
- Create the operator namespace with
To deploy the operator in the cluster as a pod, the steps are:
- Make sure the CRD manifests are updated with
make bundle
; - Install CRDs in the cluster:
make install
; - Deploy the operator manifests to the cluster (CRDs + Namespace + Operator Container):
make deploy
; - Create the namespace, secret and ExternalLoadBalancer CRs in cluster the same way as above.
To remove the manifests to the cluster use make undeploy
. To uninstall the CRDs use make uninstall
.
There are three main test methods:
1 - Automated unit-tests
These tests run with make test
and use Ginkgo testing framework. The tests spawn a Kubernetes control-plane thru envtest and runs the operator logic on it.
2 - KIND cluster with Operator Lifecycle Manager
The makefile target olm-run
starts a KIND cluster, deploys OLM into it and then installs the operator. Check the Makefile
for the commands used.
3 - Scorecard Tests
These tests also run against the previously deployed KIND cluster and does some default validations. It also uses kuttl tests to check the opetator deployed CustomResource. Check the scorecard-run
target in the Makefile
.
Building the manifests and docker images: make dist
.
Operator deployment manifest bundle is created at ./manifests/deploy.yaml
.
The sample manifests for LoadBalancer instances and backends are in ./config/samples
folder.