Video Thumbnail for Lesson
8.1: Custom Resources (Extending K8s)

Extending the Kubernetes API

Kubernetes revolves around the ideas of Declarative State and Continuous Reconciliation. While core resources such as Pods and Deployments cover common use cases, you can define your own resource types to automate almost anything.

CustomResourceDefinitions

A CustomResourceDefinition (CRD) registers a new kind with the API server. Once applied, objects created from that CRD are stored in etcd alongside the built‑in resources.

# list CRDs installed in the cluster
kubectl get crd | head

Many projects ship multiple CRDs. After installing the Traefik ingress controller you will find resources such as IngressRoute and Middleware:

kubectl api-resources | grep traefik.containo.us/v

These extra objects allow Traefik to express advanced routing features that go beyond the standard ingress spec.

Operators

Custom resources become powerful when paired with controllers—often called operators—that act on them. Operators observe the Kubernetes API and reconcile desired state whenever resources change. Common examples include:

  • CloudNativePG – manages PostgreSQL clusters and backups
  • cert-manager – provisions TLS certificates using Certificate and Challenge resources
  • Crossplane – maps Kubernetes resources to external infrastructure like AWS or GCP services

Frameworks such as Kubebuilder, Operator SDK and MetaController help scaffold these controllers.

Example CRD

Below is a trimmed down example of Traefik's IngressRoute to illustrate the structure of a CRD-managed resource:

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: example-route
spec:
  entryPoints:
    - web
  routes:
    - match: Host(`example.com`)
      kind: Rule
      services:
        - name: my-service
          port: 80

You can explore the full manifests and hands‑on exercises in the course repository.