From e3b5c67b2e95c1410bf19113cc0d8584e06c1727 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20M=C3=A9sz=C3=A1ros?= Date: Tue, 16 Sep 2025 20:20:14 +0200 Subject: [PATCH] docs: best practices for state management MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Attila Mészáros --- .../docs/getting-started/patterns-best-practices.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/content/en/docs/getting-started/patterns-best-practices.md b/docs/content/en/docs/getting-started/patterns-best-practices.md index 7451124df8..ba00e81d20 100644 --- a/docs/content/en/docs/getting-started/patterns-best-practices.md +++ b/docs/content/en/docs/getting-started/patterns-best-practices.md @@ -77,13 +77,15 @@ Thanks to Kubernetes resources' declarative nature, operators dealing only with ### When State Management Becomes Necessary -This stateless approach typically breaks down when dealing with external resources. You might need to track external state for future reconciliations. +This stateless approach typically breaks down when dealing with external resources. You might need to track external state or allocated +values for future reconciliations. There are multiple options: -**Anti-pattern**: Putting state in the primary resource's status sub-resource -- Becomes difficult to manage with large amounts of state -- Violates best practice: status should represent actual resource state, while spec represents desired state -**Recommended approach**: Store state in separate resources designed for this purpose: +1. Putting state in the primary resource's status sub-resource. This is a bit more complex that might seem at the first look. + Refer to the [documentation](../documentation/reconciler.md#making-sure-the-primary-resource-is-up-to-date-for-the-next-reconciliation) + for further details. + +2. Store state in separate resources designed for this purpose: - Kubernetes Secret or ConfigMap - Dedicated Custom Resource with validated structure