---
# System prepended metadata

title: Best Practices when Writing Operators

---

# Best Practices when Writing Operators

1. Before changing an API, review the Kubernetes API Versioning Guide
2. Reconcilers should only change non-status, non-finalizer fields on objects they manage/own, not their primary objects.
3. Reconcilers should update the object they're reconciling a single time before the function finishes.
5. Avoid state machines, and don't program Controller behavior based on the status of the object being reconciled. Operators should compare the actual state of the cluster against the desired state defined in the spec.
6. Avoid finalizers whenever possible.
7. Use metav1.Conditions and the helper library when conveying state.
8. Perform validation at admission time, before the reconcile function.
9. Avoid Admission, Mutating, and Conversion Webhooks, use cel (k8s 1.25+)
