Skip to content
StackDecode
AdvancedLesson 26 of 35

CRDs and Operators

Teach Kubernetes new object types.

A CustomResourceDefinition adds a new kind to the API. An operator is a controller that watches those objects and automates operations (create a database cluster, take backups, fail over).

yaml
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata: { name: app-db }
spec:
  instances: 3
  storage: { size: 10Gi }

You declare Cluster; the operator creates the StatefulSet, Services, certificates and handles failover. Frameworks to write your own: Kubebuilder, Operator SDK (Go), kopf (Python).