Skip to content

A boilerplate template for building a Kubernetes operator with Deno/Typecript

Notifications You must be signed in to change notification settings

evertdespiegeleer/deno-k8s-operator-template

Repository files navigation

Header with Typescript, Deno and Kubernetes logo

Typescript & Deno based kubernetes operator boilerplate 🍳

This repo serves as a boilerplate / example code for building a Kubernetes operator using Deno.

What does the example code do?

It installs a cluster scoped custom resource definition (greetings.k8s.evertdespiegeleer.com). It watches that resources and logs whenever it gets created, modified or updated. Every minute AND every time a 'greeting' resource is created or modified, a reconciliation function runs. Every reconciliation, a greeting is logged. Its exact message is based on the Helm values and the 'greeting' custom resource spec. Two properties in the 'greeting' custom resource status are also updated: lastReconciliation and randomNumber.

How does it work?

The official Kubernetes Node client is used to interact with the cluster. The custom resource is watched and whenever an action is performed to it, an event is triggered. This is used to trigger a certain reconciliation function. BullMQ is used to periodically check the state of things and trigger a reconciler function which makes sure that – if needed – the state of things is updated to the desired state.

Local Development

  • Make sure Tilt is installed on your system.
  • Run a local Kubernetes cluster (e.g.: using k3d, kind, minikube...)
  • Create a .env file and a localdev-helm-values.yaml file in the root of this project based on the example files.
  • export KUBECONFIG=<path of your kubeconfig>
  • tilt up
  • You can use the manifests in the ./k8s/example directory to deploy the custom resource and see the operator do its thing.

About

A boilerplate template for building a Kubernetes operator with Deno/Typecript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published