From 365b21974fe6b536a8c829c7e64b59b90c672fd5 Mon Sep 17 00:00:00 2001 From: Jonathan Stacks Date: Wed, 18 Dec 2024 12:44:48 -0600 Subject: [PATCH] fix(helm): .Values.podLabels should not be included in the deployment selectors --- helm/ngrok-operator/README.md | 4 +-- .../templates/agent/deployment.yaml | 3 --- .../bindings-forwarder/deployment.yaml | 3 --- .../templates/controller-deployment.yaml | 3 --- .../tests/agent/deployment_test.yaml | 24 +++++++++++++++++ .../bindings-forwarder/deployment_test.yaml | 24 +++++++++++++++++ .../tests/controller-deployment_test.yaml | 26 +++++++++++++++++++ helm/ngrok-operator/values.schema.json | 4 +-- helm/ngrok-operator/values.yaml | 4 +-- 9 files changed, 80 insertions(+), 15 deletions(-) diff --git a/helm/ngrok-operator/README.md b/helm/ngrok-operator/README.md index a7184f30..492f8fa2 100644 --- a/helm/ngrok-operator/README.md +++ b/helm/ngrok-operator/README.md @@ -70,8 +70,8 @@ To uninstall the chart: | Name | Description | Value | | ------------------------------------ | ----------------------------------------------------------------------------------------- | ------- | -| `podAnnotations` | Used to apply custom annotations to the ingress pods. | `{}` | -| `podLabels` | Used to apply custom labels to the ingress pods. | `{}` | +| `podAnnotations` | Custom pod annotations to apply to all pods. | `{}` | +| `podLabels` | Custom pod labels to apply to all pods. | `{}` | | `replicaCount` | The number of controllers to run. | `1` | | `affinity` | Affinity for the controller pod assignment | `{}` | | `podAffinityPreset` | Pod affinity preset. Ignored if `affinity` is set. Allowed values: `soft` or `hard` | `""` | diff --git a/helm/ngrok-operator/templates/agent/deployment.yaml b/helm/ngrok-operator/templates/agent/deployment.yaml index af9f4aeb..fd525c1b 100644 --- a/helm/ngrok-operator/templates/agent/deployment.yaml +++ b/helm/ngrok-operator/templates/agent/deployment.yaml @@ -18,9 +18,6 @@ spec: selector: matchLabels: {{- include "ngrok-operator.selectorLabels" . | nindent 6 }} - {{- if .Values.podLabels }} - {{- toYaml .Values.podLabels | nindent 6 }} - {{- end }} app.kubernetes.io/component: {{ $component }} template: metadata: diff --git a/helm/ngrok-operator/templates/bindings-forwarder/deployment.yaml b/helm/ngrok-operator/templates/bindings-forwarder/deployment.yaml index d9ca25a1..b2b4a947 100644 --- a/helm/ngrok-operator/templates/bindings-forwarder/deployment.yaml +++ b/helm/ngrok-operator/templates/bindings-forwarder/deployment.yaml @@ -18,9 +18,6 @@ spec: selector: matchLabels: {{- include "ngrok-operator.selectorLabels" . | nindent 6 }} - {{- if .Values.podLabels }} - {{- toYaml .Values.podLabels | nindent 6 }} - {{- end }} app.kubernetes.io/component: {{ $component }} template: metadata: diff --git a/helm/ngrok-operator/templates/controller-deployment.yaml b/helm/ngrok-operator/templates/controller-deployment.yaml index 2c58da88..9bcf32c1 100644 --- a/helm/ngrok-operator/templates/controller-deployment.yaml +++ b/helm/ngrok-operator/templates/controller-deployment.yaml @@ -15,9 +15,6 @@ spec: selector: matchLabels: {{- include "ngrok-operator.selectorLabels" . | nindent 6 }} - {{- if .Values.podLabels }} - {{- toYaml .Values.podLabels | nindent 6 }} - {{- end }} app.kubernetes.io/component: {{ $component }} template: metadata: diff --git a/helm/ngrok-operator/tests/agent/deployment_test.yaml b/helm/ngrok-operator/tests/agent/deployment_test.yaml index b9e6cdfd..6fa678d7 100644 --- a/helm/ngrok-operator/tests/agent/deployment_test.yaml +++ b/helm/ngrok-operator/tests/agent/deployment_test.yaml @@ -9,3 +9,27 @@ tests: - it: Should match snapshot asserts: - matchSnapshot: {} +- it: Adds .Values.podLabels to the controller deployment podspec + set: + podLabels: + labelKey1: labelValue1 + labelKey2: labelValue2 + template: agent/deployment.yaml + asserts: + - isSubset: + path: spec.template.metadata.labels + content: + labelKey1: labelValue1 + labelKey2: labelValue2 +- it: Does not add .Values.podLabels to the controller deployment's selector + set: + podLabels: + labelKey1: labelValue1 + labelKey2: labelValue2 + template: agent/deployment.yaml + asserts: + - isNotSubset: + path: spec.selector.matchLabels + content: + labelKey1: labelValue1 + labelKey2: labelValue2 diff --git a/helm/ngrok-operator/tests/bindings-forwarder/deployment_test.yaml b/helm/ngrok-operator/tests/bindings-forwarder/deployment_test.yaml index b1debad1..31b8ba72 100644 --- a/helm/ngrok-operator/tests/bindings-forwarder/deployment_test.yaml +++ b/helm/ngrok-operator/tests/bindings-forwarder/deployment_test.yaml @@ -19,3 +19,27 @@ tests: - equal: path: metadata.name value: RELEASE-NAME-ngrok-operator-bindings-forwarder +- it: Adds .Values.podLabels to the controller deployment podspec + set: + podLabels: + labelKey1: labelValue1 + labelKey2: labelValue2 + template: bindings-forwarder/deployment.yaml + asserts: + - isSubset: + path: spec.template.metadata.labels + content: + labelKey1: labelValue1 + labelKey2: labelValue2 +- it: Does not add .Values.podLabels to the controller deployment's selector + set: + podLabels: + labelKey1: labelValue1 + labelKey2: labelValue2 + template: bindings-forwarder/deployment.yaml + asserts: + - isNotSubset: + path: spec.selector.matchLabels + content: + labelKey1: labelValue1 + labelKey2: labelValue2 diff --git a/helm/ngrok-operator/tests/controller-deployment_test.yaml b/helm/ngrok-operator/tests/controller-deployment_test.yaml index 036358f6..05ff0356 100644 --- a/helm/ngrok-operator/tests/controller-deployment_test.yaml +++ b/helm/ngrok-operator/tests/controller-deployment_test.yaml @@ -354,3 +354,29 @@ tests: - equal: path: spec.template.spec.priorityClassName value: high-priority +- it: Adds .Values.podLabels to the controller deployment podspec + set: + podLabels: + labelKey1: labelValue1 + labelKey2: labelValue2 + template: controller-deployment.yaml + documentIndex: 0 # Document 0 is the deployment since its the first template + asserts: + - isSubset: + path: spec.template.metadata.labels + content: + labelKey1: labelValue1 + labelKey2: labelValue2 +- it: Does not add .Values.podLabels to the controller deployment's selector + set: + podLabels: + labelKey1: labelValue1 + labelKey2: labelValue2 + template: controller-deployment.yaml + documentIndex: 0 # Document 0 is the deployment since its the first template + asserts: + - isNotSubset: + path: spec.selector.matchLabels + content: + labelKey1: labelValue1 + labelKey2: labelValue2 diff --git a/helm/ngrok-operator/values.schema.json b/helm/ngrok-operator/values.schema.json index 5f8b34c1..ba3c6557 100644 --- a/helm/ngrok-operator/values.schema.json +++ b/helm/ngrok-operator/values.schema.json @@ -95,12 +95,12 @@ }, "podAnnotations": { "type": "object", - "description": "Used to apply custom annotations to the ingress pods.", + "description": "Custom pod annotations to apply to all pods.", "default": {} }, "podLabels": { "type": "object", - "description": "Used to apply custom labels to the ingress pods.", + "description": "Custom pod labels to apply to all pods.", "default": {} }, "replicaCount": { diff --git a/helm/ngrok-operator/values.yaml b/helm/ngrok-operator/values.yaml index 5a829ac9..5bf1cecc 100644 --- a/helm/ngrok-operator/values.yaml +++ b/helm/ngrok-operator/values.yaml @@ -65,8 +65,8 @@ clusterDomain: svc.cluster.local ## ## @section Operator Manager parameters ## -## @param podAnnotations Used to apply custom annotations to the ingress pods. -## @param podLabels Used to apply custom labels to the ingress pods. +## @param podAnnotations Custom pod annotations to apply to all pods. +## @param podLabels Custom pod labels to apply to all pods. ## podAnnotations: {} podLabels: {}