We use analytics cookies.We use cookies to analyze site traffic and improve your experience.
Loading...
System Design Masterclass · Kubernetes Containers
Free preview: the first 2 parts of this 6-part lesson.
Already bought the course? Sign in to read the whole lesson.
this lesson is part of
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design courseread the rest of this lesson in
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design coursein Kubernetes Containers
This lesson is part of the full System Design Masterclass. Unlock it along with 769 other lessons for a one-time payment.
One-time payment by card or PayPal
Get Lifetime AccessOne-time payment: UPI, card or netbanking
Get Lifetime Access18 Foundation lessons are free, no payment needed. Try them now
It is easy and good
“It is really nice and good Please join the course”
Kubernetes ships with built-in resources: Pods, Deployments, Services, ConfigMaps. These cover general-purpose workloads. But what about a PostgreSQL cluster? A Kafka topic? A TLS certificate? An ML training job? These are domain-specific concepts that don't map cleanly to generic Kubernetes resources.
Custom Resource Definitions let you teach new concepts. After registering a CRD for "PostgresCluster," you can create, list, update, and delete PostgresCluster objects using kubectl, just like Pods or Deployments. The Kubernetes API server stores them in etcd, validates them against your schema, and exposes them through the standard API.
CRDs are what make Kubernetes infinitely extensible. They're why Kubernetes can be a platform for running databases, service meshes, pipelines, ML workflows, and anything else, not just containers. Every Operator starts with a CRD.
Registering a CRD:
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: postgresclusters.db.example.com
spec:
group: db.example.com
names:
kind: PostgresCluster
plural: postgresclusters
shortNames: ["pgc"]
scope: Namespaced
versions:
- name: v1
served: true
storage: true
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
instances:
type: integer
version:
type: string
After registration, you can use it like any resource:
kubectl get postgresclusters
kubectl describe pgc my-database
kubectl apply -f my-database.yaml
kubectl delete pgc my-database
| Built-in Resource | CRD Equivalent |
|---|---|
| Deployment | PostgresCluster, KafkaCluster |
| ConfigMap | PrometheusRule, AlertmanagerConfig |
| Service | VirtualService (Istio), IngressRoute (Traefik) |
| Job | SparkApplication, TFJob (ML training) |
CRDs vs ConfigMaps for configuration: You could store database config in a ConfigMap, but CRDs give you validation (reject invalid configs at the API level), versioning (v1, v2 with conversion), status subresource (report database health back), and RBAC (control who can create databases vs who can create ConfigMaps).