simulate

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: May 31, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

README

pkg/simulate

simulate runs your operator's reconcile loop against an in-memory fake cluster — no Kubernetes required. Give it a Katalog and a CR file and it shows exactly which resources your operator creates, updates, or deletes, and when it converges.

ork simulate                        # Defaults to katalog.yaml/komposer.yaml and cr.yaml

Or pass custom files:

ork simulate -f my-katalog.yaml --cr my-cr.yaml

Developer documentation

I want to… Go to
Read the output and understand what each line means docs/01-output.md
Understand steady state and how to tune cycles docs/02-steady-state.md
Understand what simulate does not cover docs/03-limitations.md
Understand the internals (fake cluster, reactors, indexer) docs/04-internals.md

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CycleResult

type CycleResult struct {
	Cycle int
	Ops   []Op
	Error error
}

CycleResult is the output of one reconcile cycle.

type FakeKubeclient

type FakeKubeclient struct {
	// contains filtered or unexported fields
}

FakeKubeclient implements kubeclient.KubeClient using k8s fakes. All operations are recorded in Ops() for simulation output.

func NewFakeKubeclient

func NewFakeKubeclient(scheme *runtime.Scheme) *FakeKubeclient

func (*FakeKubeclient) AdvanceCycle

func (f *FakeKubeclient) AdvanceCycle()

AdvanceCycle increments the cycle counter. Call between simulated reconciles.

func (*FakeKubeclient) Clientset

func (f *FakeKubeclient) Clientset() kubernetes.Interface

func (*FakeKubeclient) DynamicClient

func (f *FakeKubeclient) DynamicClient() dynamic.Interface

func (*FakeKubeclient) Mapper

func (f *FakeKubeclient) Mapper() meta.RESTMapper

func (*FakeKubeclient) MarkDeploymentReady

func (f *FakeKubeclient) MarkDeploymentReady(namespace, name string)

MarkDeploymentReady advances simulated state — marks a Deployment as Available. Call after the first reconcile cycle to allow the reconciler to progress through "Deploying" → "Ready" state transitions.

func (*FakeKubeclient) Ops

func (f *FakeKubeclient) Ops() []Op

Ops returns all recorded operations in order.

func (*FakeKubeclient) OpsForCycle

func (f *FakeKubeclient) OpsForCycle(cycle int) []Op

OpsForCycle returns operations from one reconcile cycle.

func (*FakeKubeclient) PatchAnnotations

func (f *FakeKubeclient) PatchAnnotations(_ context.Context, obj runtime.Object, _ schema.GroupVersionResource, annotations map[string]string) error

func (*FakeKubeclient) PatchFinalizers

func (f *FakeKubeclient) PatchFinalizers(_ context.Context, obj runtime.Object, _ schema.GroupVersionResource, finalizers []string) error

func (*FakeKubeclient) PatchLabels

func (f *FakeKubeclient) PatchLabels(_ context.Context, obj runtime.Object, _ schema.GroupVersionResource, _, desired map[string]string) error

func (*FakeKubeclient) PatchStatus

func (f *FakeKubeclient) PatchStatus(_ context.Context, obj domain.Object, _ schema.GroupVersionResource, _ map[string]interface{}) error

type Op

type Op struct {
	Cycle     int
	Verb      string // "create", "update", "delete", "get", "patch"
	Resource  string // "deployments", "services", etc.
	Namespace string
	Name      string
	At        time.Time
}

Op is one recorded cluster operation.

type Result

type Result struct {
	Cycles   []CycleResult
	Steady   bool
	SteadyAt int // cycle number where steady state was first detected (0 if not reached)
}

Result is the output of one simulation run.

func Run

func Run(ctx context.Context, kat *katalog.Katalog, crdName string, cr *unstructured.Unstructured, maxCycles int) (*Result, error)

Run simulates the operator against an in-memory cluster.

kat is the parsed Katalog. crdName is the CRD entry to simulate. cr is the CR to reconcile. maxCycles is the maximum number of reconcile cycles.

Jump to

Keyboard shortcuts

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