Загрузка...

Kubernetes Operators: Handle multiple controllers, conflicts and retries like a pro

When multiple Kubernetes controllers update the same custom resource, you WILL hit conflict errors. Your operator caches an old resource version, another controller updates the object, and your update fails — "the object has been modified, please apply your changes to the latest version."

In this video, Shubham walks you through a real-world scenario of building a custom autoscaler with two operators (NodePool + Autoscaler) sharing the same CRD, and shows exactly why and how resource version conflicts happen.

Shubham Katara - https://www.linkedin.com/in/shubhamkatara/

You'll learn:
✅ Resource Version vs Generation — what changes when
✅ Why multiple controllers sharing CRDs causes conflicts
✅ The Lazy Way — return error, let Kubernetes re-run the reconciler (wasteful!)
✅ The Pro Way — retry.RetryOnConflict() with exponential backoff & jitter
✅ Kubernetes apierrors package: IsConflict, IsNotFound
✅ Configuring backoff: Steps, Duration, Factor, and Jitter
✅ When you need retry vs when you don't
This is Part 2 of the Kubernetes Operators Best Practices series on KubeSimplify.
---
Timestamps:
0:00 - Introduction
0:50 - Concept before problem statement
1:07 - Resource Version vs Generation explained (demo)
4:11 - Problem: Building a custom autoscaler operator
5:18 - Designing the NodePool custom resource
8:49 - Adding a second controller for autoscaling
11:16 - One operator, multiple controllers & CRDs
15:30 - Operators interacting with each other's CRs
17:31 - Timeline: when two operators touch the same CR
23:44 - The conflict problem explained
27:24 - What is a conflict error in Kubernetes
29:51 - Two fixes: Lazy Way vs Pro Way
30:38 - Code walkthrough: reconciler setup
38:19 - The Lazy Way: return error, re-run reconciler
42:06 - Dev setup: vCluster vind (vCluster in Docker)
44:47 - Demo: Lazy way conflict
49:41 - The Pro Way: apierrors package
55:21 - client-go retry package
57:48 - retry.RetryOnConflict() with DefaultBackoff
58:08 - Backoff: Steps, Duration, Factor & Jitter
1:05:02 - Error patterns: IsConflict, IsNotFound, catch-all
1:08:58 - Demo: Pro way retry in action
1:10:52 - Summary & when to use retry
1:12:13 - Outro

Related Videos:
- Kubernetes Operator Best Practice: Stop Infinite Reconcile Loops - https://youtu.be/bD-hLJK-bkM?si=1H7hgfm9-6hjJSFU
- Master Kubernetes operators with kubebuilder - https://youtu.be/X5kkrIPr5Hk?si=PhiarR6u7SKBR0sI

🔗 Resources:
- client-go retry package: k8s.io/client-go/util/retry
- apimachinery errors: k8s.io/apimachinery/pkg/api/errors
- vCluster vind: https://github.com/loft-sh/vind

►►►Connect with me ►►►
► Kubesimplify: https://kubesimplify.com/newsletter
► Newsletter: https://saiyampathak.com/newsletter
► Discord: https://saiyampathak.com/discord
► Twitch: https://saiyampathak.com/twitch
► YouTube: https://saiyampathak.com/youtube.com
► GitHub: https://github.com/saiyam1814
► LinkedIn: https://www.linkedin.com/in/saiyampathak/
► Website: https://saiyampathak.medium.com/
► Instagram: http://instagram.com/saiyampathak/
► https://twitter.com/saiyampathak

Видео Kubernetes Operators: Handle multiple controllers, conflicts and retries like a pro канала Kubesimplify
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять