
Why extend Kubernetes?
Kubernetes is commonly used for stateless workloads (Pods, Deployments, Services). Modern platform requirements (databases, ML pipelines, message buses, batch systems) demand richer lifecycle management: backups, failover, leader election, schema migrations, observability, and operational policies. Platform teams want to capture this operational knowledge once and expose simple APIs to developers so teams can consume managed services without needing deep SRE expertise.

Operator pattern — concept and value
At the core of extensibility are Custom Resource Definitions (CRDs) and controllers:- CRDs: extend the Kubernetes API with new resource types and schemas.
- Controllers: continuously reconcile actual state toward the desired state specified by CRs.


Advantages (at a glance)
CRDs: defining the API/schema
A CRD defines a new resource type and its schema. For example, an operator could define resources under a custom group likedatabase.spr.com with Kind PostgreSQLCluster. Namespaced CRDs scope each instance to a namespace.

Note: In
apiextensions.k8s.io/v1 a valid CRD requires a versions array and OpenAPI v3 schema (if you want server-side validation). The example below shows a minimal, valid CRD skeleton compatible with apiextensions.k8s.io/v1.Developer experience: a single declarative manifest
With a CRD and controller in place, a developer requests managed services using a compact, readable Custom Resource. The Operator reconciles the CR into StatefulSets, Services, PVCs, backups, monitoring, and any external actions. Example developer-facing manifest:
How controllers work — the reconciliation loop
Controllers implement the continuous reconciliation loop:- Watch: watch CR instances and related Kubernetes resources.
- Analyze: compare observed state with the desired state.
- Reconcile: perform create/update/delete actions to converge state.
- Repeat: continue in an event-driven loop (reacts to events and periodic resync).
PostgreSQLCluster controller this could include:
- Creating StatefulSets for DB pods
- Creating Services (primary and replica access)
- Creating ConfigMaps and Secrets
- Provisioning PVCs and storage
- Configuring replication, leader election, and connection endpoints
- Scheduling backup jobs per spec
- Registering ServiceMonitor or other monitoring resources


Operator frameworks — summary
Most teams choose Kubebuilder or Operator SDK for complex operators depending on language preference and ecosystem familiarity.

Scaffolding with Operator SDK
Operator SDK scaffolds a project, the API objects, controller code, CRD manifests, and testing/deployment helpers — accelerating development and enforcing common patterns. Example Operator SDK workflow:
Case study — Prometheus Operator
The Prometheus Operator is a practical example of how Operators provide platform value:- ServiceMonitor CRs discover and configure scrape targets automatically.
- PrometheusRule CRs manage recording and alerting rules as code.
- Alertmanager CRs enable programmable alert routing and notification channels.
- The operator manages Prometheus instances, storage, config, and upgrades.


Key takeaways
- Operators = CRDs (API/schema) + controllers (behavior/reconciliation).
- Operators let you convert human SRE runbooks into repeatable, automated software.
- Use the CNCF ecosystem to adopt ready-made operators or frameworks to build custom ones.
- Operators transform Kubernetes into an SRE-enabled platform for domain-specific applications.
- For the CNPA exam: understand how operators encapsulate operational knowledge, enable self-service, and provide a consistent platform API.
Exam tip: Remember the operator pattern as “CRDs define the API/schema; controllers implement the reconciliation logic.” Operators are how you encode SRE runbooks and operational behavior as software.