The exam won't ask you to write a controller in Go. It will ask you to operate, integrate, and above all diagnose operators: reading status conditions, events, owned resources, and controller logs in that exact order.

needsmake up api

Orientation

competency 3.3 · operators for automation and integration

Almost every layer of this lab is an operator reconciling CRDs: Crossplane, Kyverno, Prometheus Operator, Trivy Operator, CloudNativePG, Argo CD, and Flux. Whenever an unfamiliar operator lands in front of you on exam day, ask the exact same four questions: what kind does it watch, what does it create, what does its status say, and where do its logs live?

Level-based, not edge-based

A controller watches a kind and runs the same loop for each object: read actual state, compare it with desired spec, take one step toward convergence, write status, and requeue if needed. Because it acts on the current state it sees rather than the specific event that woke it, missed events don't matter, duplicate events are harmless, and the loop is safe to re-run anytime. That's why deleting an operator-owned pod doesn't "reset" anything; the next reconcile simply recreates it without knowing or caring who deleted it.

The conventions that make operators readable

status · generation · owners · finalizers

1 · Status conditions

Standard conditions carry type, status (True/False/Unknown), reason (machine-readable CamelCase), message (human-readable), lastTransitionTime, and observedGeneration. Ready is the roll-up summary; the other conditions pinpoint which phase is stuck. Good operators pair those with Kubernetes Events so you also get timestamps and retry counts.

2 · observedGeneration versus metadata.generation

If those two numbers don't match, the controller hasn't processed your latest edit yet; whatever status says is describing an older spec. Checking this first saves you from chasing stale errors, and almost nobody remembers to do it. Just keep in mind that metadata.generation only tracks spec changes when the CRD enables the status subresource; without it, every status write bumps generation too and observedGeneration stops meaning anything (section 3.2).

3 · Owner references

Resources created by an operator carry ownerReferences pointing back to their parent CR. That single field answers "what keeps recreating this?", drives cascade deletion (foreground, background, or orphan), and lets you map an entire operator's object tree without reading a line of docs. Two hard Kubernetes rules: an owner must live in the same namespace (or be cluster-scoped), and a namespaced object can never own a cluster-scoped one, the exact constraint behind Crossplane's architecture in section 3.5.

4 · Finalizers

A deleted object hangs in Terminating while a finalizer sits on it, either because the controller is actively running teardown logic or because the controller is dead and can't clear it. A stuck namespace or CR almost always comes down to finding whose finalizer is attached and checking why that controller isn't running. Stripping a finalizer by hand is your last resort: it unblocks deletion, but leaks whatever external cleanup (cloud volumes, databases, DNS records) the controller was supposed to perform. Make that trade deliberately.

Cluster/pg (your CR)
 ├─ ownerRef ─▶ StatefulSet-ish pods  pg-1, pg-2         each with a PVC
 ├─ ownerRef ─▶ Services  pg-rw, pg-ro, pg-r
 ├─ ownerRef ─▶ Secrets  pg-app, pg-superuser        ← connection details
 └─ status.conditions[]  Ready / Initialized / ContinuousArchiving …
                         observedGeneration must equal metadata.generation
The four-command diagnosis
kubectl get <kind> <name> -o jsonpath='{.status.conditions}' | jq
kubectl get events --field-selector involvedObject.name=<name> --sort-by=.lastTimestamp
kubectl get all,pvc,secret -l <the operator's label> -n <ns>
kubectl -n <operator-ns> logs deploy/<controller> --tail=100
outputcaptured 2026-08-26
$ kubectl get cluster pg -o jsonpath='{.status.conditions}' | jq
[
  {
    "lastTransitionTime": "2026-08-27T02:02:29Z",
    "message": "Cluster has been bootstrapped",
    "reason": "BootstrapCompleted",
    "status": "True",
    "type": "Initialized"
  },
  {
    "lastTransitionTime": "2026-08-27T02:03:45Z",
    "message": "A single, unique system ID was found across reporting instances.",
    "reason": "Unique",
    "status": "True",
    "type": "ConsistentSystemID"
  },
  {
    "lastTransitionTime": "2026-08-27T02:04:50Z",
    "message": "Cluster is Ready",
    "reason": "ClusterIsReady",
    "status": "True",
    "type": "Ready"
  },
  {
    "lastTransitionTime": "2026-08-27T02:03:44Z",
    "message": "Continuous archiving is working",
    "reason": "ContinuousArchivingSuccess",
    "status": "True",
    "type": "ContinuousArchiving"
  }
]
$ kubectl get events --field-selector involvedObject.name=pg --sort-by=.lastTimestamp
LAST SEEN   TYPE     REASON                        OBJECT       MESSAGE
3m59s       Normal   CreatingPodDisruptionBudget   cluster/pg   Creating PodDisruptionBudget pg-primary
3m59s       Normal   CreatingServiceAccount        cluster/pg   Creating ServiceAccount
3m59s       Normal   CreatingRole                  cluster/pg   Creating Cluster Role
3m58s       Normal   CreatingInstance              cluster/pg   Primary instance (initdb)
2m36s       Normal   CreatingInstance              cluster/pg   Creating instance pg-2
$ kubectl get all,pvc,secret -l cnpg.io/cluster=pg -n default
NAME       READY   STATUS    RESTARTS   AGE
pod/pg-1   1/1     Running   0          2m49s
pod/pg-2   1/1     Running   0          108s

NAME            TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
service/pg-r    ClusterIP   10.96.28.97     <none>        5432/TCP   4m
service/pg-ro   ClusterIP   10.96.161.206   <none>        5432/TCP   4m
service/pg-rw   ClusterIP   10.96.181.56    <none>        5432/TCP   3m59s

NAME                         STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   VOLUMEATTRIBUTESCLASS   AGE
persistentvolumeclaim/pg-1   Bound    pvc-b4511fca-9bf3-4cbf-bc9d-d56906094336   1Gi        RWO            standard       <unset>                 3m59s
persistentvolumeclaim/pg-2   Bound    pvc-fae7c17c-a4a7-45d5-b239-2662652ed787   1Gi        RWO            standard       <unset>                 2m37s

NAME            TYPE                       DATA   AGE
secret/pg-app   kubernetes.io/basic-auth   11     4m1s
$ kubectl -n cnpg-system logs deploy/cnpg-cloudnative-pg --tail=100
{"level":"info","ts":"2026-08-27T01:52:15.835497336Z","msg":"Starting EventSource","controller":"pooler","controllerGroup":"postgresql.cnpg.io","controllerKind":"Pooler","source":"kind source: *v1.Role"}
{"level":"info","ts":"2026-08-27T01:52:15.835502695Z","msg":"Starting EventSource","controller":"cluster","controllerGroup":"postgresql.cnpg.io","controllerKind":"Cluster","source":"kind source: *v1.DatabaseRole"}
{"level":"info","ts":"2026-08-27T01:52:15.83547942Z","msg":"Starting EventSource","controller":"pooler","controllerGroup":"postgresql.cnpg.io","controllerKind":"Pooler","source":"kind source: *v1.ServiceAccount"}
{"level":"info","ts":"2026-08-27T01:52:15.835506197Z","msg":"Starting EventSource","controller":"plugin","controllerGroup":"","controllerKind":"Service","source":"kind source: *v1.Service"}
{"level":"info","ts":"2026-08-27T01:52:15.835487001Z","msg":"Starting EventSource","controller":"plugin","controllerGroup":"","controllerKind":"Service","source":"kind source: *v1.Secret"}
{"level":"info","ts":"2026-08-27T01:52:15.835507298Z","msg":"Starting EventSource","controller":"pooler","controllerGroup":"postgresql.cnpg.io","controllerKind":"Pooler","source":"kind source: *v1.ImageCatalog"}
{"level":"info","ts":"2026-08-27T01:52:15.935948428Z","msg":"Starting Controller","controller":"backup","controllerGroup":"postgresql.cnpg.io","controllerKind":"Backup"}
{"level":"info","ts":"2026-08-27T01:52:15.935986228Z","msg":"Starting workers","controller":"backup","controllerGroup":"postgresql.cnpg.io","controllerKind":"Backup","worker count":1}
{"level":"info","ts":"2026-08-27T01:52:16.036525115Z","msg":"Starting Controller","controller":"scheduled-backup","controllerGroup":"postgresql.cnpg.io","controllerKind":"ScheduledBackup"}
{"level":"info","ts":"2026-08-27T01:52:16.036555833Z","msg":"Starting workers","controller":"scheduled-backup","controllerGroup":"postgresql.cnpg.io","controllerKind":"ScheduledBackup","worker count":10}
{"level":"info","ts":"2026-08-27T01:52:16.037638856Z","msg":"Starting Controller","controller":"plugin","controllerGroup":"","controllerKind":"Service"}
{"level":"info","ts":"2026-08-27T01:52:16.037687808Z","msg":"Starting workers","controller":"plugin","controllerGroup":"","controllerKind":"Service","worker count":10}
{"level":"info","ts":"2026-08-27T01:52:16.037735706Z","msg":"Starting Controller","controller":"cluster","controllerGroup":"postgresql.cnpg.io","controllerKind":"Cluster"}
{"level":"info","ts":"2026-08-27T01:52:16.037731587Z","msg":"Starting Controller","controller":"pooler","controllerGroup":"postgresql.cnpg.io","controllerKind":"Pooler"}
{"level":"info","ts":"2026-08-27T01:52:16.037745707Z","msg":"Starting workers","controller":"cluster","controllerGroup":"postgresql.cnpg.io","controllerKind":"Cluster","worker count":10}
{"level":"info","ts":"2026-08-27T01:52:16.03775078Z","msg":"Starting workers","controller":"pooler","controllerGroup":"postgresql.cnpg.io","controllerKind":"Pooler","worker count":10}
{"level":"info","ts":"2026-08-27T01:52:16.037728098Z","msg":"Starting Controller","controller":"database-role","controllerGroup":"postgresql.cnpg.io","controllerKind":"DatabaseRole"}
{"level":"info","ts":"2026-08-27T01:52:16.037778053Z","msg":"Starting workers","controller":"database-role","controllerGroup":"postgresql.cnpg.io","controllerKind":"DatabaseRole","worker count":10}
{"level":"info","ts":"2026-08-27T02:02:26.19113155Z","logger":"cluster-resource","msg":"Defaulting for Cluster","version":"v1","name":"pg","namespace":"default"}
{"level":"info","ts":"2026-08-27T02:02:26.22083863Z","logger":"cluster-resource","msg":"Defaulting for Cluster","version":"v1","name":"pg","namespace":"default"}
{"level":"info","ts":"2026-08-27T02:02:26.32053831Z","logger":"cluster-resource","msg":"Defaulting for Cluster","version":"v1","name":"pg","namespace":"default"}
{"level":"info","ts":"2026-08-27T02:02:26.460210545Z","msg":"no orphan PVCs found, skipping the restored cluster reconciliation","controller":"cluster","controllerGroup":"postgresql.cnpg.io","controllerKind":"Cluster","Cluster":{"name":"pg","namespace":"default"},"namespace":"default","name":"pg","reconcileID":"7652038d-f270-4d4c-9a41-d2fbd1ab01f4"}
{"level":"info","ts":"2026-08-27T02:02:26.716626012Z","msg":"creating service","controller":"cluster","controllerGroup":"postgresql.cnpg.io","controllerKind":"Cluster","Cluster":{"name":"pg","namespace":"default"},"namespace":"default","name":"pg","reconcileID":"7652038d-f270-4d4c-9a41-d2fbd1ab01f4","serviceName":"pg-r","updateStrategy":"patch"}
{"level":"info","ts":"2026-08-27T02:02:26.949154863Z","msg":"creating service","controller":"cluster","controllerGroup":"postgresql.cnpg.io","controllerKind":"Cluster","Cluster":{"name":"pg","namespace":"default"},"namespace":"default","name":"pg","reconcileID":"7652038d-f270-4d4c-9a41-d2fbd1ab01f4","serviceName":"pg-ro","updateStrategy":"patch"}
{"level":"info","ts":"2026-08-27T02:02:27.089001205Z","msg":"creating service","controller":"cluster","controllerGroup":"postgresql.cnpg.io","controllerKind":"Cluster","Cluster":{"name":"pg","namespace":"default"},"namespace":"default","name":"pg","reconcileID":"7652038d-f270-4d4c-9a41-d2fbd1ab01f4","serviceName":"pg-rw","updateStrategy":"patch"}
{"level":"info","ts":"2026-08-27T02:02:27.970787374Z","msg":"Created primary lease","controller":"cluster","controllerGroup":"postgresql.cnpg.io","controllerKind":"Cluster","Cluster":{"name":"pg","namespace":"default"},"namespace":"default","name":"pg","reconcileID":"7652038d-f270-4d4c-9a41-d2fbd1ab01f4","leaseName":"pg"}
{"level":"info","ts":"2026-08-27T02:02:28.411769916Z","msg":"Creating new Job","controller":"cluster","controllerGroup":"postgresql.cnpg.io","controllerKind":"Cluster","Cluster":{"name":"pg","namespace":"default"},"namespace":"default","name":"pg","reconcileID":"7652038d-f270-4d4c-9a41-d2fbd1ab01f4","jobName":"pg-1-initdb","primary":true}
{"level":"info","ts":"2026-08-27T02:02:28.578577487Z","logger":"cluster-resource","msg":"Defaulting for Cluster","version":"v1","name":"pg","namespace":"default"}
{"level":"info","ts":"2026-08-27T02:02:28.64742958Z","msg":"skipping pvc because it has owner metadata","controller":"cluster","controllerGroup":"postgresql.cnpg.io","controllerKind":"Cluster","Cluster":{"name":"pg","namespace":"default"},"namespace":"default","name":"pg","reconcileID":"175abb6a-f53f-48c2-9d02-5df1736425de","step":"get_orphan_pvcs","pvcName":"pg-1"}
{"level":"info","ts":"2026-08-27T02:02:28.647440816Z","msg":"no orphan PVCs found, skipping the restored cluster reconciliation","controller":"cluster","controllerGroup":"postgresql.cnpg.io","controllerKind":"Cluster","Cluster":{"name":"pg","namespace":"default"},"namespace":"default","name":"pg","reconcileID":"175abb6a-f53f-48c2-9d02-5df1736425de"}
{"level":"info","ts":"2026-08-27T02:02:29.251311342Z","logger":"cluster-resource","msg":"Defaulting for Cluster","version":"v1","name":"pg","namespace":"default"}
{"level":"info","ts":"2026-08-27T02:02:35.275772086Z","logger":"cluster-resource","msg":"Defaulting for Cluster","version":"v1","name":"pg","namespace":"default"}
{"level":"info","ts":"2026-08-27T02:02:41.089429634Z","logger":"cluster-resource","msg":"Defaulting for Cluster","version":"v1","name":"pg","namespace":"default"}
{"level":"info","ts":"2026-08-27T02:02:43.811342944Z","logger":"cluster-resource","msg":"Defaulting for Cluster","version":"v1","name":"pg","namespace":"default"}
{"level":"info","ts":"2026-08-27T02:02:44.368388244Z","logger":"cluster-resource","msg":"Defaulting for Cluster","version":"v1","name":"pg","namespace":"default"}
{"level":"info","ts":"2026-08-27T02:02:49.675245765Z","logger":"cluster-resource","msg":"Defaulting for Cluster","version":"v1","name":"pg","namespace":"default"}
{"level":"info","ts":"2026-08-27T02:02:55.257182935Z","logger":"cluster-resource","msg":"Defaulting for Cluster","version":"v1","name":"pg","namespace":"default"}
{"level":"info","ts":"2026-08-27T02:03:00.993060187Z","logger":"cluster-resource","msg":"Defaulting for Cluster","version":"v1","name":"pg","namespace":"default"}
{"level":"info","ts":"2026-08-27T02:03:06.998428892Z","logger":"cluster-resource","msg":"Defaulting for Cluster","version":"v1","name":"pg","namespace":"default"}
{"level":"info","ts":"2026-08-27T02:03:12.204012127Z","logger":"cluster-resource","msg":"Defaulting for Cluster","version":"v1","name":"pg","namespace":"default"}
… (rest of the tail omitted)

Run them in that order. Conditions tell you the phase, events show the attempts, owned objects show what actually got created, and logs tell you why the controller gave up. Diving straight into noisy controller logs first is the biggest time sink in domain 3.

Vocabulary around operators

worth knowing as words
  • Operator capability levels (the OperatorHub model): 1 Basic Install → 2 Seamless Upgrades → 3 Full Lifecycle (backup, failover) → 4 Deep Insights (metrics, alerts) → 5 Auto Pilot (auto-scaling, auto-tuning). Great yardstick whenever a scenario asks whether an operator is worth adopting.
  • OLM (Operator Lifecycle Manager): installs and upgrades operators from curated catalogs. Not installed in this lab, but know how it works (details below).
  • Kubebuilder / Operator SDK / controller-runtime: the Go scaffolding behind most Kubernetes operators. make tools puts kubebuilder on your PATH if you want to scaffold a toy controller (kubebuilder init, kubebuilder create api) to see the machinery, though writing Go is outside CNPE scope.
  • Reconcile loop hazards worth naming: hot loops (a controller whose status write re-triggers itself endlessly), requeue backoff, leader election (why multi-replica operator Deployments use a Lease), and informer cache staleness right after a write.
  • Operator vs controller vs webhook: a controller reconciles; an operator is a controller packed with domain-specific operational knowledge and CRDs; a webhook intercepts API writes synchronously. Their failure modes are night and day: a dead controller just pauses convergence, whereas a dead webhook with failurePolicy: Fail blocks every matching write outright.
Integration is a competency word

"Operators for platform automation and integration" means plugging an operator cleanly into the rest of your platform: its CRs are managed via GitOps, its metrics are scraped (ServiceMonitor/PodMonitor), its connection Secrets flow to workloads, its CRs pass through admission policy like any built-in object, and its API sits behind a thinner developer-facing abstraction (Crossplane, kro, or a Backstage template). Naming all five gives you a complete exam answer.

Inside a controller: controller-runtime in one page

manager · reconciler · For, Owns, Watches · predicates · requeue · leader election · the RBAC it needs

You won't write a line of Go on the exam, yet almost every operator you troubleshoot is built on the same dozen controller-runtime primitives, and their names pop up constantly in logs, flags, and Deployment specs. Recognizing them turns "the operator is acting weird" into "the informer cache is stale" or "it lost its leader Lease".

The pieces

  • Manager: the process hosting shared informer caches, a Kubernetes client, metrics (:8080), health probes (:8081, /healthz and /readyz), an optional webhook server (:9443), and the controllers themselves. Deployment flags like --leader-elect, --metrics-bind-address, --health-probe-bind-address, and --watch-namespace all configure the manager.
  • Controller: a deduplicating work queue of namespace/name keys feeding a Reconciler with a single method, Reconcile(ctx, req) (Result, error). Because it only receives a key (never the triggering event), reconciliation is level-based by construction. MaxConcurrentReconciles defaults to 1, which explains why an operator managing hundreds of CRs can look sluggish.
  • Builder: For(&MyKind{}) watches the primary CR and enqueues its key. Owns(&appsv1.Deployment{}) watches owned child kinds and enqueues the owner found via ownerReferences (with controller: true). Watches(...) maps any other object (like a referenced Secret) onto the CR keys to reconcile. Owns is why deleting an operator's Deployment or Secret sparks an instant rebuild, and why ownerReferences maps everything the operator manages.
  • Predicates filter watch events before they hit the work queue: GenerationChangedPredicate drops status-only updates where metadata.generation didn't move, alongside LabelChangedPredicate, AnnotationChangedPredicate, and custom filters. When an operator either ignores a label change or spins in a hot loop, a predicate is usually the culprit.
  • Result: returning Result{} means done; Result{RequeueAfter: 5*time.Minute} schedules a periodic poll (common for external APIs); returning an error triggers exponential backoff from the workqueue rate limiter (starting at 5 ms, doubling up to ~16 minutes, within a 10/s global cap). Log lines like "Retrying in 1m4s" are that exact backoff.
  • Cache: reads hit local informers rather than etcd directly, so reading right after a write can briefly return a stale copy. Good reconcilers handle that gracefully on the next pass instead of crashing.
  • Leader election: uses a Lease in the operator's namespace named by LeaderElectionID (defaults: 15 s LeaseDuration, 10 s RenewDeadline, 2 s RetryPeriod). Standby replicas stay warm and idle until they win the lease. Run kubectl get lease -n <operator-ns> and read holderIdentity to see which pod is actually reconciling.

The RBAC an operator needs, and what its absence looks like

RuleWhySymptom when missing
its own CRD: get, list, watch, update, patch; plus <plural>/status and <plural>/finalizersWatch primary CRs, write status updates, and manage finalizersStartup crash ("failed to watch") or Forbidden: ... cannot update resource "widgets/status" in logs; CRs never populate status
every owned kind: create, update, patch, delete, get, list, watchOwns() needs to watch and manage every child kindCR stays stuck in Progressing while logs log is forbidden: User "system:serviceaccount:ns:sa" cannot create ...
coordination.k8s.io leases: get, create, updateLeader election"error retrieving resource lock": no replica ever becomes leader, so nothing reconciles
events: create, patchPowers kubectl describe eventsQuiet failure: conditions still update, but zero Events ever show up
the Secrets or ConfigMaps it reads across namespacesReads credentials or config inputsA Forbidden log error that can look like the Secret is missing

Kubebuilder compiles these into a ClusterRole from // +kubebuilder:rbac comments, while Helm and Ansible operators ship equivalent manifests by hand. A namespace-scoped install (--watch-namespace) can swap ClusterRoles for Roles, the multi-tenant trade-off from section 1.4.

Admission webhooks inside operators

Many operators install their own ValidatingWebhookConfiguration and MutatingWebhookConfiguration for defaulting, cross-field validation beyond CEL, or version conversion. Those webhooks need TLS certs, usually via cert-manager's cert-manager.io/inject-ca-from annotation or a self-signed key pair patched into caBundle. When the operator pod dies while its webhook carries failurePolicy: Fail, every write to its CRDs fails with "failed calling webhook" (including your GitOps controller's syncs). Check webhooks first whenever an entire API group turns read-only during an operator upgrade.

Reflex

Check who leads (kubectl -n <op-ns> get lease), grep logs for RBAC and backoff (kubectl -n <op-ns> logs deploy/<op> | grep -i -E 'forbidden|error'), and check for blocking webhooks (kubectl get validatingwebhookconfiguration -o wide) alongside the four-command diagnosis above. Restarting the operator pod comes after those checks, never before.

Installing and judging operators

OLM v0 vs v1 · capability levels with their tests · Helm, Ansible, Go · condition conventions · a stuck operator, step by step

OLM v0 and OLM v1

AspectOLM v0 (classic)OLM v1 (operator-controller, GA)
CatalogCatalogSource (index image)ClusterCatalog { spec.source.type: Image, image.ref } with priority and availabilityMode; conditions Serving, Progressing
Install requestSubscription (package, channel, installPlanApproval Automatic|Manual) + OperatorGroup for target namespacesClusterExtension { spec.namespace, spec.serviceAccount.name, spec.source.sourceType: Catalog, catalog.packageName, channels, version (semver range), upgradeConstraintPolicy }
What runs the installOLM's own privileged ServiceAccount, creating a ClusterServiceVersion per version and InstallPlan objects to approveThe ServiceAccount you specify, scoped to the exact RBAC the bundle needs (least privilege is explicit)
UpgradesFollows the channel's declared upgrade graphCatalogProvided (default: only valid graph successors) or SelfCertified (any version, even downgrades, at your risk); includes a CRD upgrade safety preflight blocking scope changes, dropped stored versions, removed fields, new required fields, changed defaults, or tightened bounds
StatusCSV phase Succeeded / Failedconditions Installed and Progressing; status.install.bundle.name/version

Plenty of teams skip OLM altogether and deploy operators via Helm charts or plain manifests, letting Flux's HelmRelease or an Argo CD Application drive the lifecycle; just remember the CRD upgrade caveat from section 2.3 (Helm's upgrade.crds defaults to Skip).

Capability levels with the question that decides each

LevelNamePasses whenCeiling for
1Basic InstallThe CR alone provisions and configures the workload and reports readiness in status
2Seamless UpgradesBumping the CR (or operator) upgrades the operand cleanly without manual steps or downtimeHelm-based operators cap out here
3Full LifecycleBackups, restores, failover, member scaling, and reconfiguration are native operator actionsAnsible operators usually peak here
4Deep InsightsExposes rich metrics, alerts, and custom Events for both the operand and itself
5Auto PilotAuto-scaling, auto-healing, auto-tuning, and anomaly detection driven by the operand's own telemetryGo operators only, in practice

The three Operator SDK flavors map cleanly to that ladder: a Helm operator turns a CR spec into Helm values (zero custom Go logic, Levels 1–2); an Ansible operator runs a playbook or role per reconcile (reaches Level 3, slower loops); and a Go operator uses controller-runtime directly (no ceiling). When an exam scenario asks "should we adopt this operator or manage the database ourselves?", match the operator's capability level to the workload: a Level 1 operator for a stateful database buys you almost nothing on day 2.

Status conditions, the convention in full

  • metav1.Condition standardizes six fields: type (CamelCase, or domain/CamelCase for third parties), status (True/False/Unknown), reason (required CamelCase machine code), message (human-readable), lastTransitionTime (only moves when status flips), and observedGeneration. The slice uses listType: map keyed by type.
  • Condition names describe an observed state using an adjective or past participle (Ready, Available, Succeeded, Degraded), not an action verb like Deploying. Long-running transitions still model as state flags (Resizing, Reconciling) toggled True or False.
  • Polarity matters: Ready=True is normal-true, while Stalled=True or Degraded=True is normal-false. Generic tools can't summarize arbitrary condition lists without knowing each condition's polarity, which is why the convention calls for a single roll-up summary condition (Ready for long-running resources, Succeeded for run-to-completion jobs).
  • A missing condition means Unknown, so good controllers populate their conditions on the first pass (even as Unknown) to prove they're alive. kstatus (used by Flux, Argo CD guidance, and kubectl wait) reads Ready, Reconciling, Stalled, and observedGeneration to compute Current, InProgress, or Failed.

Reading a stuck operator, in order

  1. Compare metadata.generation vs status.observedGeneration: if they stay unequal, the controller hasn't processed your edit: it's down, not holding the leader lease, or filtering your event with a predicate.
  2. Read conditions: grab the reason on the False or Stalled condition. A kstatus Stalled=True means the controller stopped retrying until you change the spec.
  3. Check Events on the CR: Warning events usually quote the exact failed API call.
  4. Follow ownerReferences to owned objects: spot which child is missing or unhealthy and read its events (quota, PSS, admission, image pull).
  5. Inspect the operator pod: verify it's running, check who holds the Lease (kubectl get lease), and scan logs for Forbidden (RBAC), connection refused (dependency), or backoff retries, then inspect any webhooks it registered.
  6. Check finalizers: a CR stuck in Terminating with a finalizer from a dead or uninstalled operator needs either that controller brought back online, or a deliberate manual finalizer strip knowing you'll leak whatever external resource it was guarding.
How this gets tested

"The database CR has been Progressing for twenty minutes" is graded on finding the actual root cause: an RBAC Forbidden in the operator log, a NetworkPolicy blocking the init Job, a quota blocking pods on the StatefulSet, or a webhook with no endpoints. Each leaves its own distinct fingerprint (log line, Hubble drop, ReplicaSet event, webhook error). Find the artifact and fix the broken object; deleting and recreating the CR is a level-based no-op that just reproduces the exact same stall.

Exercises

tick the dot when its check passes

Start in default deliberately (we'll hit the locked-down tenant-namespace trap in a moment):

kubectl apply -f - <<'EOF'
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata: { name: pg, namespace: default }
spec:
  instances: 2
  storage: { size: 1Gi }
EOF
kubectl get cluster pg -w
outputcaptured 2026-08-26
$ kubectl apply -f - <<'EOF'
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata: { name: pg, namespace: default }
spec:
  instances: 2
  storage: { size: 1Gi }
EOF
cluster.postgresql.cnpg.io/pg created
$ kubectl get cluster pg -w
NAME   AGE   INSTANCES   READY   STATUS   PRIMARY
pg     0s                                 
pg     2s                                 
pg     2s                                 
pg     2s                                 
pg     2s                        Setting up primary   
pg     3s    1                   Setting up primary   
pg     71s   1                   Setting up primary   
pg     72s   1                   Setting up primary   
pg     72s   1                   Waiting for the instances to become active   
pg     77s   1                   Waiting for the instances to become active   
pg     78s   1                   Waiting for the instances to become active   pg-1
pg     78s   1                   Waiting for the instances to become active   pg-1
pg     79s   1                   Waiting for the instances to become active   pg-1
pg     84s   1           1       Waiting for the instances to become active   pg-1
pg     84s   1           1       Creating a new replica                       pg-1
pg     85s   2           1       Creating a new replica                       pg-1
pg     2m12s   2           1       Creating a new replica                       pg-1
pg     2m13s   2           1       Creating a new replica                       pg-1
pg     2m13s   2           1       Waiting for the instances to become active   pg-1
pg     2m19s   2           1       Waiting for the instances to become active   pg-1
pg     2m21s   2           1       Waiting for the instances to become active   pg-1
pg     2m23s   2           1       Waiting for the instances to become active   pg-1
pg     2m24s   2           2       Waiting for the instances to become active   pg-1
pg     2m24s   2           2       Cluster in healthy state                     pg-1
pg     2m25s   2           2       Cluster in healthy state                     pg-1
^C

While it boots up, run the diagnosis sequence: kubectl get events --field-selector involvedObject.name=pg --sort-by=.lastTimestamp, kubectl get cluster pg -o jsonpath='{.status.conditions}' | jq, and kubectl get pods,pvc,svc -l cnpg.io/cluster=pg.

verify: the Cluster reaches Ready with two instance pods, each backed by its own PVC (section 1.3 in action), plus three Services (rw, ro, r). Check ownerReferences to prove what owns every object without guessing.

Run kubectl delete pod pg-1 and watch how fast it heals. Then scale declaratively with kubectl patch cluster pg --type=merge -p '{"spec":{"instances":3}}', and verify observedGeneration catches up to generation before trusting the new status.

verify: a replacement pod spins up within seconds while the Cluster's conditions dip briefly and return to Ready; after patching, status.observedGeneration == metadata.generation.

The lab includes a deliberately broken manifest: examples/crossplane/pg-cluster.yaml deploys into team-a, where a default-deny NetworkPolicy silently drops the Postgres pod's traffic to the Kubernetes API server (if you skipped make sec, apply examples/multitenancy/team-a.yaml to set up the same trap). Apply it and trace purely from evidence: conditions read Initialized True / Ready False, phase hangs on "Setting up primary", and kubectl -n team-a logs job/pg-1-initdb ends in dial tcp 10.96.0.1:443: i/o timeout. Think through the fix before reading on: a standard ipBlock rule won't work because the ClusterIP gets DNAT'd before policy evaluation. You need a CiliumNetworkPolicy in team-a with endpointSelector: {} and an egress rule allowing toEntities: [kube-apiserver].

verify: once you apply that CiliumNetworkPolicy, the Postgres cluster converges to Ready inside team-a.

Pick any two operators installed on your cluster. For each one, name the primary CR kind it watches, trace one owned resource via ownerReferences, and locate its controller Deployment.

verify: confirm with kubectl api-resources --api-group=<group> and a one-line summary for each, the exact four-question checklist you'll run on any unfamiliar operator on exam day.

Running two replicas of an operator doesn't mean both reconcile at once: one holds a Lease while the other waits on standby. That Lease is an ordinary Kubernetes object, making it the fastest way to find which pod is actually doing the work.

kubectl -n cnpg-system get lease
kubectl -n cnpg-system get lease -o jsonpath='{range .items[*]}{.metadata.name} {.spec.holderIdentity}{"\n"}{end}'
kubectl -n cnpg-system scale deploy cnpg-cloudnative-pg --replicas=2
kubectl -n cnpg-system rollout status deploy cnpg-cloudnative-pg --timeout=120s
kubectl -n cnpg-system get pods -l app.kubernetes.io/name=cloudnative-pg
kubectl -n cnpg-system get lease -o jsonpath='{range .items[*]}{.metadata.name} {.spec.holderIdentity}{"\n"}{end}'
kubectl -n cnpg-system scale deploy cnpg-cloudnative-pg --replicas=1
outputcaptured 2026-09-12
$ kubectl -n cnpg-system get lease
NAME               HOLDER                                                                      AGE
db9c8771.cnpg.io   cnpg-cloudnative-pg-7d855d69bb-9c82x_1bf08cef-9c4b-46ce-8407-5408ac771a1b   7h8m
$ kubectl -n cnpg-system get lease -o jsonpath='{range .items[*]}{.metadata.name} {.spec.holderIdentity}{"\n"}{end}'
db9c8771.cnpg.io cnpg-cloudnative-pg-7d855d69bb-9c82x_1bf08cef-9c4b-46ce-8407-5408ac771a1b
$ kubectl -n cnpg-system scale deploy cnpg-cloudnative-pg --replicas=2
deployment.apps/cnpg-cloudnative-pg scaled
$ kubectl -n cnpg-system rollout status deploy cnpg-cloudnative-pg --timeout=120s
Waiting for deployment "cnpg-cloudnative-pg" rollout to finish: 1 out of 2 new replicas have been updated...
Waiting for deployment "cnpg-cloudnative-pg" rollout to finish: 1 of 2 updated replicas are available...
deployment "cnpg-cloudnative-pg" successfully rolled out
$ kubectl -n cnpg-system get pods -l app.kubernetes.io/name=cloudnative-pg
NAME                                   READY   STATUS    RESTARTS   AGE
cnpg-cloudnative-pg-7d855d69bb-4t22l   1/1     Running   0          26s
cnpg-cloudnative-pg-7d855d69bb-9c82x   1/1     Running   0          5h52m
$ kubectl -n cnpg-system get lease -o jsonpath='{range .items[*]}{.metadata.name} {.spec.holderIdentity}{"\n"}{end}'
db9c8771.cnpg.io cnpg-cloudnative-pg-7d855d69bb-9c82x_1bf08cef-9c4b-46ce-8407-5408ac771a1b
$ kubectl -n cnpg-system scale deploy cnpg-cloudnative-pg --replicas=1
deployment.apps/cnpg-cloudnative-pg scaled
verify: no matter how many replicas are running, there's only one holderIdentity and it names one of the running pods.

Every operator runs under a ServiceAccount, and everything it's allowed to touch is spelled out in its ClusterRole. Notice the same blueprint across every operator you inspect: its own CRDs, their /status and /finalizers subresources, and the core kinds it composes.

kubectl -n cnpg-system get sa
kubectl get clusterrole -o name | grep -i cnpg
kubectl get clusterrole cnpg-cloudnative-pg -o yaml | grep -B3 -A6 'postgresql.cnpg.io'
kubectl get clusterrole cnpg-cloudnative-pg -o jsonpath='{range .rules[*]}{.apiGroups} {.resources} {.verbs}{"\n"}{end}' | head -20
outputcaptured 2026-11-18
$ kubectl -n cnpg-system get sa
NAME                  AGE
cnpg-cloudnative-pg   3h57m
default               3h57m
$ kubectl get clusterrole -o name | grep -i cnpg
clusterrole.rbac.authorization.k8s.io/cnpg-cloudnative-pg
clusterrole.rbac.authorization.k8s.io/cnpg-cloudnative-pg-edit
clusterrole.rbac.authorization.k8s.io/cnpg-cloudnative-pg-view
$ kubectl get clusterrole cnpg-cloudnative-pg -o yaml | grep -B3 -A6 'postgresql.cnpg.io'
  - get
  - patch
- apiGroups:
  - postgresql.cnpg.io
  resources:
  - clusterimagecatalogs
  verbs:
  - get
  - list
  - watch
--
  - update
  - watch
- apiGroups:
  - postgresql.cnpg.io
  resources:
  - backups
  - clusters
  - databaseroles
  - databases
  - poolers
--
  - update
  - watch
- apiGroups:
  - postgresql.cnpg.io
  resources:
  - failoverquorums
  verbs:
  - create
  - delete
  - get
  - list
  - watch
- apiGroups:
  - postgresql.cnpg.io
  resources:
  - backups/status
  - databases/status
  - publications/status
... 29 more lines
$ kubectl get clusterrole cnpg-cloudnative-pg -o jsonpath='{range .rules[*]}{.apiGroups} {.resources} {.verbs}{"\n"}{end}' | head -20
[""] ["nodes"] ["get","list","watch"]
["admissionregistration.k8s.io"] ["mutatingwebhookconfigurations","validatingwebhookconfigurations"] ["get","patch"]
["postgresql.cnpg.io"] ["clusterimagecatalogs"] ["get","list","watch"]
[""] ["configmaps","secrets","services"] ["create","delete","get","list","patch","update","watch"]
[""] ["configmaps/status","secrets/status"] ["get","patch","update"]
[""] ["events"] ["create","patch"]
[""] ["persistentvolumeclaims","pods","pods/exec"] ["create","delete","get","list","patch","watch"]
[""] ["pods/status"] ["get"]
[""] ["serviceaccounts"] ["create","get","list","patch","update","watch"]
["apps"] ["deployments"] ["create","delete","get","list","patch","update","watch"]
["batch"] ["jobs"] ["create","delete","get","list","patch","watch"]
["coordination.k8s.io"] ["leases"] ["create","delete","get","list","update","watch"]
["discovery.k8s.io"] ["endpointslices"] ["get","list","watch"]
["monitoring.coreos.com"] ["podmonitors"] ["create","delete","get","list","patch","watch"]
["policy"] ["poddisruptionbudgets"] ["create","delete","get","list","patch","update","watch"]
["postgresql.cnpg.io"] ["backups","clusters","databaseroles","databases","poolers","publications","scheduledbackups","subscriptions"] ["create","delete","get","list","patch","update","watch"]
["postgresql.cnpg.io"] ["failoverquorums"] ["create","delete","get","list","watch"]
["postgresql.cnpg.io"] ["backups/status","databases/status","publications/status","scheduledbackups/status","subscriptions/status"] ["get","patch","update"]
["postgresql.cnpg.io"] ["imagecatalogs"] ["get","list","watch"]
["postgresql.cnpg.io"] ["clusters/finalizers","databaseroles/finalizers","poolers/finalizers"] ["update"]
verify: point directly at the rules granting the CRD, /status, and /finalizers, and explain why an operator needs all three. Then list the core Kubernetes kinds CloudNativePG creates on your behalf.

When an operator loses an RBAC rule, it doesn't crash-loop; it quietly retries and logs errors while the CR stays frozen. That Forbidden log line hands you the exact verb, resource, and ServiceAccount you need to fix it.

kubectl apply -f examples/crossplane/pg-cluster.yaml
sleep 30
# strip the resourceVersion or the restore comes back Conflict and the role stays broken
kubectl get clusterrole cnpg-cloudnative-pg -o json | jq 'del(.metadata.resourceVersion,.metadata.uid,.metadata.creationTimestamp,.metadata.generation,.metadata.managedFields)' > /tmp/cnpg-role.json
kubectl get clusterrole cnpg-cloudnative-pg -o json | jq 'del(.rules[] | select(.resources | index("pods")))' | kubectl apply -f -
kubectl -n team-a delete pod pg-1 --ignore-not-found
sleep 60
kubectl -n cnpg-system logs deploy/cnpg-cloudnative-pg --tail=200 | grep -i forbidden | head -5
kubectl -n team-a get cluster pg -o jsonpath='{.status.phase}{"\n"}'
kubectl replace -f /tmp/cnpg-role.json
sleep 30
kubectl -n team-a get cluster pg -o jsonpath='{.status.phase}{"\n"}'
kubectl get clusterrole cnpg-cloudnative-pg -o json | jq '[.rules[] | select(.resources | index("pods"))] | length'
outputcaptured 2026-11-18
$ kubectl apply -f examples/crossplane/pg-cluster.yaml
cluster.postgresql.cnpg.io/pg created
$ sleep 30
$ # strip the resourceVersion or the restore comes back Conflict and the role stays broken
$ kubectl get clusterrole cnpg-cloudnative-pg -o json | jq 'del(.metadata.resourceVersion,.metadata.uid,.metadata.creationTimestamp,.metadata.generation,.metadata.managedFields)' > /tmp/cnpg-role.json
$ kubectl get clusterrole cnpg-cloudnative-pg -o json | jq 'del(.rules[] | select(.resources | index("pods")))' | kubectl apply -f -
Warning: resource clusterroles/cnpg-cloudnative-pg is missing the kubectl.kubernetes.io/last-applied-configuration annotation which is required by kubectl apply. kubectl apply should only be used on resources created declaratively by either kubectl create --save-config or kubectl apply. The missing annotation will be patched automatically.
clusterrole.rbac.authorization.k8s.io/cnpg-cloudnative-pg configured
$ kubectl -n team-a delete pod pg-1 --ignore-not-found
$ sleep 60
$ kubectl -n cnpg-system logs deploy/cnpg-cloudnative-pg --tail=200 | grep -i forbidden | head -5
{"level":"error","ts":"2026-11-18T07:59:31.184152377Z","logger":"controller-runtime.cache.UnhandledError","msg":"Failed to watch","reflector":"pkg/mod/k8s.io/client-go@v0.37.2/tools/cache/reflector.go:343","type":"*v1.PersistentVolumeClaim","error":"persistentvolumeclaims is forbidden: User \"system:serviceaccount:cnpg-system:cnpg-cloudnative-pg\" cannot watch resource \"persistentvolumeclaims\" in API group \"\" at the cluster scope","stacktrace":"k8s.io/apimachinery/pkg/util/runtime.logError\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/runtime/runtime.go:252\nk8s.io/apimachinery/pkg/util/runtime.handleError\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/runtime/runtime.go:243\nk8s.io/apimachinery/pkg/util/runtime.HandleErrorWithContext\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/runtime/runtime.go:229\nk8s.io/client-go/tools/cache.DefaultWatchErrorHandler\n\tpkg/mod/k8s.io/client-go@v0.37.2/tools/cache/reflector.go:227\nk8s.io/client-go/tools/cache.(*Reflector).RunWithContext.func1\n\tpkg/mod/k8s.io/client-go@v0.37.2/tools/cache/reflector.go:430\nk8s.io/apimachinery/pkg/util/wait.loopConditionUntilContext.func1\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/wait/loop.go:53\nk8s.io/apimachinery/pkg/util/wait.loopConditionUntilContext\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/wait/loop.go:54\nk8s.io/apimachinery/pkg/util/wait.DelayFunc.Until\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/wait/delay.go:39\nk8s.io/client-go/tools/cache.(*Reflector).RunWithContext\n\tpkg/mod/k8s.io/client-go@v0.37.2/tools/cache/reflector.go:428\nk8s.io/apimachinery/pkg/util/wait.(*Group).StartWithContext.func1\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/wait/wait.go:63\nk8s.io/apimachinery/pkg/util/wait.(*Group).Start.func1\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/wait/wait.go:72"}
{"level":"error","ts":"2026-11-18T07:59:32.343343154Z","logger":"controller-runtime.cache.UnhandledError","msg":"Failed to watch","reflector":"pkg/mod/k8s.io/client-go@v0.37.2/tools/cache/reflector.go:343","type":"*v1.PersistentVolumeClaim","error":"failed to list *v1.PersistentVolumeClaim: persistentvolumeclaims is forbidden: User \"system:serviceaccount:cnpg-system:cnpg-cloudnative-pg\" cannot list resource \"persistentvolumeclaims\" in API group \"\" at the cluster scope","stacktrace":"k8s.io/apimachinery/pkg/util/runtime.logError\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/runtime/runtime.go:252\nk8s.io/apimachinery/pkg/util/runtime.handleError\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/runtime/runtime.go:243\nk8s.io/apimachinery/pkg/util/runtime.HandleErrorWithContext\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/runtime/runtime.go:229\nk8s.io/client-go/tools/cache.DefaultWatchErrorHandler\n\tpkg/mod/k8s.io/client-go@v0.37.2/tools/cache/reflector.go:227\nk8s.io/client-go/tools/cache.(*Reflector).RunWithContext.func1\n\tpkg/mod/k8s.io/client-go@v0.37.2/tools/cache/reflector.go:430\nk8s.io/apimachinery/pkg/util/wait.loopConditionUntilContext.func2\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/wait/loop.go:87\nk8s.io/apimachinery/pkg/util/wait.loopConditionUntilContext\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/wait/loop.go:88\nk8s.io/apimachinery/pkg/util/wait.DelayFunc.Until\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/wait/delay.go:39\nk8s.io/client-go/tools/cache.(*Reflector).RunWithContext\n\tpkg/mod/k8s.io/client-go@v0.37.2/tools/cache/reflector.go:428\nk8s.io/apimachinery/pkg/util/wait.(*Group).StartWithContext.func1\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/wait/wait.go:63\nk8s.io/apimachinery/pkg/util/wait.(*Group).Start.func1\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/wait/wait.go:72"}
{"level":"error","ts":"2026-11-18T07:59:34.066813695Z","logger":"controller-runtime.cache.UnhandledError","msg":"Failed to watch","reflector":"pkg/mod/k8s.io/client-go@v0.37.2/tools/cache/reflector.go:343","type":"*v1.PersistentVolumeClaim","error":"failed to list *v1.PersistentVolumeClaim: persistentvolumeclaims is forbidden: User \"system:serviceaccount:cnpg-system:cnpg-cloudnative-pg\" cannot list resource \"persistentvolumeclaims\" in API group \"\" at the cluster scope","stacktrace":"k8s.io/apimachinery/pkg/util/runtime.logError\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/runtime/runtime.go:252\nk8s.io/apimachinery/pkg/util/runtime.handleError\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/runtime/runtime.go:243\nk8s.io/apimachinery/pkg/util/runtime.HandleErrorWithContext\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/runtime/runtime.go:229\nk8s.io/client-go/tools/cache.DefaultWatchErrorHandler\n\tpkg/mod/k8s.io/client-go@v0.37.2/tools/cache/reflector.go:227\nk8s.io/client-go/tools/cache.(*Reflector).RunWithContext.func1\n\tpkg/mod/k8s.io/client-go@v0.37.2/tools/cache/reflector.go:430\nk8s.io/apimachinery/pkg/util/wait.loopConditionUntilContext.func2\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/wait/loop.go:87\nk8s.io/apimachinery/pkg/util/wait.loopConditionUntilContext\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/wait/loop.go:88\nk8s.io/apimachinery/pkg/util/wait.DelayFunc.Until\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/wait/delay.go:39\nk8s.io/client-go/tools/cache.(*Reflector).RunWithContext\n\tpkg/mod/k8s.io/client-go@v0.37.2/tools/cache/reflector.go:428\nk8s.io/apimachinery/pkg/util/wait.(*Group).StartWithContext.func1\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/wait/wait.go:63\nk8s.io/apimachinery/pkg/util/wait.(*Group).Start.func1\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/wait/wait.go:72"}
{"level":"error","ts":"2026-11-18T07:59:38.515278227Z","logger":"controller-runtime.cache.UnhandledError","msg":"Failed to watch","reflector":"pkg/mod/k8s.io/client-go@v0.37.2/tools/cache/reflector.go:343","type":"*v1.PersistentVolumeClaim","error":"failed to list *v1.PersistentVolumeClaim: persistentvolumeclaims is forbidden: User \"system:serviceaccount:cnpg-system:cnpg-cloudnative-pg\" cannot list resource \"persistentvolumeclaims\" in API group \"\" at the cluster scope","stacktrace":"k8s.io/apimachinery/pkg/util/runtime.logError\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/runtime/runtime.go:252\nk8s.io/apimachinery/pkg/util/runtime.handleError\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/runtime/runtime.go:243\nk8s.io/apimachinery/pkg/util/runtime.HandleErrorWithContext\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/runtime/runtime.go:229\nk8s.io/client-go/tools/cache.DefaultWatchErrorHandler\n\tpkg/mod/k8s.io/client-go@v0.37.2/tools/cache/reflector.go:227\nk8s.io/client-go/tools/cache.(*Reflector).RunWithContext.func1\n\tpkg/mod/k8s.io/client-go@v0.37.2/tools/cache/reflector.go:430\nk8s.io/apimachinery/pkg/util/wait.loopConditionUntilContext.func2\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/wait/loop.go:87\nk8s.io/apimachinery/pkg/util/wait.loopConditionUntilContext\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/wait/loop.go:88\nk8s.io/apimachinery/pkg/util/wait.DelayFunc.Until\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/wait/delay.go:39\nk8s.io/client-go/tools/cache.(*Reflector).RunWithContext\n\tpkg/mod/k8s.io/client-go@v0.37.2/tools/cache/reflector.go:428\nk8s.io/apimachinery/pkg/util/wait.(*Group).StartWithContext.func1\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/wait/wait.go:63\nk8s.io/apimachinery/pkg/util/wait.(*Group).Start.func1\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/wait/wait.go:72"}
{"level":"error","ts":"2026-11-18T07:59:45.712001074Z","logger":"controller-runtime.cache.UnhandledError","msg":"Failed to watch","reflector":"pkg/mod/k8s.io/client-go@v0.37.2/tools/cache/reflector.go:343","type":"*v1.PersistentVolumeClaim","error":"failed to list *v1.PersistentVolumeClaim: persistentvolumeclaims is forbidden: User \"system:serviceaccount:cnpg-system:cnpg-cloudnative-pg\" cannot list resource \"persistentvolumeclaims\" in API group \"\" at the cluster scope","stacktrace":"k8s.io/apimachinery/pkg/util/runtime.logError\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/runtime/runtime.go:252\nk8s.io/apimachinery/pkg/util/runtime.handleError\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/runtime/runtime.go:243\nk8s.io/apimachinery/pkg/util/runtime.HandleErrorWithContext\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/runtime/runtime.go:229\nk8s.io/client-go/tools/cache.DefaultWatchErrorHandler\n\tpkg/mod/k8s.io/client-go@v0.37.2/tools/cache/reflector.go:227\nk8s.io/client-go/tools/cache.(*Reflector).RunWithContext.func1\n\tpkg/mod/k8s.io/client-go@v0.37.2/tools/cache/reflector.go:430\nk8s.io/apimachinery/pkg/util/wait.loopConditionUntilContext.func2\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/wait/loop.go:87\nk8s.io/apimachinery/pkg/util/wait.loopConditionUntilContext\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/wait/loop.go:88\nk8s.io/apimachinery/pkg/util/wait.DelayFunc.Until\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/wait/delay.go:39\nk8s.io/client-go/tools/cache.(*Reflector).RunWithContext\n\tpkg/mod/k8s.io/client-go@v0.37.2/tools/cache/reflector.go:428\nk8s.io/apimachinery/pkg/util/wait.(*Group).StartWithContext.func1\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/wait/wait.go:63\nk8s.io/apimachinery/pkg/util/wait.(*Group).Start.func1\n\tpkg/mod/k8s.io/apimachinery@v0.37.2/pkg/util/wait/wait.go:72"}
$ kubectl -n team-a get cluster pg -o jsonpath='{.status.phase}{"\n"}'
Setting up primary
$ kubectl replace -f /tmp/cnpg-role.json
clusterrole.rbac.authorization.k8s.io/cnpg-cloudnative-pg replaced
$ sleep 30
$ kubectl -n team-a get cluster pg -o jsonpath='{.status.phase}{"\n"}'
Setting up primary
$ kubectl get clusterrole cnpg-cloudnative-pg -o json | jq '[.rules[] | select(.resources | index("pods"))] | length'
1
verify: the log names system:serviceaccount:cnpg-system:cnpg-cloudnative-pg along with the denied verb and resource, and the Cluster stalls while that rule is gone, even though nothing is wrong with the Cluster CR itself. (Remember that pg in team-a won't reach healthy without the CiliumNetworkPolicy from earlier, so watch for movement rather than Ready.) Make sure the final command prints 1: if the restore returned Conflict, the operator is still missing its rule and later exercises will run against a broken controller.

Most operators ship admission webhooks for their own CRDs. Scale the operator pod down to zero and writes to those CRs freeze immediately, because the webhook has zero endpoints and failurePolicy: Fail doesn't forgive.

kubectl get validatingwebhookconfiguration | grep -i cnpg
kubectl get validatingwebhookconfiguration cnpg-validating-webhook-configuration -o jsonpath='{range .webhooks[*]}{.name} {.failurePolicy}{"\n"}{end}'
# mutation runs before validation, so the refusal below names the mutating one
kubectl get mutatingwebhookconfiguration | grep -i cnpg
kubectl get mutatingwebhookconfiguration cnpg-mutating-webhook-configuration -o jsonpath='{range .webhooks[*]}{.name} {.failurePolicy}{"\n"}{end}'
kubectl -n cnpg-system scale deploy cnpg-cloudnative-pg --replicas=0
kubectl -n cnpg-system rollout status deploy cnpg-cloudnative-pg --timeout=60s || true
kubectl -n team-a patch cluster pg --type merge -p '{"spec":{"instances":3}}'
kubectl -n cnpg-system scale deploy cnpg-cloudnative-pg --replicas=1
kubectl -n cnpg-system rollout status deploy cnpg-cloudnative-pg --timeout=180s
kubectl -n team-a patch cluster pg --type merge -p '{"spec":{"instances":2}}'
outputcaptured 2026-09-13
$ kubectl get validatingwebhookconfiguration | grep -i cnpg
cnpg-validating-webhook-configuration           5          17h
$ kubectl get validatingwebhookconfiguration cnpg-validating-webhook-configuration -o jsonpath='{range .webhooks[*]}{.name} {.failurePolicy}{"\n"}{end}'
vbackup.cnpg.io Fail
vcluster.cnpg.io Fail
vscheduledbackup.cnpg.io Fail
vdatabase.cnpg.io Fail
vpooler.cnpg.io Fail
$ # mutation runs before validation, so the refusal below names the mutating one
$ kubectl get mutatingwebhookconfiguration | grep -i cnpg
cnpg-mutating-webhook-configuration         4          17h
$ kubectl get mutatingwebhookconfiguration cnpg-mutating-webhook-configuration -o jsonpath='{range .webhooks[*]}{.name} {.failurePolicy}{"\n"}{end}'
mbackup.cnpg.io Fail
mcluster.cnpg.io Fail
mdatabase.cnpg.io Fail
mscheduledbackup.cnpg.io Fail
$ kubectl -n cnpg-system scale deploy cnpg-cloudnative-pg --replicas=0
deployment.apps/cnpg-cloudnative-pg scaled
$ kubectl -n cnpg-system rollout status deploy cnpg-cloudnative-pg --timeout=60s || true
deployment "cnpg-cloudnative-pg" successfully rolled out
$ kubectl -n team-a patch cluster pg --type merge -p '{"spec":{"instances":3}}'
Error from server (InternalError): Internal error occurred: failed calling webhook "mcluster.cnpg.io": failed to call webhook: Post "https://cnpg-webhook-service.cnpg-system.svc:443/mutate-postgresql-cnpg-io-v1-cluster?timeout=10s": dial tcp 10.96.57.128:443: connect: connection refused
$ kubectl -n cnpg-system scale deploy cnpg-cloudnative-pg --replicas=1
deployment.apps/cnpg-cloudnative-pg scaled
$ kubectl -n cnpg-system rollout status deploy cnpg-cloudnative-pg --timeout=180s
Waiting for deployment "cnpg-cloudnative-pg" rollout to finish: 0 out of 1 new replicas have been updated...
Waiting for deployment "cnpg-cloudnative-pg" rollout to finish: 0 out of 1 new replicas have been updated...
Waiting for deployment "cnpg-cloudnative-pg" rollout to finish: 0 out of 1 new replicas have been updated...
Waiting for deployment "cnpg-cloudnative-pg" rollout to finish: 0 of 1 updated replicas are available...
deployment "cnpg-cloudnative-pg" successfully rolled out
$ kubectl -n team-a patch cluster pg --type merge -p '{"spec":{"instances":2}}'
cluster.postgresql.cnpg.io/pg patched (no change)
verify: the patch fails with Internal error occurred: failed calling webhook "mcluster.cnpg.io" ... connection refused while the operator is scaled to zero, and succeeds as soon as it's back. Notice it blames the mutating webhook rather than the validating one because mutation runs first in admission, and both use failurePolicy: Fail, turning a down operator into a total write outage on its own CRDs.

metav1.Condition gives every controller the same field layout and status semantics. Condition types vary by domain, but the structure never changes; comparing live conditions against kubectl explain trains you to read any operator's status in seconds.

kubectl -n team-a get cluster pg -o jsonpath='{.status.conditions[*].type}{"\n"}'
kubectl -n team-a get cluster pg -o jsonpath='{.status.conditions}' | jq '.[] | {type, status, reason, lastTransitionTime}'
kubectl explain cluster.status.conditions
kubectl explain cluster.status.conditions.reason
outputcaptured 2026-09-12
$ kubectl -n team-a get cluster pg -o jsonpath='{.status.conditions[*].type}{"\n"}'
Initialized ConsistentSystemID Ready
$ kubectl -n team-a get cluster pg -o jsonpath='{.status.conditions}' | jq '.[] | {type, status, reason, lastTransitionTime}'
{
  "type": "Initialized",
  "status": "True",
  "reason": "BootstrapCompleted",
  "lastTransitionTime": "2026-09-13T01:54:45Z"
}
{
  "type": "ConsistentSystemID",
  "status": "False",
  "reason": "NotFound",
  "lastTransitionTime": "2026-09-13T01:54:42Z"
}
{
  "type": "Ready",
  "status": "False",
  "reason": "ClusterIsNotReady",
  "lastTransitionTime": "2026-09-13T01:54:43Z"
}
$ kubectl explain cluster.status.conditions
GROUP:      postgresql.cnpg.io
KIND:       Cluster
VERSION:    v1

FIELD: conditions <[]Object>


DESCRIPTION:
    Conditions for cluster object
    Condition contains details for one aspect of the current state of this API
    Resource.
    
FIELDS:
  lastTransitionTime	<string> -required-
    lastTransitionTime is the last time the condition transitioned from one
    status to another.
    This should be when the underlying condition changed.  If that is not known,
    then using the time when the API field changed is acceptable.

  message	<string> -required-
    message is a human readable message indicating details about the transition.
    This may be an empty string.

  observedGeneration	<integer>
    observedGeneration represents the .metadata.generation that the condition
    was set based upon.
    For instance, if .metadata.generation is currently 12, but the
    .status.conditions[x].observedGeneration is 9, the condition is out of date
    with respect to the current state of the instance.

  reason	<string> -required-
    reason contains a programmatic identifier indicating the reason for the
    condition's last transition.
    Producers of specific condition types may define expected values and
    meanings for this field,
    and whether the values are considered a guaranteed API.
    The value should be a CamelCase string.
    This field may not be empty.

  status	<string> -required-
... 5 more lines
$ kubectl explain cluster.status.conditions.reason
GROUP:      postgresql.cnpg.io
KIND:       Cluster
VERSION:    v1

FIELD: reason <string>


DESCRIPTION:
    reason contains a programmatic identifier indicating the reason for the
    condition's last transition.
    Producers of specific condition types may define expected values and
    meanings for this field,
    and whether the values are considered a guaranteed API.
    The value should be a CamelCase string.
    This field may not be empty.
    
verify: every condition on the live Cluster matches the schema in kubectl explain, and you can separate the machine-readable field (reason) from the human one (message). A condition missing its reason is a controller bug, not a valid state.

Self-check

answer before opening
You patch a CR and its status still reports the old problem. What do you check before believing it?

Compare status.observedGeneration against metadata.generation. If they don't match, the controller hasn't reconciled your edit yet and status is still reporting on the previous spec. Once they match and the error persists, you're looking at a real current failure.

A namespace has been Terminating for twenty minutes. Method?

List whatever objects remain (kubectl api-resources --verbs=list --namespaced -o name | xargs -n1 kubectl get -n <ns>), check the finalizer holding them, and verify whether the owning controller is alive. Reviving the controller is the clean fix; stripping the finalizer by hand is a last resort that leaks whatever teardown it was guarding.

Why is deleting an operator-managed pod not a way to "reset" anything?

Because reconciliation is level-based: the controller simply sees a missing pod and spins up a replacement, with zero memory of why you deleted it. To change behavior, fix the spec or underlying cause; otherwise the reconcile loop will faithfully restore the same state forever.

An operator's CRs apply fine and nothing happens at all. Two checks?

First, verify the controller pod is running and actually holds its leader Lease. Second, check its logs for RBAC Forbidden errors covering your namespace or kind, the classic silent failure. Only after clearing both should you check whether the CR is missing a selector, class field, or has a pause annotation.

Name the five ways an operator integrates with the rest of a platform.

Its CRs are delivered through GitOps, its metrics are scraped and alerted on, its connection Secrets are consumed by apps (or bridged via ESO), its CRs are validated by admission policy, and its API is wrapped behind a thinner developer-facing abstraction (Crossplane, kro, or a portal template). That's the full "integration" half of the competency.

An operator Deployment has three replicas and only one does work. How does it decide, and how do you see which?

Leader election via a Lease in the operator's namespace (named by LeaderElectionID, defaulting to a 15 s lease and 10 s renew deadline). Run kubectl -n <ns> get lease <id> -o jsonpath='{.spec.holderIdentity}' to identify the active pod. Standby replicas warm their caches without reconciling, so checking the wrong pod's logs gives you nothing.

What does Owns() in a controller builder do, and what does it explain about operator behavior you see in the cluster?

Owns() watches a child resource kind and, whenever a child changes, enqueues its parent CR using the controller ownerReference. That's why deleting an operator-owned Deployment or Secret triggers an immediate recreate, why ownerReferences map an operator's entire object tree, and why operators require full RBAC on every child kind they create.

Install an operator with OLM v1 pinned to versions below 2.0 from channel stable. Which object, and what does upgradeConstraintPolicy: SelfCertified change?

Create a ClusterExtension naming spec.namespace, spec.serviceAccount.name (an SA you pre-configured with the bundle's RBAC), and spec.source.catalog: { packageName, channels: [stable], version: "<2.0" }. The default CatalogProvided policy only permits upgrades on the catalog's upgrade graph; SelfCertified lets you jump to any version (including downgrades), while CRD upgrade safety checks still run unless disabled.

Why should a condition be named Ready or Degraded rather than Deploying, and what is polarity?

Condition types describe an observed state (adjective or past participle), while ongoing transitions are represented by toggling status (like Reconciling=True rather than Deploying). Polarity tells you whether True is healthy (Ready) or unhealthy (Degraded, Stalled), and because generic tooling can't guess polarity for every custom condition, the convention provides a roll-up Ready summary condition.

Docs to know your way around

study time, not exam time
  • kubernetes.io: Operator pattern; Controllers; Owners and Dependents (cascade deletion); Finalizers.
  • github.com/kubernetes/community: the API conventions doc's conditions section, for what Reason/Message promise.
  • cloudnative-pg.io: the Cluster API reference, mostly to practice navigating a big operator's docs quickly.
  • Offline: kubectl explain cluster.status.conditions, kubectl get <res> -o jsonpath='{.metadata.ownerReferences}', kubectl api-resources --api-group=<g>.
  • book.kubebuilder.io: Watching Resources, Good Practices; pkg.go.dev controller-runtime builder and reconcile: For/Owns/Watches, predicates, Result semantics, leader election options.
  • operator-framework.github.io/operator-controller (ClusterExtension, upgrade support, CRD upgrade safety) and sdk.operatorframework.io Operator Capability Levels: the v1 API fields, the two upgrade policies, and the level definitions with their guiding questions.
  • github.com/kubernetes/community, api-conventions.md "Typical status properties": the metav1.Condition schema, polarity, and naming rules quoted above.