From c856874564497c8490f2525b93637daee2b29535 Mon Sep 17 00:00:00 2001 From: Robert Brennan Date: Mon, 28 Aug 2023 10:49:08 -0400 Subject: [PATCH] Update topologySpreadConstraint.yaml (#971) * Update topologySpreadConstraint.yaml * Update topologySpreadConstraint.yaml * fix test * add passing test --------- Co-authored-by: Andrew Suderman --- checks/topologySpreadConstraint.yaml | 14 +++++--------- ....invalidtopologykey.yaml => failure.empty.yaml} | 5 +---- test/checks/topologySpreadConstraint/success.yaml | 9 +++++++-- 3 files changed, 13 insertions(+), 15 deletions(-) rename test/checks/topologySpreadConstraint/{failure.invalidtopologykey.yaml => failure.empty.yaml} (92%) diff --git a/checks/topologySpreadConstraint.yaml b/checks/topologySpreadConstraint.yaml index 8256d42c5..e4173455d 100644 --- a/checks/topologySpreadConstraint.yaml +++ b/checks/topologySpreadConstraint.yaml @@ -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 @@ -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 diff --git a/test/checks/topologySpreadConstraint/failure.invalidtopologykey.yaml b/test/checks/topologySpreadConstraint/failure.empty.yaml similarity index 92% rename from test/checks/topologySpreadConstraint/failure.invalidtopologykey.yaml rename to test/checks/topologySpreadConstraint/failure.empty.yaml index 0cb09de8e..f1e14de63 100644 --- a/test/checks/topologySpreadConstraint/failure.invalidtopologykey.yaml +++ b/test/checks/topologySpreadConstraint/failure.empty.yaml @@ -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" diff --git a/test/checks/topologySpreadConstraint/success.yaml b/test/checks/topologySpreadConstraint/success.yaml index e48ee51d7..568e54204 100644 --- a/test/checks/topologySpreadConstraint/success.yaml +++ b/test/checks/topologySpreadConstraint/success.yaml @@ -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"