How viveksinghggits/kluster works
Kluster is a Kubernetes operator that turns a Kluster custom resource into a DigitalOcean Kubernetes cluster. The workflow starts when a user installs the CRD and submits a resource; the operator observes it, queues reconciliation, reads its token Secret, requests cluster creation, polls for readiness, and writes progress to resource status. The generated informer and lister support this control loop. The sampled implementation shows creation and readiness updates, but deletion handling only logs success; it does not show deletion of a DigitalOcean cluster.
Main entry points: controller/kluster.go Reconcile controller · do.go DigitalOcean adapter · v1alpha1/kluster.go Custom client · main.go Operator startup
Components 14
Kluster API
- Kluster CRD
manifests/viveksingh.dev_klusters.yaml - Kluster types
pkg/apis/viveksingh.dev/v1alpha1/types.go - Custom client
pkg/client/clientset/versioned/typed/viveksingh.dev/v1alpha1/kluster.go
Observation
- Informer factory
pkg/client/informers/externalversions/factory.go - Kluster informer
pkg/client/informers/externalversions/viveksingh.dev/v1alpha1/kluster.go - Kluster lister
pkg/client/listers/viveksingh.dev/v1alpha1/kluster.go
Reconciliation
- Operator startup
main.go - Reconcile controller
pkg/controller/kluster.go - Work queue
pkg/controller/kluster.go
Cloud integration
- DigitalOcean adapter
pkg/do/do.go
Other components
- Kubernetes user
- Kubernetes API
- Token Secret
- DigitalOcean API
Connections 17
- Kubernetes user → Kluster CRD: installs
README.md - Kubernetes user → Kubernetes API: submits Kluster
README.md - Operator startup → Custom client: creates client
main.go - Operator startup → Informer factory: starts factory
main.go - Operator startup → Reconcile controller: starts controller
main.go - Informer factory → Kluster informer: provides informer
pkg/client/informers/externalversions/factory.go - Kluster informer → Custom client: lists and watches
pkg/client/informers/externalversions/viveksingh.dev/v1alpha1/kluster.go - Reconcile controller → Kluster informer: registers handlers
pkg/controller/kluster.go - Reconcile controller → Work queue: enqueues events
pkg/controller/kluster.go - Reconcile controller → Kluster lister: reads cached Kluster
pkg/controller/kluster.go - Reconcile controller → DigitalOcean adapter: creates and polls cluster
pkg/controller/kluster.go - DigitalOcean adapter → Token Secret: reads token
pkg/do/do.go - DigitalOcean adapter → DigitalOcean API: creates and queries
pkg/do/do.go - Reconcile controller → Custom client: updates status
pkg/controller/kluster.go - Custom client → Kubernetes API: accesses Kluster API
pkg/client/clientset/versioned/typed/viveksingh.dev/v1alpha1/kluster.go - DigitalOcean adapter → Kubernetes API: fetches Secret
pkg/do/do.go - Reconcile controller → Kubernetes API: checks namespace and records events
pkg/controller/kluster.go