greeting-controller
A minimal but complete provider built on provider-runtime. It reconciles a
Greeting custom resource against a fake in-process "external system",
demonstrating everything a real Krateo provider wires up:
- a Managed type (
Greeting) embedding apis/common/v1.ConditionedStatus
and satisfying resource.Managed;
- an
ExternalConnecter / ExternalClient pair implementing
Observe / Create / Update / Delete against the external system;
reconciler.NewReconciler with functional options
(WithExternalConnecter, WithLogger);
controller.DefaultOptions() → ForControllerRuntime() for queue and
rate-limiter wiring;
- the OTel-model JSON logging handler from
pkg/logging
(NewOTelJSONHandler + NewSlogLogger).
The external name lifecycle is real: on first reconcile Observe reports the
external resource missing, Create stamps the krateo.io/external-name
annotation, and subsequent reconciles report Available (the Ready
condition) or drift (Diff) when spec.message changes.
Observe sets Ready on every path that returns no error, as the
provider-runtime Ready contract requires (since v1.8.0; see
overview).
main_test.go checks each of those paths with
reconcilertest.AssertObserveSetsReady; run it with go test ..
Compile (no cluster needed)
go build .
Run against a cluster
Preconditions: a reachable cluster in your kubeconfig (e.g. kind create cluster) and permission to create CRDs.
kubectl apply -f ./crd.yaml
go run .
Then, in another terminal:
kubectl apply -f ./greeting.yaml
kubectl get greeting hello -n default -o yaml
The status gains Ready=True (reason Available) and Synced=True (reason
ReconcileSuccess) conditions, and the object gains the
krateo.io/external-name annotation. Edit spec.message and watch the
controller log the Diff and update the fake external system. Delete the
Greeting and the reconciler removes the finalizer after Delete succeeds.