Skip to content

Portal | Level: L3: Advanced | Topics: K8s Ecosystem | Domain: Kubernetes

Kubernetes Operators & CRDs - Skill Check

Mental model (bottom-up)

A CRD extends the K8s API with custom types. An operator watches those types and reconciles actual state to desired state, encoding operational knowledge into software.

Visual stack

[Custom Resource  ]  "I want a 3-replica Postgres cluster"
|
[Operator         ]  controller watching CRs, running reconciliation loop
|
[Child Resources  ]  StatefulSet, Service, ConfigMap (auto-managed)
|
[Owner References ]  garbage collection on CR deletion

Glossary

  • CRD - Custom Resource Definition; extends K8s API with new types
  • CR - Custom Resource; instance of a CRD
  • reconciliation loop - observe -> compare -> act -> update status -> repeat
  • owner reference - links child resources to parent for garbage collection
  • finalizer - prevents deletion until cleanup logic runs
  • Kubebuilder - Go framework for building operators
  • Kopf - Python framework for quick operator prototyping

Core questions (easy -> hard)

  • What is a CRD?
  • Extends K8s API with custom resource types. kubectl get <your-type> works.
  • What is the operator pattern?
  • Controller that watches CRs and reconciles actual state to desired state.
  • What are owner references?
  • Link child resources to parent. GC deletes children when parent is deleted.
  • What is a finalizer?
  • Prevents deletion until operator runs cleanup (e.g., take final backup).
  • Why must reconciliation be idempotent?
  • Controller may be called multiple times for same state. Must produce same result.
  • How do you handle CRD schema changes?
  • Add optional fields (backward compat). For breaking changes: new API version + conversion webhook.

Wiki Navigation

Prerequisites