A kubernetes operator for checklyhq.com.
The operator can create checklyhq.com checks and groups based of kubernetes CRDs and Ingress object annotations.
Sources used for kick starting this project:
- https://sdk.operatorframework.io/docs/building-operators/golang/tutorial/
- https://kubernetes.io/blog/2021/06/21/writing-a-controller-for-pod-labels/
- https://github.com/checkly/checkly-go-sdk
- https://docs.okd.io/latest/operators/operator_sdk/golang/osdk-golang-tutorial.html
- https://sdk.operatorframework.io/docs/building-operators/golang/advanced-topics/#external-resources
- https://book.kubebuilder.io/cronjob-tutorial/writing-tests.html
You can download the combined kubernetes resource manifest file from the release page for a specific version.
The CHECKLY_API_KEY
and CHECKLY_ACCOUNT_ID
should be environment variables attached to the container, make sure you create these as secrets and are available before you apply the resource manifests.
Once you have all the files, you can just apply the generated manifest files:
kubectl apply -f install-(version).yaml
We support reading configuration from ingress resources, take a look at the samples directory.
Warning Groups have to exist before the Ingress object, so please at least apply 1 group CRD.
We're using the following versions of packages:
- operator-sdk 1.22.0
- golang 1.18
We're using direnv to manage environment variables for this project (or export them manually and you can skip this step). Make sure you generate a checkly API key and you get the account ID as well.
touch .envrc
echo "export CHECKLY_API_KEY=foorbarbaz" > .envrc
echo "export CHECKLY_ACCOUNT_ID=randomnumbers" >> .envrc
direnv allow .
Make sure your current kubectl context is set to the appropriate kubernetes cluster where you want to test the operator, then run
kubectl apply -f config/crd/bases/k8s.checklyhq.com_apichecks.yaml
kubectl apply -f config/crd/bases/k8s.checklyhq.com_groups.yaml
make run
If you update any of the types for the CRD, run
make manifests
and re-apply the CRD.
- Make sure your kubectl context is set to your local k8s cluster
- Run
USE_EXISTING_CLUSTER=true make test
- To see coverage run
go tool cover -html=cover.out
Set your default kubernetes context to the cluster you desire to work on.
Modify the config/samples/checkly_v1alpha1_apicheck.yaml or config/samples/checkly_v1alpha1_group.yaml and apply it.
Any checks created on checklyhq.com will be muted.