Skip to content

Commit

Permalink
Update topologySpreadConstraint.yaml (#971)
Browse files Browse the repository at this point in the history
* Update topologySpreadConstraint.yaml

* Update topologySpreadConstraint.yaml

* fix test

* add passing test

---------

Co-authored-by: Andrew Suderman <andy@fairwinds.com>
  • Loading branch information
rbren and sudermanjr authored Aug 28, 2023
1 parent 09525d0 commit c856874
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
14 changes: 5 additions & 9 deletions checks/topologySpreadConstraint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ successMessage: Pod has a valid topology spread constraint
failureMessage: Pod should be configured with a valid topology spread constraint
category: Reliability
target: PodSpec
controllers:
exclude:
- Job
- CronJob
schema:
'$schema': http://json-schema.org/draft-07/schema
type: object
Expand All @@ -10,12 +14,4 @@ schema:
properties:
topologySpreadConstraints:
type: array
items:
type: object
properties:
topologyKey:
anyOf:
- type: string
const: "kubernetes.io/hostname"
- type: string
const: "topology.kubernetes.io/zone"
minItems: 1
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ spec:
app.kubernetes.io/name: basic-demo
app.kubernetes.io/instance: demo
spec:
topologySpreadConstraints:
- maxSkew: 1
topologyKey: farglebargle
whenUnsatisfiable: ScheduleAnyway
topologySpreadConstraints: []
containers:
- name: basic-demo
image: "quay.io/fairwinds/docker-demo:latest"
Expand Down
9 changes: 7 additions & 2 deletions test/checks/topologySpreadConstraint/success.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ spec:
spec:
topologySpreadConstraints:
- maxSkew: 1
topologyKey: "topology.kubernetes.io/zone"
whenUnsatisfiable: ScheduleAnyway
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
app: foo
matchLabelKeys:
- pod-template-hash
containers:
- name: basic-demo
image: "quay.io/fairwinds/docker-demo:latest"
Expand Down

0 comments on commit c856874

Please sign in to comment.