Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added configuration for pod labels and deployment labels in constellation and constellation messaging charts #834

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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" ) }}
Expand Down
3 changes: 3 additions & 0 deletions charts/backingservices/charts/constellation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -15,6 +18,9 @@ spec:
metadata:
labels:
app: {{ $depName }}
{{- if .Values.podLabels }}
{{ toYaml .Values.podLabels | nindent 8 }}
{{- end }}
spec:
{{- if .Values.customerAssetVolumeClaimName }}
volumes:
Expand Down
53 changes: 53 additions & 0 deletions terratest/src/test/backingservices/constellation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"

"github.com/stretchr/testify/require"
appsv1 "k8s.io/api/apps/v1"
)

func Test_shouldNotContainConstellationResourcesWhenDisabled(t *testing.T) {
Expand Down Expand Up @@ -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",
Expand Down
Loading