From d7a857cf0b6823fe67765824ea7d9f23567d389c Mon Sep 17 00:00:00 2001 From: Alessandro Cattapan Date: Sun, 6 Oct 2024 16:12:03 +0200 Subject: [PATCH 1/5] Added labels for deployment of SRS --- .../charts/srs/templates/srsservice_deployment.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/charts/backingservices/charts/srs/templates/srsservice_deployment.yaml b/charts/backingservices/charts/srs/templates/srsservice_deployment.yaml index ba5b1406a..7af8c57dc 100644 --- a/charts/backingservices/charts/srs/templates/srsservice_deployment.yaml +++ b/charts/backingservices/charts/srs/templates/srsservice_deployment.yaml @@ -5,6 +5,9 @@ metadata: name: {{ template "srs.fullname" . }} namespace: {{ .Release.Namespace }} labels: +{{- if .Values.srsRuntime.deploymentLabels }} +{{ toYaml .Values.srsRuntime.deploymentLabels | indent 4 }} +{{- end }} {{- include "srs.srs-service.labels" . | indent 4 }} spec: replicas: {{ .Values.srsRuntime.replicaCount }} From 055226f423c763723fff2abc7babb2b6b6f31d40 Mon Sep 17 00:00:00 2001 From: Alessandro Cattapan Date: Sun, 6 Oct 2024 23:11:05 +0200 Subject: [PATCH 2/5] Added labels for pods --- .../charts/srs/templates/srsservice_deployment.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/charts/backingservices/charts/srs/templates/srsservice_deployment.yaml b/charts/backingservices/charts/srs/templates/srsservice_deployment.yaml index 7af8c57dc..67060919e 100644 --- a/charts/backingservices/charts/srs/templates/srsservice_deployment.yaml +++ b/charts/backingservices/charts/srs/templates/srsservice_deployment.yaml @@ -17,6 +17,9 @@ spec: template: metadata: labels: +{{- if .Values.srsRuntime.podLabels }} +{{ toYaml .Values.srsRuntime.podLabels | indent 8 }} +{{- end }} {{- include "srs.srs-service.match-labels" . | indent 8 }} spec: imagePullSecrets: From fbfa7be2610d6c98ea7f9d1005a1109d07306afd Mon Sep 17 00:00:00 2001 From: Alessandro Cattapan Date: Sun, 6 Oct 2024 23:17:22 +0200 Subject: [PATCH 3/5] Updated documentation --- charts/backingservices/charts/srs/README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/charts/backingservices/charts/srs/README.md b/charts/backingservices/charts/srs/README.md index 3b55f7a93..f5b5b3109 100644 --- a/charts/backingservices/charts/srs/README.md +++ b/charts/backingservices/charts/srs/README.md @@ -108,7 +108,7 @@ To deploy Pega Platform with the SRS backing service, the SRS helm chart require |-----------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `enabled` | Enable the Search and Reporting Service deployment as a backing service. Set this parameter to `true` to use SRS. | | `deploymentName` | Specify the name of your SRS cluster. Your deployment creates resources prefixed with this string. This is also the service name for the SRS. | -| `srsRuntime` | Use this section to define specific resource configuration options like image, replica count, pod affinity, cpu and memory resource settings in the SRS. The default minimum required number of replicas is 2, but as a best practice, deploy 3 replicas to maintain high availability. | +| `srsRuntime` | Use this section to define specific resource configuration options like image, replica count, deployment labels, pod labels, pod affinity, cpu and memory resource settings in the SRS. The default minimum required number of replicas is 2, but as a best practice, deploy 3 replicas to maintain high availability. | | `busybox` | When provisioning an internally managed Elasticsearch cluster, you can customize the location and pull policy of the Alpine image used during the deployment process by specifying `busybox.image` and `busybox.imagePullPolicy`. | | `elasticsearch` | Define the elasticsearch cluster configurations. The [Elasticsearch](https://github.com/helm/charts/tree/master/stable/elasticsearch/values.yaml) chart defines the values for Elasticsearch provisioning in the SRS cluster. For internally provisioned Elasticsearch the default version is set to `7.17.9`. Set the `elasticsearch.imageTag` parameter in values.yaml to `7.16.3` to use this supported version in the SRS cluster. | | `k8sProvider` | Specify your Kubernetes provider name. Supported values are [`eks`, `aks`, `minikube`, `gke`, `openshift`, `pks`]. @@ -169,6 +169,14 @@ srs: imagePullPolicy: "IfNotPresent" srsRuntime: + # Specify additional deployment labels + deploymentLabels: + key1: value1 + + # Specify additional pod labels + podLabels: + key1: value1 + # Number of pods to provision replicaCount: 2 From 7e70382b9d74952c3a3bd9cfdb3ef43b5d67c7ec Mon Sep 17 00:00:00 2001 From: Alessandro Cattapan Date: Sun, 6 Oct 2024 23:48:52 +0200 Subject: [PATCH 4/5] Added Unit Tests --- .../backingservices/srs-deployment_test.go | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/terratest/src/test/backingservices/srs-deployment_test.go b/terratest/src/test/backingservices/srs-deployment_test.go index 482068615..fd994c5c4 100644 --- a/terratest/src/test/backingservices/srs-deployment_test.go +++ b/terratest/src/test/backingservices/srs-deployment_test.go @@ -48,6 +48,8 @@ func TestSRSDeployment(t *testing.T) { protocol: "https", }, false, + []label{}, + []label{}, }) } @@ -58,6 +60,9 @@ func TestSRSDeploymentVariables(t *testing.T) { "srs.enabled": "true", "srs.deploymentName": "test-srs-dev", "global.imageCredentials.registry": "docker-registry.io", + "srs.srsRuntime.deploymentLabels.key1": "value1", + "srs.srsRuntime.deploymentLabels.key2": "value2", + "srs.srsRuntime.podLabels.podkey1": "podValue1", "srs.srsRuntime.replicaCount": "3", "srs.srsRuntime.srsImage": "platform-services/search-n-reporting-service:1.0.0", "srs.srsRuntime.imagePullSecretNames": "{secret1, secret2}", @@ -101,6 +106,22 @@ func TestSRSDeploymentVariables(t *testing.T) { region: "us-east-1", }, true, + []label{ + { + key: "key1", + value: "value1", + }, + { + key: "key2", + value: "value2", + }, + }, + []label{ + { + key: "podkey1", + value: "podValue1", + }, + }, }) } @@ -151,6 +172,8 @@ func TestSRSDeploymentVariablesDefaultInternetEgress(t *testing.T) { protocol: "https", }, true, + []label{}, + []label{}, }) } @@ -200,6 +223,13 @@ func VerifySRSDeployment(t *testing.T, deploymentObj appsv1.Deployment, expected } require.Equal(t, expectedDeployment.appName, deploymentObj.Spec.Template.Labels["app.kubernetes.io/name"]) deploymentSpec := deploymentObj.Spec.Template.Spec + // Verify labels + for _, labelpair := range expectedDeployment.depLabels { + require.Equal(t, labelpair.value, deploymentObj.Labels[labelpair.key]) + } + for _, labelpair := range expectedDeployment.podLabels { + require.Equal(t, labelpair.value, deploymentObj.Spec.Template.Labels[labelpair.key]) + } VerifyDeployment(t, &deploymentSpec, expectedDeployment) } @@ -300,6 +330,8 @@ type srsDeployment struct { podLimits podResources elasticsearchEndPoint esDomain imagePullSecretNames bool + depLabels []label + podLabels []label } type podResources struct { @@ -315,3 +347,8 @@ type esDomain struct { protocol string region string } + +type label struct { + key string + value string +} From 41a86f51906421075f0aa41ef33c7287e435710d Mon Sep 17 00:00:00 2001 From: Alessandro Cattapan Date: Fri, 11 Oct 2024 22:26:59 +0200 Subject: [PATCH 5/5] Changed name of key to hold the deployment labels --- charts/backingservices/charts/srs/README.md | 11 +++++++---- .../charts/srs/templates/srsservice_deployment.yaml | 4 ++-- .../src/test/backingservices/srs-deployment_test.go | 4 ++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/charts/backingservices/charts/srs/README.md b/charts/backingservices/charts/srs/README.md index f5b5b3109..f7600febb 100644 --- a/charts/backingservices/charts/srs/README.md +++ b/charts/backingservices/charts/srs/README.md @@ -108,7 +108,8 @@ To deploy Pega Platform with the SRS backing service, the SRS helm chart require |-----------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `enabled` | Enable the Search and Reporting Service deployment as a backing service. Set this parameter to `true` to use SRS. | | `deploymentName` | Specify the name of your SRS cluster. Your deployment creates resources prefixed with this string. This is also the service name for the SRS. | -| `srsRuntime` | Use this section to define specific resource configuration options like image, replica count, deployment labels, pod labels, pod affinity, cpu and memory resource settings in the SRS. The default minimum required number of replicas is 2, but as a best practice, deploy 3 replicas to maintain high availability. | +| `deployment.labels` | Provide custom labels for the deployment as metadata to be consumed by other tools and libraries. | +| `srsRuntime` | Use this section to define specific resource configuration options like image, replica count, pod labels, pod affinity, cpu and memory resource settings in the SRS. The default minimum required number of replicas is 2, but as a best practice, deploy 3 replicas to maintain high availability. | | `busybox` | When provisioning an internally managed Elasticsearch cluster, you can customize the location and pull policy of the Alpine image used during the deployment process by specifying `busybox.image` and `busybox.imagePullPolicy`. | | `elasticsearch` | Define the elasticsearch cluster configurations. The [Elasticsearch](https://github.com/helm/charts/tree/master/stable/elasticsearch/values.yaml) chart defines the values for Elasticsearch provisioning in the SRS cluster. For internally provisioned Elasticsearch the default version is set to `7.17.9`. Set the `elasticsearch.imageTag` parameter in values.yaml to `7.16.3` to use this supported version in the SRS cluster. | | `k8sProvider` | Specify your Kubernetes provider name. Supported values are [`eks`, `aks`, `minikube`, `gke`, `openshift`, `pks`]. @@ -162,6 +163,11 @@ srs: # specify unique name for the deployment based on org app and/or srs applicable environment name. eg: acme-demo-dev-srs deploymentName: "YOUR_SRS_DEPLOYMENT_NAME" + deployment: + # Specify additional deployment labels + labels: + key1: value1 + # Configure the location of the busybox image that is used during the deployment process of # the internal Elasticsearch cluster busybox: @@ -169,9 +175,6 @@ srs: imagePullPolicy: "IfNotPresent" srsRuntime: - # Specify additional deployment labels - deploymentLabels: - key1: value1 # Specify additional pod labels podLabels: diff --git a/charts/backingservices/charts/srs/templates/srsservice_deployment.yaml b/charts/backingservices/charts/srs/templates/srsservice_deployment.yaml index 67060919e..381094e1f 100644 --- a/charts/backingservices/charts/srs/templates/srsservice_deployment.yaml +++ b/charts/backingservices/charts/srs/templates/srsservice_deployment.yaml @@ -5,8 +5,8 @@ metadata: name: {{ template "srs.fullname" . }} namespace: {{ .Release.Namespace }} labels: -{{- if .Values.srsRuntime.deploymentLabels }} -{{ toYaml .Values.srsRuntime.deploymentLabels | indent 4 }} +{{- if and (.Values.deployment) (.Values.deployment.labels) }} +{{ toYaml .Values.deployment.labels | indent 4 }} {{- end }} {{- include "srs.srs-service.labels" . | indent 4 }} spec: diff --git a/terratest/src/test/backingservices/srs-deployment_test.go b/terratest/src/test/backingservices/srs-deployment_test.go index fd994c5c4..2b3e0aaf7 100644 --- a/terratest/src/test/backingservices/srs-deployment_test.go +++ b/terratest/src/test/backingservices/srs-deployment_test.go @@ -60,8 +60,8 @@ func TestSRSDeploymentVariables(t *testing.T) { "srs.enabled": "true", "srs.deploymentName": "test-srs-dev", "global.imageCredentials.registry": "docker-registry.io", - "srs.srsRuntime.deploymentLabels.key1": "value1", - "srs.srsRuntime.deploymentLabels.key2": "value2", + "srs.deployment.labels.key1": "value1", + "srs.deployment.labels.key2": "value2", "srs.srsRuntime.podLabels.podkey1": "podValue1", "srs.srsRuntime.replicaCount": "3", "srs.srsRuntime.srsImage": "platform-services/search-n-reporting-service:1.0.0",