CKAD — Custom Resources
Creating Custom Resources
Once the CRD is created, you can create instances (Custom Resources):
apiVersion: stable.example.com/v1
kind: Backup
metadata:
name: daily-db-backup
namespace: default
spec:
database: postgres-main
schedule: "0 2 * * *"
retentionDays: 30
kubectl apply -f backup-instance.yaml
# Expected: backup.stable.example.com/daily-db-backup created
# List custom resources
kubectl get backups
# Expected:
# NAME AGE
# daily-db-backup 5s
# Use the short name
kubectl get bk
# Describe a custom resource
kubectl describe backup daily-db-backup
# Get as YAML
kubectl get backup daily-db-backup -o yaml
Managing CRDs
# List all CRDs
kubectl get crd
# Get details
kubectl describe crd backups.stable.example.com
# Delete a CRD (this also deletes ALL custom resources of that type)
kubectl delete crd backups.stable.example.com
Warning: Deleting a CRD deletes all custom resources of that type. This is a destructive operation.
Next: Operator Pattern →