# Operators and Custom Resources

> Extend Kubernetes with Custom Resource Definitions and controllers that automate running complex software. Free notes, key concepts, resources and a mini...

Canonical: https://www.internhack.in/roadmaps/tracks/devops/k8s-operators
Last updated: 2026-11-28

Extend Kubernetes with Custom Resource Definitions and controllers that automate running complex software.

Advanced · about 8 hours · difficulty 4/5

Learn first: [Packaging with Helm and Kustomize](https://www.internhack.in/roadmaps/tracks/devops/helm)

Kubernetes is extensible: you can add your own object types (**Custom Resource Definitions**) and write controllers that reconcile them. An **operator** is a controller that encodes operational knowledge, such as how to provision, back up, upgrade and fail over a database.

### What to understand

- CRDs define a new `kind` with a schema; custom resources are instances of it.
- A controller watches resources and runs a **reconcile loop**: compare desired and actual state, take one step, requeue.
- Many tools you use are operators: cert-manager, Prometheus Operator, CloudNativePG, Strimzi (Kafka), Argo CD.
- Building your own: **Kubebuilder** or **Operator SDK** (Go), or lighter frameworks like kopf (Python).
- Status conditions, finalizers (cleanup before deletion) and owner references (garbage collection).

### When to write one

Only when you have repeated, stateful operational logic that plain manifests and Helm cannot express. Most teams consume operators far more than they write them.

### Pitfalls

Installing operators with cluster-wide permissions without review, and CRD upgrades that break existing resources.

**Good enough to move on:** you can install and operate a third-party operator, read its CRDs, and explain how its reconcile loop behaves when you edit a custom resource.

## Key concepts

- **Custom Resource Definitions**
- **Controllers and reconcile loops**
- **Finalizers and owner references**
- **Using existing operators**
- **Kubebuilder / Operator SDK**
- **kopf for Python**

## Mini project

Install the CloudNativePG operator, create a 3-instance Postgres cluster from a single custom resource, then delete the primary pod and watch the operator promote a replica.

## Check yourself

What problem does a finalizer solve when a custom resource is deleted?

## Free resources

- [Operator pattern](https://kubernetes.io/docs/concepts/extend-kubernetes/operator/) (kubernetes.io)
- [The Kubebuilder Book](https://book.kubebuilder.io/) (Kubernetes SIGs)

Previous: [Packaging with Helm and Kustomize](https://www.internhack.in/roadmaps/tracks/devops/helm) · Next: [Service Mesh](https://www.internhack.in/roadmaps/tracks/devops/service-mesh)

## More in Orchestrating Containers with Kubernetes

- [Kubernetes Architecture and kubectl](https://www.internhack.in/roadmaps/tracks/devops/kubernetes-architecture)
- [Workloads, Probes and Autoscaling](https://www.internhack.in/roadmaps/tracks/devops/k8s-workloads)
- [Services, Ingress and Network Policy](https://www.internhack.in/roadmaps/tracks/devops/k8s-networking)
- [Configuration, Secrets, Storage and RBAC](https://www.internhack.in/roadmaps/tracks/devops/k8s-config-storage)
- [Packaging with Helm and Kustomize](https://www.internhack.in/roadmaps/tracks/devops/helm)
- [Operators and Custom Resources](https://www.internhack.in/roadmaps/tracks/devops/k8s-operators)
- [Service Mesh](https://www.internhack.in/roadmaps/tracks/devops/service-mesh)
- [Beyond Kubernetes: Nomad and ECS](https://www.internhack.in/roadmaps/tracks/devops/nomad-ecs)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [DevOps Engineer Roadmap](https://www.internhack.in/roadmaps/tracks/devops)
