From f6127efd85d1f3a8de27ef441b7aa3bec29bc28a Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Thu, 21 Nov 2024 11:12:31 -0500 Subject: [PATCH] feat(labels): add part-of selector label (#211) * feat(labels): add part-of selector label * chore(service): rename ports to remove 'cryostat-' prefix * set service ports appProtocol --- charts/cryostat/templates/_helpers.tpl | 1 + charts/cryostat/templates/cryostat_service.yaml | 6 ++++-- charts/cryostat/tests/cookie_secret_test.yaml | 1 + .../cryostat/tests/cryostat_deployment_test.yaml | 3 +++ charts/cryostat/tests/cryostat_service_test.yaml | 15 ++++++++++++--- charts/cryostat/tests/db_deployment_test.yaml | 3 +++ charts/cryostat/tests/db_pvc_test.yaml | 1 + charts/cryostat/tests/db_secret_test.yaml | 1 + charts/cryostat/tests/db_service_test.yaml | 2 ++ .../cryostat/tests/reports_deployment_test.yaml | 3 +++ charts/cryostat/tests/role_test.yaml | 2 ++ charts/cryostat/tests/route_test.yaml | 1 + .../cryostat/tests/storage_deployment_test.yaml | 3 +++ charts/cryostat/tests/storage_pvc_test.yaml | 1 + charts/cryostat/tests/storage_secret_test.yaml | 1 + charts/cryostat/tests/storage_service_test.yaml | 2 ++ 16 files changed, 41 insertions(+), 5 deletions(-) diff --git a/charts/cryostat/templates/_helpers.tpl b/charts/cryostat/templates/_helpers.tpl index c68af86a..5a37a96c 100644 --- a/charts/cryostat/templates/_helpers.tpl +++ b/charts/cryostat/templates/_helpers.tpl @@ -48,6 +48,7 @@ Selector labels. {{- define "cryostat.selectorLabels" -}} app.kubernetes.io/name: {{ include "cryostat.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} +app.kubernetes.io/part-of: cryostat {{- end }} {{/* diff --git a/charts/cryostat/templates/cryostat_service.yaml b/charts/cryostat/templates/cryostat_service.yaml index 74aea0fd..46351a28 100644 --- a/charts/cryostat/templates/cryostat_service.yaml +++ b/charts/cryostat/templates/cryostat_service.yaml @@ -17,12 +17,14 @@ spec: - port: {{ .Values.core.service.httpPort }} targetPort: 4180 protocol: TCP - name: cryostat-http + name: http + appProtocol: http {{- if (.Values.authentication.openshift).enabled }} - port: 443 targetPort: 8443 protocol: TCP - name: cryostat-https + name: https + appProtocol: https {{- end }} selector: {{- include "cryostat.selectorLabels" $ | nindent 4 }} diff --git a/charts/cryostat/tests/cookie_secret_test.yaml b/charts/cryostat/tests/cookie_secret_test.yaml index 8047df4e..00fc2241 100644 --- a/charts/cryostat/tests/cookie_secret_test.yaml +++ b/charts/cryostat/tests/cookie_secret_test.yaml @@ -22,6 +22,7 @@ tests: path: metadata.labels value: app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/part-of: cryostat app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: cryostat app.kubernetes.io/version: 4.0.0-dev diff --git a/charts/cryostat/tests/cryostat_deployment_test.yaml b/charts/cryostat/tests/cryostat_deployment_test.yaml index 64396061..d47607e0 100644 --- a/charts/cryostat/tests/cryostat_deployment_test.yaml +++ b/charts/cryostat/tests/cryostat_deployment_test.yaml @@ -23,12 +23,14 @@ tests: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/name: cryostat app.kubernetes.io/component: cryostat + app.kubernetes.io/part-of: cryostat - equal: path: spec.template.metadata.labels value: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/name: cryostat app.kubernetes.io/component: cryostat + app.kubernetes.io/part-of: cryostat - equal: path: spec.template.spec.serviceAccountName value: RELEASE-NAME-cryostat @@ -47,6 +49,7 @@ tests: app.kubernetes.io/version: "4.0.0-dev" app.kubernetes.io/managed-by: Helm app.kubernetes.io/component: cryostat + app.kubernetes.io/part-of: cryostat - it: should validate all container settings including environment variables and security contexts asserts: diff --git a/charts/cryostat/tests/cryostat_service_test.yaml b/charts/cryostat/tests/cryostat_service_test.yaml index 1cc53127..f051287e 100644 --- a/charts/cryostat/tests/cryostat_service_test.yaml +++ b/charts/cryostat/tests/cryostat_service_test.yaml @@ -31,7 +31,10 @@ tests: value: TCP - equal: path: spec.ports[0].name - value: cryostat-http + value: http + - equal: + path: spec.ports[0].appProtocol + value: http - equal: path: metadata.labels value: @@ -41,6 +44,7 @@ tests: app.kubernetes.io/version: "4.0.0-dev" helm.sh/chart: cryostat-2.0.0-dev app.kubernetes.io/component: cryostat + app.kubernetes.io/part-of: cryostat - it: should create a Service with the correct settings when OpenShift authentication is enabled set: @@ -68,7 +72,7 @@ tests: value: TCP - equal: path: spec.ports[0].name - value: cryostat-http + value: http - equal: path: spec.ports[1].port value: 443 @@ -80,13 +84,17 @@ tests: value: TCP - equal: path: spec.ports[1].name - value: cryostat-https + value: https + - equal: + path: spec.ports[1].appProtocol + value: https - equal: path: spec.selector value: app.kubernetes.io/name: cryostat app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/component: cryostat + app.kubernetes.io/part-of: cryostat - equal: path: metadata.labels value: @@ -96,6 +104,7 @@ tests: app.kubernetes.io/version: "4.0.0-dev" helm.sh/chart: cryostat-2.0.0-dev app.kubernetes.io/component: cryostat + app.kubernetes.io/part-of: cryostat - equal: path: metadata.annotations value: diff --git a/charts/cryostat/tests/db_deployment_test.yaml b/charts/cryostat/tests/db_deployment_test.yaml index 092b33b5..fa1ff93e 100644 --- a/charts/cryostat/tests/db_deployment_test.yaml +++ b/charts/cryostat/tests/db_deployment_test.yaml @@ -23,12 +23,14 @@ tests: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/name: cryostat app.kubernetes.io/component: db + app.kubernetes.io/part-of: cryostat - equal: path: spec.template.metadata.labels value: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/name: cryostat app.kubernetes.io/component: db + app.kubernetes.io/part-of: cryostat - equal: path: spec.template.spec.serviceAccountName value: RELEASE-NAME-cryostat @@ -47,6 +49,7 @@ tests: app.kubernetes.io/version: "4.0.0-dev" app.kubernetes.io/managed-by: Helm app.kubernetes.io/component: db + app.kubernetes.io/part-of: cryostat - it: should validate cryostat-db settings asserts: diff --git a/charts/cryostat/tests/db_pvc_test.yaml b/charts/cryostat/tests/db_pvc_test.yaml index b88b4e41..0e793d34 100644 --- a/charts/cryostat/tests/db_pvc_test.yaml +++ b/charts/cryostat/tests/db_pvc_test.yaml @@ -29,6 +29,7 @@ tests: path: metadata.labels value: app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/part-of: cryostat app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: cryostat app.kubernetes.io/version: "4.0.0-dev" diff --git a/charts/cryostat/tests/db_secret_test.yaml b/charts/cryostat/tests/db_secret_test.yaml index 1405ce76..f1e8463b 100644 --- a/charts/cryostat/tests/db_secret_test.yaml +++ b/charts/cryostat/tests/db_secret_test.yaml @@ -26,6 +26,7 @@ tests: path: metadata.labels value: app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/part-of: cryostat app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: cryostat app.kubernetes.io/version: 4.0.0-dev diff --git a/charts/cryostat/tests/db_service_test.yaml b/charts/cryostat/tests/db_service_test.yaml index 69c162e2..48c10436 100644 --- a/charts/cryostat/tests/db_service_test.yaml +++ b/charts/cryostat/tests/db_service_test.yaml @@ -28,6 +28,7 @@ tests: app.kubernetes.io/version: "4.0.0-dev" helm.sh/chart: cryostat-2.0.0-dev app.kubernetes.io/component: db + app.kubernetes.io/part-of: cryostat - it: should create a Service with the correct settings overrides set: @@ -57,3 +58,4 @@ tests: app.kubernetes.io/version: "4.0.0-dev" helm.sh/chart: cryostat-2.0.0-dev app.kubernetes.io/component: db + app.kubernetes.io/part-of: cryostat diff --git a/charts/cryostat/tests/reports_deployment_test.yaml b/charts/cryostat/tests/reports_deployment_test.yaml index d504264c..b5ca35a1 100644 --- a/charts/cryostat/tests/reports_deployment_test.yaml +++ b/charts/cryostat/tests/reports_deployment_test.yaml @@ -31,11 +31,13 @@ tests: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/name: cryostat app.kubernetes.io/component: reports + app.kubernetes.io/part-of: cryostat - equal: path: spec.template.metadata.labels value: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/name: cryostat + app.kubernetes.io/part-of: cryostat app.kubernetes.io/component: reports - equal: path: spec.template.spec.serviceAccountName @@ -55,6 +57,7 @@ tests: app.kubernetes.io/version: "4.0.0-dev" app.kubernetes.io/managed-by: Helm app.kubernetes.io/component: reports + app.kubernetes.io/part-of: cryostat - it: should validate all container settings including environment variables and security contexts set: diff --git a/charts/cryostat/tests/role_test.yaml b/charts/cryostat/tests/role_test.yaml index 75723b13..19db7aef 100644 --- a/charts/cryostat/tests/role_test.yaml +++ b/charts/cryostat/tests/role_test.yaml @@ -36,6 +36,7 @@ tests: path: metadata.labels value: app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/part-of: cryostat app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: cryostat app.kubernetes.io/version: "4.0.0-dev" @@ -45,6 +46,7 @@ tests: path: metadata.labels value: app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/part-of: cryostat app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: cryostat app.kubernetes.io/version: "4.0.0-dev" diff --git a/charts/cryostat/tests/route_test.yaml b/charts/cryostat/tests/route_test.yaml index b29cabb7..d31d1a57 100644 --- a/charts/cryostat/tests/route_test.yaml +++ b/charts/cryostat/tests/route_test.yaml @@ -31,6 +31,7 @@ tests: path: metadata.labels value: app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/part-of: cryostat app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: cryostat app.kubernetes.io/version: "4.0.0-dev" diff --git a/charts/cryostat/tests/storage_deployment_test.yaml b/charts/cryostat/tests/storage_deployment_test.yaml index b3c1d8db..a077cd00 100644 --- a/charts/cryostat/tests/storage_deployment_test.yaml +++ b/charts/cryostat/tests/storage_deployment_test.yaml @@ -23,12 +23,14 @@ tests: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/name: cryostat app.kubernetes.io/component: storage + app.kubernetes.io/part-of: cryostat - equal: path: spec.template.metadata.labels value: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/name: cryostat app.kubernetes.io/component: storage + app.kubernetes.io/part-of: cryostat - equal: path: spec.template.spec.serviceAccountName value: RELEASE-NAME-cryostat @@ -47,6 +49,7 @@ tests: app.kubernetes.io/version: "4.0.0-dev" app.kubernetes.io/managed-by: Helm app.kubernetes.io/component: storage + app.kubernetes.io/part-of: cryostat - it: should validate cryostat-storage settings asserts: diff --git a/charts/cryostat/tests/storage_pvc_test.yaml b/charts/cryostat/tests/storage_pvc_test.yaml index 7af53d86..01d30378 100644 --- a/charts/cryostat/tests/storage_pvc_test.yaml +++ b/charts/cryostat/tests/storage_pvc_test.yaml @@ -29,6 +29,7 @@ tests: path: metadata.labels value: app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/part-of: cryostat app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: cryostat app.kubernetes.io/version: "4.0.0-dev" diff --git a/charts/cryostat/tests/storage_secret_test.yaml b/charts/cryostat/tests/storage_secret_test.yaml index e18e9908..72c31741 100644 --- a/charts/cryostat/tests/storage_secret_test.yaml +++ b/charts/cryostat/tests/storage_secret_test.yaml @@ -22,6 +22,7 @@ tests: path: metadata.labels value: app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/part-of: cryostat app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: cryostat app.kubernetes.io/version: 4.0.0-dev diff --git a/charts/cryostat/tests/storage_service_test.yaml b/charts/cryostat/tests/storage_service_test.yaml index ec0c9fe8..59bec524 100644 --- a/charts/cryostat/tests/storage_service_test.yaml +++ b/charts/cryostat/tests/storage_service_test.yaml @@ -28,6 +28,7 @@ tests: app.kubernetes.io/version: "4.0.0-dev" helm.sh/chart: cryostat-2.0.0-dev app.kubernetes.io/component: storage + app.kubernetes.io/part-of: cryostat - it: should create a Service with the correct settings overrides set: @@ -58,3 +59,4 @@ tests: app.kubernetes.io/version: "4.0.0-dev" helm.sh/chart: cryostat-2.0.0-dev app.kubernetes.io/component: storage + app.kubernetes.io/part-of: cryostat