12 Kubernetes CRDs That Make Life Easier
12 Kubernetes CRDs that replace manual work: cert-manager, ServiceMonitor, Argo CD, Flux, KEDA, ExternalSecret, Gateway API, Kyverno, Velero and more.
A Kubernetes CRD (CustomResourceDefinition) adds a new object type to the Kubernetes API, and a controller acts on it. The CRDs that save the most effort replace scripts with declarations: cert-manager's Certificate, Prometheus Operator's ServiceMonitor, Argo CD's Application, KEDA's ScaledObject, External Secrets' ExternalSecret and the Gateway API's HTTPRoute.
This guide explains how CRDs work and then walks through twelve custom resources with short YAML examples. If you are new to the built-in objects, start with our Kubernetes architecture guide, then come back here.
Key takeaways
- A CRD only defines a schema. Nothing happens until a controller (often called an operator) watches the resource and reconciles it.
- Custom resources are managed with the same tools as built-in ones:
kubectl, RBAC, GitOps and admission policies. - Each project's CRDs have their own API group and version; check the version your installed release supports before copying YAML.
- Install CRDs before the resources that use them, and be careful when upgrading or deleting them, because deleting a CRD deletes every object of that type.
- Pick CRDs that remove a manual task you already do. Twelve operators you do not need add upgrade work for nothing.
How CRDs and controllers work
When you apply a CustomResourceDefinition, the API server starts serving a new REST endpoint, for example /apis/cert-manager.io/v1/namespaces/default/certificates. You can then create objects of that kind, and they are stored in etcd like any other object. A controller watches those objects and changes the real world to match: it requests a certificate, writes a Secret, or creates a load balancer rule. This loop of desired state, observed state and correction is the operator pattern described in the Kubernetes documentation.
kubectl get crds
kubectl api-resources --api-group=cert-manager.io
kubectl explain certificate.spec
kubectl explain works for CRDs that publish an OpenAPI schema, which apiextensions.k8s.io/v1 requires. It is the fastest way to check field names for the version you have installed.
The 12 CRDs at a glance
| # | Kind | Project | Replaces |
|---|---|---|---|
| 1 | Certificate, ClusterIssuer | cert-manager | Manual TLS renewal |
| 2 | ServiceMonitor, PrometheusRule | Prometheus Operator | Hand-edited Prometheus config |
| 3 | Application, ApplicationSet | Argo CD | kubectl apply from CI |
| 4 | Kustomization, HelmRelease | Flux | Scripted Helm installs |
| 5 | ScaledObject | KEDA | Custom scaling scripts |
| 6 | ExternalSecret | External Secrets Operator | Copying secrets by hand |
| 7 | Gateway, HTTPRoute | Gateway API (Kubernetes SIG Network) | Annotation-heavy Ingress |
| 8 | ClusterPolicy | Kyverno | Review checklists for manifests |
| 9 | Rollout | Argo Rollouts | Manual canary steps |
| 10 | Backup, Schedule | Velero | Backup cron scripts |
| 11 | VolumeSnapshot | Kubernetes CSI snapshot API | Cloud console snapshots |
| 12 | Composite resources, Managed resources | Crossplane | Separate cloud provisioning scripts |
Security and certificates
1. cert-manager: Certificate and ClusterIssuer
cert-manager requests TLS certificates from issuers such as Let's Encrypt (ACME), HashiCorp Vault or a private CA, stores them in Secrets and renews them before they expire.
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: shop-tls
namespace: shop
spec:
secretName: shop-tls
dnsNames:
- shop.example.com
issuerRef:
name: letsencrypt-prod
kind: ClusterIssuer
An Issuer works in one namespace; a ClusterIssuer works across the cluster. Many teams skip the Certificate object and add a cert-manager annotation to an Ingress, which creates it automatically.
6. External Secrets Operator: ExternalSecret
External Secrets Operator syncs values from AWS Secrets Manager, Azure Key Vault, Google Secret Manager, Vault and others into Kubernetes Secrets. A SecretStore or ClusterSecretStore holds the connection details; an ExternalSecret says which keys to fetch.
apiVersion: external-secrets.io/v1
kind: ExternalSecret
metadata:
name: db-credentials
spec:
refreshInterval: 1h
secretStoreRef:
name: aws-secrets
kind: ClusterSecretStore
target:
name: db-credentials
data:
- secretKey: password
remoteRef:
key: prod/db
property: password
Older releases use external-secrets.io/v1beta1; check which version your installed chart serves. Other approaches are compared in 10 tools to manage Kubernetes secrets safely.
8. Kyverno: ClusterPolicy
Kyverno is a policy engine whose policies are Kubernetes resources written in YAML. Policies can validate, mutate or generate resources at admission time.
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: require-team-label
spec:
validationFailureAction: Enforce
rules:
- name: check-team
match:
any:
- resources:
kinds:
- Deployment
validate:
message: "Deployments must have a team label."
pattern:
metadata:
labels:
team: "?*"
Recent Kyverno releases also introduce newer policy types based on CEL; the ClusterPolicy kind above remains widely used. Check the docs for your version.
Observability
2. Prometheus Operator: ServiceMonitor and PrometheusRule
Instead of editing a central prometheus.yml, each team adds a ServiceMonitor next to its application. The operator turns it into scrape configuration.
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: shop-api
labels:
release: kube-prometheus-stack
spec:
selector:
matchLabels:
app: shop-api
endpoints:
- port: http-metrics
interval: 30s
The release label must match the Prometheus object's serviceMonitorSelector; a mismatch is the most common reason a ServiceMonitor is ignored. PrometheusRule holds alerting and recording rules the same way. See 10 monitoring alerts every DevOps team should configure for rules worth adding.
Delivery and GitOps
3. Argo CD: Application and ApplicationSet
An Application points Argo CD at a Git path and a destination cluster and namespace. Argo CD keeps the cluster in sync with Git.
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: shop
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/example/shop-deploy.git
targetRevision: main
path: overlays/prod
destination:
server: https://kubernetes.default.svc
namespace: shop
syncPolicy:
automated:
prune: true
selfHeal: true
ApplicationSet generates many Applications from a template, for example one per cluster or one per directory.
4. Flux: Kustomization and HelmRelease
Flux splits the job into sources (GitRepository, OCIRepository, HelmRepository) and reconcilers (Kustomization, HelmRelease). A HelmRelease declares a chart, version and values, and Flux installs and upgrades it. Argo CD and Flux overlap; most teams pick one. Our Helm chart examples pair well with either.
9. Argo Rollouts: Rollout
A Rollout replaces a Deployment and adds canary and blue-green steps, with optional analysis against metrics.
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: shop-api
spec:
replicas: 5
selector:
matchLabels:
app: shop-api
template:
metadata:
labels:
app: shop-api
spec:
containers:
- name: api
image: example/shop-api:1.4.2
strategy:
canary:
steps:
- setWeight: 20
- pause: {duration: 10m}
- setWeight: 50
- pause: {duration: 10m}
The strategies themselves are explained in 14 Kubernetes deployment strategies.
Scaling and traffic
5. KEDA: ScaledObject
KEDA scales workloads on event sources such as queue length, Kafka lag, Prometheus queries or cron schedules, and can scale to zero. It creates and manages a HorizontalPodAutoscaler for you.
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: worker
spec:
scaleTargetRef:
name: worker
minReplicaCount: 0
maxReplicaCount: 20
triggers:
- type: prometheus
metadata:
serverAddress: http://prometheus.monitoring:9090
query: sum(rate(jobs_enqueued_total[2m]))
threshold: "50"
7. Gateway API: Gateway and HTTPRoute
The Gateway API is the Kubernetes project's successor to Ingress for traffic routing. It ships as CRDs maintained by SIG Network, with core resources (GatewayClass, Gateway, HTTPRoute) at gateway.networking.k8s.io/v1. It separates the infrastructure owner (Gateway) from application owners (routes) and supports header matching and traffic splitting without vendor annotations.
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: shop
spec:
parentRefs:
- name: public-gateway
hostnames:
- shop.example.com
rules:
- backendRefs:
- name: shop-v1
port: 80
weight: 90
- name: shop-v2
port: 80
weight: 10
Implementations are compared in top 12 Kubernetes gateways.
Data and infrastructure
10. Velero: Backup and Schedule
Velero backs up Kubernetes objects and persistent volume data to object storage. A Schedule creates Backup objects on a cron expression.
apiVersion: velero.io/v1
kind: Schedule
metadata:
name: nightly
namespace: velero
spec:
schedule: "0 2 * * *"
template:
includedNamespaces:
- shop
ttl: 720h0m0s
More options are in 12 Kubernetes backup tools.
11. CSI snapshots: VolumeSnapshot
The volume snapshot API (snapshot.storage.k8s.io/v1, generally available since Kubernetes 1.20) is installed as CRDs plus a snapshot controller. A VolumeSnapshot captures a PersistentVolumeClaim through the CSI driver, and a new PVC can be restored from it.
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata:
name: db-snap
spec:
volumeSnapshotClassName: csi-snapclass
source:
persistentVolumeClaimName: db-data
12. Crossplane: composite and managed resources
Crossplane, a CNCF project, lets you manage cloud resources (databases, buckets, networks) as Kubernetes objects through providers. Platform teams define their own APIs with CompositeResourceDefinitions (XRDs) and Compositions, so a developer can request a "database" without knowing the cloud-specific details. It is the most powerful entry on this list and the one with the steepest learning curve.
Operating CRDs safely
- Install order: CRDs must exist before custom resources are applied. In Argo CD, sync waves or separate Applications handle this; in Helm, charts often keep CRDs in a
crds/directory that Helm installs but does not upgrade. - Upgrades: read release notes for API version changes. Helm's handling of
crds/means many projects ask you to apply new CRDs manually before upgrading the chart. - Deletion: deleting a CRD deletes all of its objects. Protect production CRDs from accidental removal.
- RBAC: custom resources need explicit RBAC rules; the built-in
editandviewroles include them only when the project adds aggregation labels. - Control plane load: every CRD adds watches and storage. Install what you use.
For other cluster add-ons worth running, see 12 Kubernetes add-ons that improve cluster stability.
Anatomy of a CustomResourceDefinition
You rarely write CRDs for third-party tools, but reading one helps when debugging. Here is a minimal CRD for a made-up Backup type:
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: backups.example.com
spec:
group: example.com
scope: Namespaced
names:
plural: backups
singular: backup
kind: Backup
shortNames: ["bk"]
versions:
- name: v1
served: true
storage: true
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
required: ["schedule"]
properties:
schedule:
type: string
retentionDays:
type: integer
minimum: 1
subresources:
status: {}
The name must be plural.group. Exactly one version has storage: true, which is the version stored in etcd. The schema validates objects at the API server, so a missing schedule is rejected before any controller sees it. Kubernetes also supports CEL validation rules inside the schema (x-kubernetes-validations) for checks that span fields. The status subresource lets the controller update status separately from spec.
Built-in API or CRD?
| Use | When |
|---|---|
| Built-in object (Deployment, ConfigMap, Job) | The built-in behavior already does what you need |
| ConfigMap read by your app | You need configuration, not new API behavior |
| Existing project's CRD | A maintained operator already solves the problem (most cases on this list) |
| Your own CRD and controller | You have a repeated operational task specific to your platform and the team can maintain Go code |
| Aggregated API server | Rare: you need custom storage or behavior CRDs cannot provide |
Debugging custom resources
- Check the resource exists and read its status:
kubectl get certificate -n shop, thenkubectl describe. Most operators write conditions such asReadywith a reason and message. - Read events for the object; many controllers emit them.
- Check the controller's logs, for example
kubectl logs -n cert-manager deploy/cert-manager. A custom resource with no status at all usually means the controller is not running or is watching other namespaces. - Follow owned objects. cert-manager creates CertificateRequest and Order objects; Argo CD shows the resource tree. Problems often sit one level down.
- If an object will not delete, look for finalizers in
metadata.finalizers. Fix the controller rather than removing finalizers by hand, because finalizers exist to clean up external resources.
Where to start
If you are building a platform from scratch, a reasonable order is cert-manager (TLS is needed early), Prometheus Operator (you need to see what is happening), External Secrets Operator (stop putting secrets in Git), then Argo CD or Flux for delivery. Add KEDA, Rollouts, Velero, Gateway API and Crossplane when a real need appears. Each operator is another component to upgrade and monitor.
Learn Kubernetes hands-on
CRDs and operators appear across our CKA training and CKAD training, both available in Kharadi, Pune and live online.
Frequently asked questions
What is a CRD in Kubernetes?
A CustomResourceDefinition registers a new resource type with the Kubernetes API server, including its name, API group, versions and schema. After that you can create, list and delete objects of that type with kubectl.
What is the difference between a CRD and an operator?
The CRD defines the data. The operator is the controller that watches those objects and takes action to make the cluster match them. Most useful CRDs ship with an operator.
Can I write my own CRD?
Yes. You can write the CustomResourceDefinition YAML directly, and frameworks such as Kubebuilder and Operator SDK generate CRDs and controller code in Go.
Is the Gateway API a CRD?
Yes. It is an official Kubernetes project, but its resources are installed as CRDs rather than built into the API server. Many managed Kubernetes services can install them for you.
What happens if I delete a CRD?
The API server deletes every custom resource of that type in all namespaces. Back up the objects first and check that no controller still depends on them.
How do I list all CRDs in a cluster?
Run kubectl get crds. Use kubectl api-resources to see the kinds and short names they add.
Do CRDs work with Helm and GitOps?
Yes. Custom resources are YAML like any other object. Make sure the CRD is applied before resources that use it, and plan CRD upgrades separately from chart upgrades.
References
- Kubernetes: custom resources
- Kubernetes: operator pattern
- cert-manager Certificate resource
- Prometheus Operator design
- Argo CD declarative setup
- Flux components
- KEDA ScaledObject specification
- External Secrets Operator
- Gateway API
- Kyverno documentation
- Argo Rollouts
- Velero documentation
- Kubernetes volume snapshots
- Crossplane documentation
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Angry
0
Sad
0
Wow
0