Best Practices on writing a Kubernetes Operator: my lessons from Capsule
summary
Capsule implements a Tenant CRD that groups namespaces to enforce network policies, limit ranges and quotas; code uses Operator SDK atop controller-runtime and relies on creator-update mutate closure to avoid overwriting metadata, retry-on-conflict for concurrent updates, and a custom field indexer to get near O(1) tenant lookups. Finalizers handle async deletion of external resources. A production outage from a wrong ownerReference underlines the danger of careless ownership links. The operator and utilities work in production but require careful use of cache, predicates and runners.
AI-written summary · about
chapters (34)
- 0:00Introduction
- 3:58Welcome
- 4:49About me
- 6:36Warning
- 7:07Capsule
- 7:46Preface
- 8:13What is Kubernetes
- 9:01Why I like Kubernetes
- 10:44Namespaces
- 11:42Kubernetes
- 14:49Operator Pattern
- 16:43Sample Code
- 19:57Capsule overview
- 21:20How a tenant is defined
- 23:28Code
- 25:17Recap
- 26:19Donts
- 28:03Finalizers
- 30:22Dos Donts
- 32:02Real Code Snippet
- 33:01General Reminders
- 34:57Example
- 36:19ControllerTime Client
- 37:11Demo
- 38:40Failed Indexer
- 41:43Summary
- 43:10Run Enable
- 43:41User Customization
- 44:33Runnable
- 45:12predicates
- 45:56Kubernetes Developer Experience
- 47:16Predicate
- 48:02Conclusion
- 49:29QA with Dario
