-
Notifications
You must be signed in to change notification settings - Fork 0
Add PodDisruptionBudgets and topologySpreadConstraints support #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
henzigo
wants to merge
4
commits into
cron-consumer-resource-defaults
Choose a base branch
from
pdb-topology-spread
base: cron-consumer-resource-defaults
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
306eb0c
Add PodDisruptionBudgets and topologySpreadConstraints support
henzigo c2aeb51
Tighten PDB gating to guaranteed 2+ replicas and guard the pdb map
henzigo d24e469
Merge remote-tracking branch 'origin/cron-consumer-resource-defaults'…
henzigo f93671c
Add pdb and topologySpreadConstraints to the values schemas
henzigo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| {{/* Rendered only when the storefront is guaranteed to run with 2+ replicas — a PDB with | ||
| minAvailable: 1 on a single-replica Deployment would block node drains forever. | ||
| Autoscaling counts only with minReplicas > 1 (the HPA may scale down to minReplicas). */}} | ||
| {{- $s := .Values.storefront }} | ||
| {{- if and ($s.pdb).enabled (or (and $s.autoscaling.enabled (gt (int $s.autoscaling.minReplicas) 1)) (gt (int $s.replicas) 1)) }} | ||
| apiVersion: policy/v1 | ||
| kind: PodDisruptionBudget | ||
| metadata: | ||
| name: storefront | ||
| labels: | ||
| {{- include "shopsys.labels" $ | nindent 4 }} | ||
| app: storefront | ||
| spec: | ||
| minAvailable: {{ $s.pdb.minAvailable | default 1 }} | ||
| selector: | ||
| matchLabels: | ||
| app: storefront | ||
| {{- end }} |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| {{/* Rendered only when the webserver is guaranteed to run with 2+ replicas — a PDB with | ||
| minAvailable: 1 on a single-replica Deployment would block node drains forever. | ||
| Autoscaling counts only with minReplicas > 1 (the HPA may scale down to minReplicas). */}} | ||
| {{- $w := .Values.webserver }} | ||
| {{- if and ($w.pdb).enabled (or (and $w.autoscaling.enabled (gt (int $w.autoscaling.minReplicas) 1)) (gt (int $w.replicas) 1)) }} | ||
| apiVersion: policy/v1 | ||
| kind: PodDisruptionBudget | ||
| metadata: | ||
| name: webserver-php-fpm | ||
| labels: | ||
| {{- include "shopsys.labels" $ | nindent 4 }} | ||
| app: webserver-php-fpm | ||
| spec: | ||
| minAvailable: {{ $w.pdb.minAvailable | default 1 }} | ||
| selector: | ||
| matchLabels: | ||
| app: webserver-php-fpm | ||
| {{- end }} |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| suite: pod disruption budgets | ||
| values: | ||
| - ./values/required.yaml | ||
| templates: | ||
| - templates/pdb-webserver.yaml | ||
| - templates/pdb-storefront.yaml | ||
| tests: | ||
| - it: renders no PDB for single-replica components without autoscaling | ||
| asserts: | ||
| - hasDocuments: | ||
| count: 0 | ||
|
|
||
| - it: renders the PDB when autoscaling is enabled | ||
| template: templates/pdb-webserver.yaml | ||
| set: | ||
| webserver: | ||
| autoscaling: | ||
| enabled: true | ||
| asserts: | ||
| - hasDocuments: | ||
| count: 1 | ||
| - equal: | ||
| path: spec.minAvailable | ||
| value: 1 | ||
| - equal: | ||
| path: spec.selector.matchLabels.app | ||
| value: webserver-php-fpm | ||
|
|
||
| - it: renders no PDB when autoscaling can scale down to a single replica | ||
| template: templates/pdb-webserver.yaml | ||
| set: | ||
| webserver: | ||
| autoscaling: | ||
| enabled: true | ||
| minReplicas: 1 | ||
| asserts: | ||
| - hasDocuments: | ||
| count: 0 | ||
|
|
||
| - it: renders no PDB when the pdb map is nulled by an overlay | ||
| template: templates/pdb-storefront.yaml | ||
| set: | ||
| storefront: | ||
| autoscaling: | ||
| enabled: true | ||
| pdb: null | ||
| asserts: | ||
| - hasDocuments: | ||
| count: 0 | ||
|
|
||
| - it: renders the PDB when running multiple fixed replicas | ||
| template: templates/pdb-storefront.yaml | ||
| set: | ||
| storefront: | ||
| replicas: 3 | ||
| asserts: | ||
| - hasDocuments: | ||
| count: 1 | ||
| - equal: | ||
| path: spec.selector.matchLabels.app | ||
| value: storefront | ||
|
|
||
| - it: honors a minAvailable override | ||
| template: templates/pdb-webserver.yaml | ||
| set: | ||
| webserver: | ||
| autoscaling: | ||
| enabled: true | ||
| pdb: | ||
| minAvailable: 2 | ||
| asserts: | ||
| - equal: | ||
| path: spec.minAvailable | ||
| value: 2 | ||
|
|
||
| - it: can be disabled explicitly | ||
| template: templates/pdb-webserver.yaml | ||
| set: | ||
| webserver: | ||
| autoscaling: | ||
| enabled: true | ||
| pdb: | ||
| enabled: false | ||
| asserts: | ||
| - hasDocuments: | ||
| count: 0 |
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
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
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
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since
topologySpreadConstraintsis a raw passthrough, consider a one-line usage hint here: preferwhenUnsatisfiable: ScheduleAnywayunless spread is a hard requirement (DoNotSchedulecan leave pods Pending on small/dev clusters), and addmatchLabelKeys: [pod-template-hash](beta, enabled by default since K8s 1.27; the chart is validated against 1.31) so the spread does not count old-ReplicaSet pods during rolling updates. Purely a docs suggestion — the passthrough design itself is right and consistent withaffinity. — Claude Agent (CR)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in c2aeb51: a short note under the standard-keys table in
docs/values.mdrecommendingwhenUnsatisfiable: ScheduleAnywayunless spread is a hard requirement, andmatchLabelKeys: [pod-template-hash]so the spread ignores old-ReplicaSet pods during rolling updates. Kept it to one paragraph since the key is a raw passthrough by design.