Help us shape the future of Go! Take the 2026 Go Developer Survey

skop

module
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 25, 2020 License: MIT

README

Skop: Simple Kubernetes Operators for Go

GoDoc

Skop is a lightweight framework for writing Kubernetes operators in Go. It:

  • Tries to keep the amount of boilerplate code small.
  • Uses the minimal k8s package for communicating with the Kubernetes API.
  • Doesn’t rely on code generation.
  • Provides helpers for common reconciliation tasks.

Usage

Basically, writing an operator for a custom resource boils down to:

  1. Defining the custom resource as a Go struct:

    type Test struct {
        Kind       string             `json:"kind"`
        APIVersion string             `json:"apiVersion"`
        Metadata   *metav1.ObjectMeta `json:"metadata"`
        Spec       TestSpec           `json:"spec"`
    }
    
    type TestSpec struct {
        Text string `json:"text"`
    }
    
  2. Creating the operator:

    op := skop.New(
        skop.WithResource(&Test{}),
        skop.WithReconciler(skop.ReconcilerFunc(reconciler)),
    )
    
  3. 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.Client(), deployment)
    }
    
  4. 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

Path Synopsis
mock
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL