operator-sdk-extra

module
v3.0.6 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT

README

operator-sdk-extra

This framework is an extension of operator-sdk. Its goal is to eliminate repetitive boilerplate when writing Kubernetes operators: finalizer management, status tracking, resource diff computation, and automatic create/update/delete orchestration.

After writing several operators, we identified 3 distinct use cases, each handled by a dedicated reconciler pattern:

Pattern Use case
Multiphase Manage multiple K8s resources (ConfigMaps, Deployments, Services, etc.) from your own CRD
Remote Manage external API resources (Elasticsearch roles, database users, etc.) from your own CRD
Sentinel Watch standard K8s resources you do not own (Ingresses, Secrets, etc.) and derive new resources from their annotations

Patterns overview

Multiphase Reconciler

Use it when your CRD creates and orchestrates a sequence of Kubernetes resources (e.g. a ConfigMap, then a Deployment). Each resource type is handled by its own step reconciler, executed sequentially by a main reconciler.

A Server-Side Apply (SSA) engine delegates diff computation and conflict detection to the Kubernetes API server, producing apply / delete operations automatically.

Read the full documentation

Remote Reconciler

Use it when your CRD manages resources external to Kubernetes via API calls (e.g. Elasticsearch roles, database users, cloud resources).

The pattern relies on a generic RemoteExternalReconciler that wraps your API client (Build, Get, Create, Update, Delete) and a 3-way merge diff that stores the last applied configuration as a compressed object in the CRD status.

Read the full documentation

Sentinel Reconciler

Use it when you need to watch standard Kubernetes resources that your operator does not own — such as Ingresses, Secrets or ConfigMaps — and create derived resources based on their annotations or labels.

Unlike the other patterns, the Sentinel reconciler does not use a finalizer: child resources are cleaned up automatically by Kubernetes garbage collection through owner references.

Read the full documentation

Project structure

operator-sdk-extra/
├── pkg/
│   ├── apis/                   Status type definitions (DefaultObjectStatus, shared types)
│   │   ├── multiphase/         DefaultMultiPhaseObjectStatus
│   │   ├── remote/             DefaultRemoteObjectStatus
│   │   └── shared/             PhaseName, ConditionName, FinalizerName
│   ├── controller/
│   │   ├── controller.go       Controller interface and setup helpers
│   │   ├── reconciler.go       Reconciler interface (finalizer, logger, recorder)
│   │   ├── multiphase/         Multiphase pattern implementation
│   │   ├── remote/             Remote pattern implementation (generic [k8sObject, apiObject, apiClient])
│   │   └── sentinel/           Sentinel pattern implementation (generic [k8sObject])
│   ├── helper/                 Utilities: diff, merge, slice ops, rate limiter, zip, CRD detection
│   ├── mock/                   Generated mocks for testing
│   ├── object/                 ObjectStatus, MultiPhaseObject, RemoteObject interfaces
│   └── test/                   TestCase / TestStep framework for integration tests
├── cmd/crd/                    CLI tool: clean-crd (remove @clean tagged fields from CRD YAML)
├── samples/
│   ├── memcached-operator/       Multiphase pattern sample
│   ├── elasticsearch-operator/   Remote pattern sample
│   └── ingress-sentinel-operator/ Sentinel pattern sample
├── documentations/             Pattern-specific documentation
├── ci/dagger/                  Dagger CI pipeline module
├── dagger.json                 Dagger module configuration
└── Makefile                    Local development targets

Quick start

Prerequisites
As a Go module dependency
go get github.com/disaster37/operator-sdk-extra/v3@latest

Refer to the Multiphase, Remote or Sentinel documentation to implement the pattern that fits your use case.

Upgrading from v1? This is a major, breaking release (new /v2 module path, package split, and a switch from client-side 3-way diff to Server-Side Apply for the multiphase and sentinel patterns). Follow the v1 → v2 migration guide.

Upgrading from v2? This release adds a new /v3 module path. Follow the v2 → v3 migration guide.

Run the full CI pipeline locally (without pushing)
dagger call --src . ci

See CONTRIBUTING.md for the full list of available commands.

Ignore reconciliation

If you need to manually update a resource managed by an operator without it being reconciled back, add the following annotation:

annotations:
  operator-sdk-extra.webcenter.fr/ignoreReconcile: "true"

Key features

  • Finalizer management: automatic add / remove on create / delete
  • Status tracking: deep-copy + deferred-update only persists status when it actually changed
  • Server-Side Apply: multiphase and sentinel patterns use SSA for precise apply / delete with native field ownership
  • 3-way merge diff (remote pattern): current vs. expected vs. last-applied-configuration to compute precise create / update / delete lists
  • Rate limiter: less aggressive than the default (1s to 1000s exponential backoff, 10 QPS bucket)
  • Annotation-based reconciliation skip via operator-sdk-extra.webcenter.fr/ignoreReconcile
  • Sentinel pattern: watch any K8s resource, derive children, rely on GC for cleanup

Samples

Each pattern has a reference operator implementation in samples/ with its own go.mod and a replace directive pointing to the framework source:

Pattern Sample What it does
Multiphase samples/memcached-operator/ Deploys Memcached by creating a ConfigMap and a Deployment from a CRD
Remote samples/elasticsearch-operator/ Creates and reconciles Elasticsearch roles via the cluster API from a CRD
Sentinel samples/ingress-sentinel-operator/ Watches Ingresses with annotations and derives ConfigMaps in target namespaces

To build a sample, run go build ./... from its directory. The replace directive in its go.mod uses the framework from the local source tree (../../).

License

Apache 2.0 — see LICENSE.

Directories

Path Synopsis
cmd
crd command
pkg
apis
Package shared contains types and functions used by API definitions in the operators package +groupName=operators.webcenter.fr
Package shared contains types and functions used by API definitions in the operators package +groupName=operators.webcenter.fr
apis/multiphase
Package shared contains types and functions used by API definitions in the operators package +groupName=operators.webcenter.fr
Package shared contains types and functions used by API definitions in the operators package +groupName=operators.webcenter.fr
apis/remote
Package shared contains types and functions used by API definitions in the operators package +groupName=operators.webcenter.fr
Package shared contains types and functions used by API definitions in the operators package +groupName=operators.webcenter.fr
apis/shared
Package shared contains types and functions used by API definitions in the operators package +groupName=operators.webcenter.fr
Package shared contains types and functions used by API definitions in the operators package +groupName=operators.webcenter.fr
apis/workflow
+k8s:deepcopy-gen=package,register Package workflow contains types used to model multi-cycle reconciler workflows.
+k8s:deepcopy-gen=package,register Package workflow contains types used to model multi-cycle reconciler workflows.
controller/certificate
Package certificate provides pluggable TLSBackend abstractions for certificate management in Kubernetes operators.
Package certificate provides pluggable TLSBackend abstractions for certificate management in Kubernetes operators.
controller/certificate/byo
Package byo provides a TLSBackend that references an existing user-managed Secret.
Package byo provides a TLSBackend that references an existing user-managed Secret.
controller/certificate/certmanager
Package certmanager provides a TLSBackend that emits cert-manager Issuer and Certificate custom resources.
Package certmanager provides a TLSBackend that emits cert-manager Issuer and Certificate custom resources.
controller/certificate/rotation
Package rotation provides a reusable multi-cycle TLS rotation saga step built on workflow.WorkflowStepReconcilerActionWithDiff.
Package rotation provides a reusable multi-cycle TLS rotation saga step built on workflow.WorkflowStepReconcilerActionWithDiff.
controller/certificate/selfmanaged
Package selfmanaged provides a TLSBackend that generates and manages CA and leaf certificates using Go's crypto/x509 standard library.
Package selfmanaged provides a TLSBackend that generates and manages CA and leaf certificates using Go's crypto/x509 standard library.
controller/certificate/selfmanaged/pernode
Package pernode provides a TLSBackend that keeps one certificate per node in a single Secret (multi-cert transport TLS, e.g.
Package pernode provides a TLSBackend that keeps one certificate per node in a single Secret (multi-cert transport TLS, e.g.
controller/workflow
Package workflow provides a multi-cycle saga abstraction on top of the multiphase reconciler pattern.
Package workflow provides a multi-cycle saga abstraction on top of the multiphase reconciler pattern.
tlsconfig
Package tlsconfig provides a generic, app-agnostic client-side TLS configuration builder.
Package tlsconfig provides a generic, app-agnostic client-side TLS configuration builder.
tlsconfig/k8s
Package k8s resolves TLS material (CA and client certificates) from Kubernetes Secrets into tlsconfig.CertificateOptions.
Package k8s resolves TLS material (CA and client certificates) from Kubernetes Secrets into tlsconfig.CertificateOptions.

Jump to

Keyboard shortcuts

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