diff --git a/charts/backingservices/charts/srs/README.md b/charts/backingservices/charts/srs/README.md index 3b55f7a93..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, 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,6 +175,11 @@ srs: imagePullPolicy: "IfNotPresent" srsRuntime: + + # Specify additional pod labels + podLabels: + key1: value1 + # Number of pods to provision replicaCount: 2 diff --git a/charts/backingservices/charts/srs/templates/srsservice_deployment.yaml b/charts/backingservices/charts/srs/templates/srsservice_deployment.yaml index ba5b1406a..381094e1f 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 and (.Values.deployment) (.Values.deployment.labels) }} +{{ toYaml .Values.deployment.labels | indent 4 }} +{{- end }} {{- include "srs.srs-service.labels" . | indent 4 }} spec: replicas: {{ .Values.srsRuntime.replicaCount }} @@ -14,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: diff --git a/terratest/src/test/backingservices/srs-deployment_test.go b/terratest/src/test/backingservices/srs-deployment_test.go index 482068615..2b3e0aaf7 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.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", "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 +}