EAI-7854 Skip the keycloak CNPG PDB for a single instance - #798
Open
pre wants to merge 2 commits into
Open
Conversation
A CloudNativePG Cluster with instances: 1 gets a <name>-primary PodDisruptionBudget at minAvailable: 1, which permits zero disruptions for as long as the cluster is single-instance. That PDB protects nothing, since there is no second replica to keep serving, and it blocks kubectl drain on whichever node the pod sits on. Node maintenance then stalls until an operator disables it by hand on the live cluster, out of band from Git. enablePDB now defaults to false while instances is 1 and true from two instances up, and an explicit cnpg.enablePDB wins either way.
keycloak-config renders the same keycloak-cnpg Cluster as keycloak-old, so it carries the same drain blocker. A single-instance PDB permits zero disruptions, which protects nothing and only stalls `kubectl drain` on whichever node the primary sits on. Introduce the cnpg values block this chart lacked and derive enablePDB from instances, with an explicit value winning. Matches the pattern already applied to keycloak-old in this branch.
Contributor
|
We could have affinity rules like following: |
Contributor
Author
yeah, although it should be a separate pull request. |
silokimmo
approved these changes
Aug 5, 2026
silokimmo
left a comment
Contributor
There was a problem hiding this comment.
LGTM - let's improve also affinity rules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A CloudNativePG
Clusterwithinstances: 1gets a<name>-primaryPodDisruptionBudget atminAvailable: 1, which permits zero disruptions for as long as the cluster stays single-instance.That PDB protects nothing. There is no second replica to keep serving, so the only thing it can do is refuse. What it refuses is
kubectl drainon whichever node the pod happens to sit on, which stalls node maintenance until an operator disables it by hand on the live cluster, out of band from Git.This came out of a maintenance window on
app-install-test, wherekeycloak/keycloak-cnpg-1was one of two drain blockers on the node being rebooted. The other was Longhorn's per-node instance-manager PDB, which turned out to be held open by the database pod: Longhorn refuses to release it while volumes are still attached to the node. Clearing the CNPG PDB let the drain evict the database pod, the volumes detached, and Longhorn released its own PDB on the next reconcile.Change
enablePDBis now rendered on the Cluster, followinginstancesunless set:cnpg.instancescnpg.enablePDBfalsetruetruetruefalsefalseThe default is derived rather than hardcoded, so a cluster scaled to two instances gets its PDB back without a second values change, and the field stays overridable in both directions.
Applied to both charts that render a
keycloak-cnpgCluster:sources/keycloak-oldis the one wired up viaroot/values.yaml(path: keycloak-old). It already had acnpgvalues block, so this extends it.sources/keycloak-configrenders the same resource with a fully static manifest and had no values block beyonddomain. Thecnpgblock is introduced there, keeping the two charts identical in behaviour so whichever one is wired up next does not reintroduce the blocker.enablePDBis CNPG's own recommendation over the alternative. PatchingnodeMaintenanceWindow.inProgressinstead draws a warning from the operator:It is also the only one of the two that survives ArgoCD.
nodeMaintenanceWindowis templated by these charts, so ArgoCD owns it and selfHeal reverts a manual patch within the reconcile interval.Verification
helm templateacross the matrix above, run separately for each chart, all five combinations rendering as expected withenablePDBtyped!!booland not a string:For
keycloak-old,cnpg.enabled=falsestill renders no Cluster at all, andhelm lintpasses.keycloak-configdoes not render or lint cleanly onmaineither:templates/keycloak-realm-templates-cm.yamlfails to parse at line 2123, unchanged by this PR and untouched by it. The matrix above was produced with that one file moved aside; the rest of the chart, including the Cluster, renders correctly.The rendered manifest was validated against the live CNPG v1.27.0 CRD on the
app-install-testcluster withkubectl apply --dry-run=server, which reportedconfiguredand converges to the same state as the hand patch currently applied there.Note on the sibling chart
sources/eai-infra/airm-cnpgis also single-instance with noenablePDB, so it carries the same latent drain blocker.aiwb-cnpgdefaults toinstances: 3and is unaffected. Left alone here to keep this PR to the keycloak charts, but worth a follow-up.