module
Version:
v2.1.0
Opens a new window with list of versions in this module.
Published: Jul 21, 2022
License: MIT
Opens a new window with license information.
README
¶
Skop: Simple Kubernetes Operators for Go
Skop is a lightweight framework for writing Kubernetes operators in Go. It:
- Tries to keep the amount of boilerplate code small.
- Doesn’t rely on code generation.
- Provides helpers for common reconciliation tasks.
Usage
Basically, writing an operator for a custom resource boils down to:
-
Defining the custom resource as a Go struct:
type Test struct {
metav1.ObjectMeta `json:"metadata"`
Kind string `json:"kind"`
APIVersion string `json:"apiVersion"`
Spec TestSpec `json:"spec"`
}
type TestSpec struct {
Text string `json:"text"`
}
-
Creating the operator:
op := skop.New(
skop.WithResource("example.com", "v1", "tests", &Test{}),
skop.WithReconciler(skop.ReconcilerFunc(reconciler)),
)
-
Writing the reconcile function:
func reconciler(ctx context.Context, op *skop.Operator, res k8s.Resource) error {
test := res.(*Test)
deployment := makeDeployment(test)
return reconcile.Deployment(ctx, op.Clientset(), deployment)
}
-
Running the operator:
go op.Run()
A complete, working example can be found in the example/ directory.
Who’s using Skop
- Hetzner Cloud is using Skop to deploy their
services in production, staging, and development environments.
License
MIT
Directories
¶
Click to show internal directories.
Click to hide internal directories.