Skip to content

Commit

Permalink
Add support for deployment labels (temporalio#581)
Browse files Browse the repository at this point in the history
* feat: add support for defining deployment labels

---------

Co-authored-by: Rob Holland <[email protected]>
  • Loading branch information
2 people authored and asproul committed Dec 16, 2024
1 parent f7e3f68 commit d1a39d2
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 3 deletions.
2 changes: 1 addition & 1 deletion charts/temporal/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ app.kubernetes.io/part-of: {{ $global.Chart.Name }}
{{- end -}}
{{- end -}}
{{- range $label_name, $label_value := $global.Values.additionalLabels }}
{{ $label_name }}: {{ $label_value | quote }}
{{ $label_name }}: {{ $label_value }}
{{- end -}}
{{- end -}}

Expand Down
2 changes: 1 addition & 1 deletion charts/temporal/templates/admintools-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
annotations:
{{- include "temporal.resourceAnnotations" (list $ "admintools" "deployment") | nindent 4 }}
labels:
{{- include "temporal.resourceLabels" (list $ "admintools" "") | nindent 4 }}
{{- include "temporal.resourceLabels" (list $ "admintools" "deployment") | nindent 4 }}
spec:
replicas: 1
selector:
Expand Down
2 changes: 1 addition & 1 deletion charts/temporal/templates/web-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
annotations:
{{- include "temporal.resourceAnnotations" (list $ "web" "deployment") | nindent 4 }}
labels:
{{- include "temporal.resourceLabels" (list $ "web" "") | nindent 4 }}
{{- include "temporal.resourceLabels" (list $ "web" "deployment") | nindent 4 }}
spec:
replicas: {{ .Values.web.replicaCount }}
selector:
Expand Down
34 changes: 34 additions & 0 deletions charts/temporal/tests/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,37 @@ func TestTemplateServerDeploymentAnnotations(t *testing.T) {
require.Equal(t, "zero", deployment.ObjectMeta.Annotations["zero"])
require.Equal(t, "zero", deployment.Spec.Template.ObjectMeta.Annotations["zero"])
}

func TestTemplateServerDeploymentLabels(t *testing.T) {
// t.Parallel()

helmChartPath, err := filepath.Abs("../")
releaseName := "temporal"
require.NoError(t, err)

namespaceName := "temporal-" + strings.ToLower(random.UniqueId())

var deployment appsv1.Deployment

options := &helm.Options{
SetValues: map[string]string{
"server.frontend.deploymentLabels.one": "three",
"server.frontend.deploymentLabels.four": "four",
"server.deploymentLabels.one": "one",
"server.deploymentLabels.two": "two",
"additionalLabels.zero": "zero",
},
KubectlOptions: k8s.NewKubectlOptions("", "", namespaceName),
BuildDependencies: true,
}

output := helm.RenderTemplate(t, options, helmChartPath, releaseName, []string{"templates/server-deployment.yaml"})

helm.UnmarshalK8SYaml(t, output, &deployment)

require.Equal(t, "three", deployment.ObjectMeta.Labels["one"])
require.Equal(t, "two", deployment.ObjectMeta.Labels["two"])
require.Equal(t, "four", deployment.ObjectMeta.Labels["four"])
require.Equal(t, "zero", deployment.ObjectMeta.Labels["zero"])
require.Equal(t, "zero", deployment.Spec.Template.ObjectMeta.Labels["zero"])
}
7 changes: 7 additions & 0 deletions charts/temporal/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ server:
# targetLabel: __name__
prometheus:
timerType: histogram
deploymentLabels: {}
deploymentAnnotations: {}
podAnnotations: {}
podLabels: {}
Expand Down Expand Up @@ -232,6 +233,7 @@ server:
# enabled: false
prometheus: {}
# timerType: histogram
deploymentLabels: {}
deploymentAnnotations: {}
podAnnotations: {}
podLabels: {}
Expand All @@ -255,6 +257,7 @@ server:
# enabled: false
prometheus: {}
# timerType: histogram
deploymentLabels: {}
deploymentAnnotations: {}
podAnnotations: {}
podLabels: {}
Expand All @@ -279,6 +282,7 @@ server:
# enabled: false
prometheus: {}
# timerType: histogram
deploymentLabels: {}
deploymentAnnotations: {}
podAnnotations: {}
podLabels: {}
Expand All @@ -302,6 +306,7 @@ server:
# enabled: false
prometheus: {}
# timerType: histogram
deploymentLabels: {}
deploymentAnnotations: {}
podAnnotations: {}
podLabels: {}
Expand All @@ -323,6 +328,7 @@ admintools:
type: ClusterIP
port: 22
annotations: {}
deploymentLabels: {}
deploymentAnnotations: {}
podLabels: {}
podAnnotations: {}
Expand Down Expand Up @@ -367,6 +373,7 @@ web:
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
deploymentLabels: {}
deploymentAnnotations: {}
podAnnotations: {}
podLabels: {}
Expand Down

0 comments on commit d1a39d2

Please sign in to comment.