diff --git a/charts/backingservices/charts/constellation-messaging/README.md b/charts/backingservices/charts/constellation-messaging/README.md index 88e7058c8..f2ef2bf1f 100644 --- a/charts/backingservices/charts/constellation-messaging/README.md +++ b/charts/backingservices/charts/constellation-messaging/README.md @@ -15,7 +15,9 @@ Complete information on the design of the service including architecture, scalab | `enabled` | Enable the Messaging Service deployment as a backing service. Set this parameter to `true` to deploy the service. | | `provider` | Enter your Kubernetes provider. Accepted values are aws, gke or k8s. | | `name` | Deprecated, use `deployment.name`. Specify the name of your messaging service. Your deployment creates resources prefixed with this string. | +| `podLabels` | Provide custom labels for Pods as metadata to be consumed by other tools and libraries. | | `deployment.name` | Specify the name of your messaging service. Your deployment creates resources prefixed with this string. | +| `deployment.labels` | Provide custom labels for the deployment as metadata to be consumed by other tools and libraries. | | `imagePullSecretNames` | Deprected, use `docker.imagePullSecretNames`. List pre-existing secrets to be used for pulling docker images. | | `affinity` | Define pod affinity so that it is restricted to run on particular node(s), or to prefer to run on particular nodes. | | `docker.imagePullSecretNames` | List pre-existing secrets to be used for pulling docker images. | diff --git a/charts/backingservices/charts/constellation-messaging/templates/messaging-deployment.yaml b/charts/backingservices/charts/constellation-messaging/templates/messaging-deployment.yaml index 0a4ae8b0e..90ae28957 100644 --- a/charts/backingservices/charts/constellation-messaging/templates/messaging-deployment.yaml +++ b/charts/backingservices/charts/constellation-messaging/templates/messaging-deployment.yaml @@ -7,6 +7,9 @@ metadata: name: {{ $depName }} labels: app: {{ $depName }} + {{- if and (.Values.deployment) (.Values.deployment.labels) }} + {{ toYaml .Values.deployment.labels | nindent 4 }} + {{- end }} spec: replicas: {{ .Values.replicas }} selector: @@ -16,6 +19,9 @@ spec: metadata: labels: app: {{ $depName }} + {{- if .Values.podLabels }} + {{ toYaml .Values.podLabels | nindent 8 }} + {{- end }} spec: imagePullSecrets: - name: {{ include "backingservicesRegistrySecret" ( dict "root" .Values "defaultname" "constellation-messaging" ) }} diff --git a/charts/backingservices/charts/constellation/README.md b/charts/backingservices/charts/constellation/README.md index 341179bf1..30d58cfb3 100644 --- a/charts/backingservices/charts/constellation/README.md +++ b/charts/backingservices/charts/constellation/README.md @@ -45,6 +45,9 @@ The values.yaml file provides configuration options to define the values for the | `cloudProvider` | Deprecated, use `provider`. Specify the cloud provider details. Accepted values are aws. | | `provider` | Enter your Kubernetes provider. Accepted values are aws, gke or k8s. | | `awsCertificateArn` | Specify the arn for the AWS ACM certificate. | +| `podLabels` | Provide custom labels for Pods as metadata to be consumed by other tools and libraries. | +| `deployment.name` | Specify the name of constellation deployment. Your deployment creates resources prefixed with this string. | +| `deployment.labels` | Provide custom labels for the deployment as metadata to be consumed by other tools and libraries. | | `service.port` | The port of the tier to be exposed to the cluster. The default value is `3000`. | | `service.targetPort` | The target port of the container to expose. The constellation container exposes web traffic on port `3000`. | | `service.serviceType` | The [type of service](https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types) you wish to expose. | diff --git a/charts/backingservices/charts/constellation/templates/clln-deployment.yaml b/charts/backingservices/charts/constellation/templates/clln-deployment.yaml index 2dcb3dc41..8cf2570d6 100644 --- a/charts/backingservices/charts/constellation/templates/clln-deployment.yaml +++ b/charts/backingservices/charts/constellation/templates/clln-deployment.yaml @@ -6,6 +6,9 @@ metadata: name: {{ $depName }} labels: app: {{ $depName }} + {{- if and (.Values.deployment) (.Values.deployment.labels) }} + {{ toYaml .Values.deployment.labels | nindent 4 }} + {{- end }} spec: replicas: {{ .Values.replicas }} selector: @@ -15,6 +18,9 @@ spec: metadata: labels: app: {{ $depName }} + {{- if .Values.podLabels }} + {{ toYaml .Values.podLabels | nindent 8 }} + {{- end }} spec: {{- if .Values.customerAssetVolumeClaimName }} volumes: diff --git a/terratest/src/test/backingservices/constellation_test.go b/terratest/src/test/backingservices/constellation_test.go index 455a70d17..1ae68a1e3 100644 --- a/terratest/src/test/backingservices/constellation_test.go +++ b/terratest/src/test/backingservices/constellation_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/stretchr/testify/require" + appsv1 "k8s.io/api/apps/v1" ) func Test_shouldNotContainConstellationResourcesWhenDisabled(t *testing.T) { @@ -95,6 +96,58 @@ func Test_shouldNotContainConstellationMessagingWhenDisabled(t *testing.T) { } } +func Test_ConstellationMessagingWithLabels(t *testing.T) { + + var deploymentName string = "constellation-msg" + + helmChartParser := NewHelmConfigParser( + NewHelmTest(t, helmChartRelativePath, map[string]string{ + "constellation-messaging.enabled": "true", + "constellation-messaging.deployment.name": deploymentName, + "constellation-messaging.deployment.labels.key1": "value1", + "constellation-messaging.podLabels.podKey1": "podValue1", + }), + ) + + var cllnMsgDeployment appsv1.Deployment + helmChartParser.getResourceYAML(SearchResourceOption{ + Name: deploymentName, + Kind: "Deployment", + }, &cllnMsgDeployment) + + require.Equal(t, cllnMsgDeployment.Name, deploymentName) + require.Equal(t, cllnMsgDeployment.Labels["key1"], "value1") + require.Equal(t, cllnMsgDeployment.Spec.Template.Labels["podKey1"], "podValue1") + require.Equal(t, cllnMsgDeployment.Labels["app"], deploymentName) + require.Equal(t, cllnMsgDeployment.Spec.Template.Labels["app"], deploymentName) +} + +func Test_ConstellationWithLabels(t *testing.T) { + + var deploymentName string = "constellation-static" + + helmChartParser := NewHelmConfigParser( + NewHelmTest(t, helmChartRelativePath, map[string]string{ + "constellation.enabled": "true", + "constellation.deployment.name": deploymentName, + "constellation.deployment.labels.key1": "value1", + "constellation.podLabels.podKey1": "podValue1", + }), + ) + + var cllnDeployment appsv1.Deployment + helmChartParser.getResourceYAML(SearchResourceOption{ + Name: deploymentName, + Kind: "Deployment", + }, &cllnDeployment) + + require.Equal(t, cllnDeployment.Name, deploymentName) + require.Equal(t, cllnDeployment.Labels["key1"], "value1") + require.Equal(t, cllnDeployment.Spec.Template.Labels["podKey1"], "podValue1") + require.Equal(t, cllnDeployment.Labels["app"], deploymentName) + require.Equal(t, cllnDeployment.Spec.Template.Labels["app"], deploymentName) +} + var constellationResources = []SearchResourceOption{ { Name: "constellation",