deployment-primitive

command
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

README

Deployment Primitive Example

This example demonstrates the usage of the deployment primitive within the operator component framework. It shows how to manage a Kubernetes Deployment as a component of a larger application, utilizing features like:

  • Base Construction: Initializing a Deployment with basic metadata and spec.
  • Feature Mutations: Applying version-gated or conditional changes (sidecars, env vars, annotations) using the Mutator.
  • Custom Status Handlers: Overriding the default logic for determining readiness (ConvergeStatus) and health assessment during rollouts (GraceStatus).
  • Custom Suspension: Extending the default suspension logic (scaling to 0) with additional mutations.
  • Data Extraction: Harvesting information from the reconciled resource.

Directory Structure

  • app/: Defines the mock ExampleApp CRD and the controller that uses the component framework.
  • features/: Contains modular feature definitions:
    • mutations.go: sidecar injection, env vars, and version-based image updates.
    • status.go: implementation of custom handlers for convergence, grace, and suspension.
  • resources/: Contains the central NewDeploymentResource factory that assembles all features using the deployment.Builder.
  • main.go: A standalone entry point that demonstrates a single reconciliation loop using a fake client.

Running the Example

You can run this example directly using go run:

go run examples/deployment-primitive/main.go

This will:

  1. Initialize a fake Kubernetes client.
  2. Create an ExampleApp owner object.
  3. Reconcile the ExampleApp components.
  4. Print the resulting status conditions.

Documentation

Overview

Package main is the entry point for the deployment primitive example.

Directories

Path Synopsis
Package app provides a sample controller using the deployment primitive.
Package app provides a sample controller using the deployment primitive.
Package features provides example feature mutations for the deployment primitive.
Package features provides example feature mutations for the deployment primitive.
Package resources provides resource implementations for the deployment primitive example.
Package resources provides resource implementations for the deployment primitive example.

Jump to

Keyboard shortcuts

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