K8s Pingdom Operator is a simple kubernates controller (based on the operator pattern). It allows you to manage your Pingdom service checks through the usage of custom resources.
Since this was my first experince with K8s extensions (and Golang for production like purposes) this code is highly inspired by the sample controller from K8S oficial repo.
Installing dependencies
go get -u
you may need to add GO111MODULES=on
as a prefix for the command above, or simply export the variable.
In the root of the project just run
go build -o pingdom-controller .
Running it locally requires you to have you kubeconfig
file properly setup so that the controller can easily communicate with the cluster api.
After setting the kubeconfig
simply run
./pingdom-controller -kubeconfig=<path to kubeconfig>
When running it as a container in your cluster (as it is intedend to be ran) you should make sure that you container has enough permissions to access your control plane (through the use of a service account)
The next section has some demonstrations on how to apply your checks (also, update and delete). The first step is adding your Custom Resource Definition
to the cluster
kubectl apply -f artifact/examples/crd.yaml
Then you can add your checks as you would with any other K8s native object. Heres an example of a PingdomOperator
custom object defined by the definition applied in the step above
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: pingdomoperators.tacf.github.io
spec:
group: tacf.github.io
version: v1alpha1
names:
kind: PingdomOperator
plural: pingdomoperators
scope: Namespaced
As of now the definition and implementation of the controller only allows for simple http(s) checks to be created.