From b652bdd75728ca2a981055d65b28b97902f91714 Mon Sep 17 00:00:00 2001 From: chgl Date: Mon, 26 Apr 2021 21:43:36 +0200 Subject: [PATCH] fix: use new-style labels Signed-off-by: chgl --- .../ci/enable-metrics-values.yaml | 5 ++ .../argo-workflows/ci/enable-rbac-values.yaml | 5 ++ charts/argo-workflows/templates/_helpers.tpl | 88 ++++++++++++++++++- .../controller/workflow-aggregate-roles.yaml | 6 +- .../workflow-controller-cluster-roles.yaml | 4 +- .../workflow-controller-config-map.yaml | 6 +- .../controller/workflow-controller-crb.yaml | 12 ++- .../workflow-controller-deployment-pdb.yaml | 10 +-- .../workflow-controller-deployment.yaml | 19 ++-- .../controller/workflow-controller-sa.yaml | 2 +- .../workflow-controller-service.yaml | 10 +-- .../workflow-controller-servicemonitor.yaml | 10 +-- .../templates/controller/workflow-rb.yaml | 4 +- .../templates/controller/workflow-role.yaml | 2 +- .../server/server-cluster-roles.yaml | 8 +- .../templates/server/server-crb.yaml | 12 ++- .../server/server-deployment-pdb.yaml | 10 +-- .../templates/server/server-deployment.yaml | 14 ++- .../templates/server/server-ingress.yaml | 15 +--- .../templates/server/server-sa.yaml | 2 +- .../templates/server/server-service.yaml | 12 +-- 21 files changed, 164 insertions(+), 92 deletions(-) create mode 100644 charts/argo-workflows/ci/enable-metrics-values.yaml create mode 100644 charts/argo-workflows/ci/enable-rbac-values.yaml diff --git a/charts/argo-workflows/ci/enable-metrics-values.yaml b/charts/argo-workflows/ci/enable-metrics-values.yaml new file mode 100644 index 00000000..949ed73b --- /dev/null +++ b/charts/argo-workflows/ci/enable-metrics-values.yaml @@ -0,0 +1,5 @@ +controller: + serviceMonitor: + enabled: true + metricsConfig: + enabled: true diff --git a/charts/argo-workflows/ci/enable-rbac-values.yaml b/charts/argo-workflows/ci/enable-rbac-values.yaml new file mode 100644 index 00000000..10f717ac --- /dev/null +++ b/charts/argo-workflows/ci/enable-rbac-values.yaml @@ -0,0 +1,5 @@ +workflow: + serviceAccount: + create: true # Specifies whether a service account should be created + rbac: + create: true # adds Role and RoleBinding for the above specified service account to be able to run workflows diff --git a/charts/argo-workflows/templates/_helpers.tpl b/charts/argo-workflows/templates/_helpers.tpl index f0d83d2e..14dd315a 100644 --- a/charts/argo-workflows/templates/_helpers.tpl +++ b/charts/argo-workflows/templates/_helpers.tpl @@ -1,16 +1,96 @@ {{/* vim: set filetype=mustache: */}} + +{{/* +Create argo workflows server name and version as used by the chart label. +*/}} +{{- define "argo-workflows.server.fullname" -}} +{{- printf "%s-%s" (include "argo-workflows.fullname" .) .Values.server.name | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create controller name and version as used by the chart label. +*/}} +{{- define "argo-workflows.controller.fullname" -}} +{{- printf "%s-%s" (include "argo-workflows.fullname" .) .Values.controller.name | trunc 63 | trimSuffix "-" -}} +{{- end -}} + {{/* Expand the name of the chart. */}} -{{- define "name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} -{{- end -}} +{{- define "argo-workflows.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} {{/* Create a default fully qualified app name. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). */}} -{{- define "fullname" -}} +{{- define "argo-workflows.fullname" -}} {{- $name := default .Chart.Name .Values.nameOverride -}} {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} {{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "argo-workflows.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "argo-workflows.labels" -}} +helm.sh/chart: {{ include "argo-workflows.chart" .context }} +{{ include "argo-workflows.selectorLabels" (dict "context" .context "component" .component "name" .name) }} +app.kubernetes.io/managed-by: {{ .context.Release.Service }} +app.kubernetes.io/part-of: argo-workflows +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "argo-workflows.selectorLabels" -}} +{{- if .name -}} +app.kubernetes.io/name: {{ include "argo-workflows.name" .context }}-{{ .name }} +{{ end -}} +app.kubernetes.io/instance: {{ .context.Release.Name }} +{{- if .component }} +app.kubernetes.io/component: {{ .component }} +{{- end }} +{{- end }} + +{{/* +Create the name of the server service account to use +*/}} +{{- define "argo-workflows.serverServiceAccountName" -}} +{{- if .Values.server.createServiceAccount -}} + {{ default (include "argo-workflows.fullname" .) .Values.server.serviceAccount }} +{{- else -}} + {{ default "default" .Values.server.serviceAccount }} +{{- end -}} +{{- end -}} + +{{/* +Create the name of the controller service account to use +*/}} +{{- define "argo-workflows.controllerServiceAccountName" -}} +{{- if .Values.controller.createServiceAccount -}} + {{ default (include "argo-workflows.fullname" .) .Values.controller.serviceAccount }} +{{- else -}} + {{ default "default" .Values.controller.serviceAccount }} +{{- end -}} +{{- end -}} + +{{/* +Return the appropriate apiVersion for ingress +*/}} +{{- define "argo-cd.ingress.apiVersion" -}} +{{- if semverCompare "<1.14-0" .Capabilities.KubeVersion.GitVersion -}} +{{- print "extensions/v1beta1" -}} +{{- else if semverCompare "<1.19-0" .Capabilities.KubeVersion.GitVersion -}} +{{- print "networking.k8s.io/v1beta1" -}} +{{- else -}} +{{- print "networking.k8s.io/v1" -}} +{{- end -}} +{{- end -}} diff --git a/charts/argo-workflows/templates/controller/workflow-aggregate-roles.yaml b/charts/argo-workflows/templates/controller/workflow-aggregate-roles.yaml index ad06e61d..2143f208 100644 --- a/charts/argo-workflows/templates/controller/workflow-aggregate-roles.yaml +++ b/charts/argo-workflows/templates/controller/workflow-aggregate-roles.yaml @@ -5,7 +5,7 @@ metadata: annotations: helm.sh/hook: pre-install helm.sh/hook-delete-policy: before-hook-creation - name: argo-aggregate-to-view + name: argo-workflows-aggregate-to-view labels: rbac.authorization.k8s.io/aggregate-to-view: "true" rules: @@ -33,7 +33,7 @@ metadata: annotations: helm.sh/hook: pre-install helm.sh/hook-delete-policy: before-hook-creation - name: argo-aggregate-to-edit + name: argo-workflows-aggregate-to-edit labels: rbac.authorization.k8s.io/aggregate-to-edit: "true" rules: @@ -66,7 +66,7 @@ metadata: annotations: helm.sh/hook: pre-install helm.sh/hook-delete-policy: before-hook-creation - name: argo-aggregate-to-admin + name: argo-workflows-aggregate-to-admin labels: rbac.authorization.k8s.io/aggregate-to-admin: "true" rules: diff --git a/charts/argo-workflows/templates/controller/workflow-controller-cluster-roles.yaml b/charts/argo-workflows/templates/controller/workflow-controller-cluster-roles.yaml index 4d596b1c..de5e88a3 100644 --- a/charts/argo-workflows/templates/controller/workflow-controller-cluster-roles.yaml +++ b/charts/argo-workflows/templates/controller/workflow-controller-cluster-roles.yaml @@ -5,7 +5,9 @@ kind: Role kind: ClusterRole {{- end }} metadata: - name: {{ .Release.Name }}-{{ .Values.controller.name }} + name: {{ template "argo-workflows.controller.fullname" . }} + labels: + {{- include "argo-workflows.labels" (dict "context" . "component" .Values.controller.name "name" .Values.controller.name) | nindent 4 }} rules: - apiGroups: - "" diff --git a/charts/argo-workflows/templates/controller/workflow-controller-config-map.yaml b/charts/argo-workflows/templates/controller/workflow-controller-config-map.yaml index f689375f..afddb194 100644 --- a/charts/argo-workflows/templates/controller/workflow-controller-config-map.yaml +++ b/charts/argo-workflows/templates/controller/workflow-controller-config-map.yaml @@ -1,11 +1,9 @@ apiVersion: v1 kind: ConfigMap metadata: - name: {{ .Release.Name }}-{{ .Values.controller.name }}-configmap + name: {{ template "argo-workflows.controller.fullname" . }}-configmap labels: - chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} + {{- include "argo-workflows.labels" (dict "context" . "component" .Values.controller.name "name" "cm") | nindent 4 }} data: config: | {{- if .Values.controller.instanceID.enabled }} diff --git a/charts/argo-workflows/templates/controller/workflow-controller-crb.yaml b/charts/argo-workflows/templates/controller/workflow-controller-crb.yaml index 66cca4d0..e99f0fcf 100644 --- a/charts/argo-workflows/templates/controller/workflow-controller-crb.yaml +++ b/charts/argo-workflows/templates/controller/workflow-controller-crb.yaml @@ -5,7 +5,9 @@ kind: RoleBinding kind: ClusterRoleBinding {{- end }} metadata: - name: {{ .Release.Name }}-{{ .Values.controller.name }} + name: {{ template "argo-workflows.controller.fullname" . }} + labels: + {{- include "argo-workflows.labels" (dict "context" . "component" .Values.controller.name "name" .Values.controller.name) | nindent 4 }} roleRef: apiGroup: rbac.authorization.k8s.io {{- if .Values.singleNamespace }} @@ -13,7 +15,7 @@ roleRef: {{ else }} kind: ClusterRole {{- end }} - name: {{ .Release.Name }}-{{ .Values.controller.name }} + name: {{ template "argo-workflows.controller.fullname" . }} subjects: - kind: ServiceAccount name: {{ .Values.controller.serviceAccount }} @@ -33,11 +35,13 @@ subjects: apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: - name: {{ .Release.Name }}-{{ .Values.controller.name }}-cluster-template + name: {{ template "argo-workflows.controller.fullname" . }}-cluster-template + labels: + {{- include "argo-workflows.labels" (dict "context" . "component" .Values.controller.name "name" .Values.controller.name) | nindent 4 }} roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole - name: {{ .Release.Name }}-{{ .Values.controller.name }}-cluster-template + name: {{ template "argo-workflows.controller.fullname" . }}-cluster-template subjects: - kind: ServiceAccount name: {{ .Values.controller.serviceAccount }} diff --git a/charts/argo-workflows/templates/controller/workflow-controller-deployment-pdb.yaml b/charts/argo-workflows/templates/controller/workflow-controller-deployment-pdb.yaml index a7352a04..564ba412 100644 --- a/charts/argo-workflows/templates/controller/workflow-controller-deployment-pdb.yaml +++ b/charts/argo-workflows/templates/controller/workflow-controller-deployment-pdb.yaml @@ -2,12 +2,9 @@ apiVersion: policy/v1beta1 kind: PodDisruptionBudget metadata: - name: {{ .Release.Name }}-{{ .Values.controller.name}} + name: {{ template "argo-workflows.controller.fullname" . }} labels: - app: {{ .Release.Name }}-{{ .Values.controller.name}} - chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} + {{- include "argo-workflows.labels" (dict "context" . "component" .Values.controller.name "name" .Values.controller.name) | nindent 4 }} spec: {{- if .Values.controller.pdb.minAvailable }} minAvailable: {{ .Values.controller.pdb.minAvailable }} @@ -18,6 +15,5 @@ spec: {{- end }} selector: matchLabels: - app: {{ .Release.Name }}-{{ .Values.controller.name}} - release: {{ .Release.Name }} + {{- include "argo-workflows.selectorLabels" (dict "context" . "name" .Values.controller.name) | nindent 6 }} {{- end }} diff --git a/charts/argo-workflows/templates/controller/workflow-controller-deployment.yaml b/charts/argo-workflows/templates/controller/workflow-controller-deployment.yaml index 66b6afbb..c449896e 100644 --- a/charts/argo-workflows/templates/controller/workflow-controller-deployment.yaml +++ b/charts/argo-workflows/templates/controller/workflow-controller-deployment.yaml @@ -1,23 +1,20 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: {{ .Release.Name }}-{{ .Values.controller.name}} + name: {{ template "argo-workflows.controller.fullname" . }} labels: - app: {{ .Release.Name }}-{{ .Values.controller.name}} - chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} + {{- include "argo-workflows.labels" (dict "context" . "component" .Values.controller.name "name" .Values.controller.name) | nindent 4 }} + app.kubernetes.io/version: {{ default .Chart.AppVersion .Values.controller.image.tag | quote }} spec: replicas: {{ .Values.controller.replicas }} selector: matchLabels: - app: {{ .Release.Name }}-{{ .Values.controller.name}} - release: {{ .Release.Name }} + {{- include "argo-workflows.selectorLabels" (dict "context" . "name" .Values.controller.name) | nindent 6 }} template: metadata: labels: - app: {{ .Release.Name }}-{{ .Values.controller.name}} - release: {{ .Release.Name }} + {{- include "argo-workflows.labels" (dict "context" . "component" .Values.controller.name "name" .Values.controller.name) | nindent 8 }} + app.kubernetes.io/version: {{ default .Chart.AppVersion .Values.controller.image.tag | quote }} {{- if .Values.controller.podLabels }} {{ toYaml .Values.controller.podLabels | nindent 8}} {{- end }} @@ -25,7 +22,7 @@ spec: annotations: {{ toYaml .Values.controller.podAnnotations | indent 8}}{{- end }} spec: - serviceAccountName: {{ .Values.controller.serviceAccount | quote }} + serviceAccountName: {{ template "argo-workflows.controllerServiceAccountName" . }} {{- if .Values.controller.podSecurityContext }} securityContext: {{- toYaml .Values.controller.podSecurityContext | nindent 8 }} @@ -37,7 +34,7 @@ spec: command: [ "workflow-controller" ] args: - "--configmap" - - "{{ .Release.Name }}-{{ .Values.controller.name}}-configmap" + - "{{ template "argo-workflows.controller.fullname" . }}-configmap" - "--executor-image" - "{{ .Values.executor.image.registry }}/{{ .Values.executor.image.repository }}:{{ .Values.executor.image.tag | default .Chart.AppVersion }}" - "--loglevel" diff --git a/charts/argo-workflows/templates/controller/workflow-controller-sa.yaml b/charts/argo-workflows/templates/controller/workflow-controller-sa.yaml index 02d274da..09715489 100644 --- a/charts/argo-workflows/templates/controller/workflow-controller-sa.yaml +++ b/charts/argo-workflows/templates/controller/workflow-controller-sa.yaml @@ -1,6 +1,6 @@ apiVersion: v1 kind: ServiceAccount metadata: - name: {{ .Values.controller.serviceAccount }} + name: {{ template "argo-workflows.controllerServiceAccountName" . }} annotations: {{ toYaml .Values.controller.serviceAccountAnnotations | indent 4 }} diff --git a/charts/argo-workflows/templates/controller/workflow-controller-service.yaml b/charts/argo-workflows/templates/controller/workflow-controller-service.yaml index 7985a54c..9517ddb3 100644 --- a/charts/argo-workflows/templates/controller/workflow-controller-service.yaml +++ b/charts/argo-workflows/templates/controller/workflow-controller-service.yaml @@ -2,12 +2,10 @@ apiVersion: v1 kind: Service metadata: - name: {{ .Release.Name }}-{{ .Values.controller.name }} + name: {{ template "argo-workflows.controller.fullname" . }} labels: - app: {{ .Release.Name }}-{{ .Values.controller.name}} - chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} + {{- include "argo-workflows.labels" (dict "context" . "component" .Values.controller.name "name" .Values.controller.name) | nindent 4 }} + app.kubernetes.io/version: {{ default .Chart.AppVersion .Values.controller.image.tag | quote }} {{- if .Values.controller.serviceLabels }} {{ toYaml .Values.controller.serviceLabels | nindent 4}} {{- end }} @@ -29,7 +27,7 @@ spec: targetPort: {{ .Values.controller.telemetryConfig.port }} {{- end }} selector: - app: {{ .Release.Name }}-{{ .Values.controller.name }} + {{- include "argo-workflows.selectorLabels" (dict "context" . "name" .Values.controller.name) | nindent 4 }} sessionAffinity: None type: {{ .Values.controller.serviceType }} {{- if and (eq .Values.controller.serviceType "LoadBalancer") .Values.controller.loadBalancerSourceRanges }} diff --git a/charts/argo-workflows/templates/controller/workflow-controller-servicemonitor.yaml b/charts/argo-workflows/templates/controller/workflow-controller-servicemonitor.yaml index 425fedac..06888a8f 100644 --- a/charts/argo-workflows/templates/controller/workflow-controller-servicemonitor.yaml +++ b/charts/argo-workflows/templates/controller/workflow-controller-servicemonitor.yaml @@ -2,12 +2,9 @@ apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: - name: {{ .Release.Name }}-{{ .Values.controller.name }} + name: {{ template "argo-workflows.controller.fullname" . }} labels: - app: {{ .Release.Name }}-{{ .Values.controller.name}} - chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} + {{- include "argo-workflows.labels" (dict "context" . "component" .Values.controller.name "name" .Values.controller.name) | nindent 4 }} {{- if .Values.controller.serviceMonitor.additionalLabels }} {{ toYaml .Values.controller.serviceMonitor.additionalLabels | indent 4 }} {{- end }} @@ -28,6 +25,5 @@ spec: - {{ .Release.Namespace }} selector: matchLabels: - app: {{ .Release.Name }}-{{ .Values.controller.name}} - release: {{ .Release.Name }} + {{- include "argo-workflows.selectorLabels" (dict "context" . "name" .Values.controller.name) | nindent 6 }} {{- end }} diff --git a/charts/argo-workflows/templates/controller/workflow-rb.yaml b/charts/argo-workflows/templates/controller/workflow-rb.yaml index 17785257..c2d54b7c 100644 --- a/charts/argo-workflows/templates/controller/workflow-rb.yaml +++ b/charts/argo-workflows/templates/controller/workflow-rb.yaml @@ -2,14 +2,14 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: - name: {{ .Release.Name }}-workflow + name: {{ template "argo-workflows.fullname" . }}-workflow {{- if .Values.workflow.namespace }} namespace: {{ .Values.workflow.namespace }} {{- end }} roleRef: apiGroup: rbac.authorization.k8s.io kind: Role - name: {{ .Release.Name }}-workflow + name: {{ template "argo-workflows.fullname" . }}-workflow subjects: - kind: ServiceAccount name: {{ .Values.workflow.serviceAccount.name }} diff --git a/charts/argo-workflows/templates/controller/workflow-role.yaml b/charts/argo-workflows/templates/controller/workflow-role.yaml index 37365f21..7fb0bbc6 100644 --- a/charts/argo-workflows/templates/controller/workflow-role.yaml +++ b/charts/argo-workflows/templates/controller/workflow-role.yaml @@ -2,7 +2,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: - name: {{ .Release.Name }}-workflow + name: {{ template "argo-workflows.fullname" . }}-workflow {{- if .Values.workflow.namespace }} namespace: {{ .Values.workflow.namespace }} {{- end }} diff --git a/charts/argo-workflows/templates/server/server-cluster-roles.yaml b/charts/argo-workflows/templates/server/server-cluster-roles.yaml index 1ee505ef..976a25c3 100644 --- a/charts/argo-workflows/templates/server/server-cluster-roles.yaml +++ b/charts/argo-workflows/templates/server/server-cluster-roles.yaml @@ -6,7 +6,9 @@ kind: Role kind: ClusterRole {{- end }} metadata: - name: {{ .Release.Name }}-{{ .Values.server.name }} + name: {{ template "argo-workflows.server.fullname" . }} + labels: + {{- include "argo-workflows.labels" (dict "context" . "component" .Values.server.name "name" .Values.server.name) | nindent 4 }} rules: - apiGroups: - "" @@ -115,7 +117,9 @@ rules: apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: - name: {{ .Release.Name }}-{{ .Values.server.name }}-cluster-template + name: {{ template "argo-workflows.server.fullname" . }}-cluster-template + labels: + {{- include "argo-workflows.labels" (dict "context" . "component" .Values.server.name "name" .Values.server.name) | nindent 4 }} rules: - apiGroups: - argoproj.io diff --git a/charts/argo-workflows/templates/server/server-crb.yaml b/charts/argo-workflows/templates/server/server-crb.yaml index ad4cfeda..d6f35da1 100644 --- a/charts/argo-workflows/templates/server/server-crb.yaml +++ b/charts/argo-workflows/templates/server/server-crb.yaml @@ -6,7 +6,9 @@ kind: RoleBinding kind: ClusterRoleBinding {{- end }} metadata: - name: {{ .Release.Name }}-{{ .Values.server.name}} + name: {{ template "argo-workflows.server.fullname" . }} + labels: + {{- include "argo-workflows.labels" (dict "context" . "component" .Values.server.name "name" .Values.server.name) | nindent 4 }} roleRef: apiGroup: rbac.authorization.k8s.io {{- if .Values.singleNamespace }} @@ -14,7 +16,7 @@ roleRef: {{ else }} kind: ClusterRole {{- end }} - name: {{ .Release.Name }}-{{ .Values.server.name}} + name: {{ template "argo-workflows.server.fullname" . }} subjects: - kind: ServiceAccount name: {{ .Values.server.serviceAccount }} @@ -23,11 +25,13 @@ subjects: apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: - name: {{ .Release.Name }}-{{ .Values.server.name}}-cluster-template + name: {{ template "argo-workflows.server.fullname" . }}-cluster-template + labels: + {{- include "argo-workflows.labels" (dict "context" . "component" .Values.server.name "name" .Values.server.name) | nindent 4 }} roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole - name: {{ .Release.Name }}-{{ .Values.server.name}}-cluster-template + name: {{ template "argo-workflows.server.fullname" . }}-cluster-template subjects: - kind: ServiceAccount name: {{ .Values.server.serviceAccount }} diff --git a/charts/argo-workflows/templates/server/server-deployment-pdb.yaml b/charts/argo-workflows/templates/server/server-deployment-pdb.yaml index 31f1d4f8..452fa90a 100644 --- a/charts/argo-workflows/templates/server/server-deployment-pdb.yaml +++ b/charts/argo-workflows/templates/server/server-deployment-pdb.yaml @@ -3,12 +3,9 @@ apiVersion: policy/v1beta1 kind: PodDisruptionBudget metadata: - name: {{ .Release.Name }}-{{ .Values.server.name}} + name: {{ template "argo-workflows.server.fullname" . }} labels: - app: {{ .Release.Name }}-{{ .Values.server.name}} - chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} + {{- include "argo-workflows.labels" (dict "context" . "component" .Values.server.name "name" .Values.server.name) | nindent 4 }} spec: {{- if .Values.server.pdb.minAvailable }} minAvailable: {{ .Values.server.pdb.minAvailable }} @@ -19,7 +16,6 @@ spec: {{- end }} selector: matchLabels: - app: {{ .Release.Name }}-{{ .Values.server.name}} - release: {{ .Release.Name }} + {{- include "argo-workflows.selectorLabels" (dict "context" . "name" .Values.server.name) | nindent 6 }} {{- end -}} {{- end -}} diff --git a/charts/argo-workflows/templates/server/server-deployment.yaml b/charts/argo-workflows/templates/server/server-deployment.yaml index 40d3d738..07fa2af5 100644 --- a/charts/argo-workflows/templates/server/server-deployment.yaml +++ b/charts/argo-workflows/templates/server/server-deployment.yaml @@ -2,22 +2,20 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: {{ .Release.Name }}-{{ .Values.server.name}} + name: {{ template "argo-workflows.server.fullname" . }} labels: - chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} + {{- include "argo-workflows.labels" (dict "context" . "component" .Values.server.name "name" .Values.server.name) | nindent 4 }} + app.kubernetes.io/version: {{ default .Chart.AppVersion .Values.server.image.tag | quote }} spec: replicas: {{ .Values.server.replicas }} selector: matchLabels: - app: {{ .Release.Name }}-{{ .Values.server.name}} - release: {{ .Release.Name }} + {{- include "argo-workflows.selectorLabels" (dict "context" . "name" .Values.server.name) | nindent 6 }} template: metadata: labels: - app: {{ .Release.Name }}-{{ .Values.server.name}} - release: {{ .Release.Name }} + {{- include "argo-workflows.labels" (dict "context" . "component" .Values.server.name "name" .Values.server.name) | nindent 8 }} + app.kubernetes.io/version: {{ default .Chart.AppVersion .Values.server.image.tag | quote }} {{- if .Values.server.podLabels }} {{- toYaml .Values.server.podLabels | nindent 8 }} {{- end }} diff --git a/charts/argo-workflows/templates/server/server-ingress.yaml b/charts/argo-workflows/templates/server/server-ingress.yaml index 6eab3f50..4594fb18 100644 --- a/charts/argo-workflows/templates/server/server-ingress.yaml +++ b/charts/argo-workflows/templates/server/server-ingress.yaml @@ -1,19 +1,12 @@ {{- if .Values.server.enabled -}} {{- if .Values.server.ingress.enabled -}} -{{- $serviceName := printf "%s-%s" .Release.Name .Values.server.name -}} +{{- $serviceName := include "argo-workflows.server.fullname" . -}} {{- $servicePort := .Values.server.servicePort -}} -{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1" }} -apiVersion: networking.k8s.io/v1beta1 -{{ else }} -apiVersion: extensions/v1beta1 -{{ end -}} -kind: Ingress +apiVersion: {{ include "argo-workflows.ingress.apiVersion" . }} metadata: - name: {{ .Release.Name }}-{{ .Values.server.name }} + name: {{ template "argo-workflows.server.fullname" . }} labels: - chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} + {{- include "argo-workflows.labels" $ | nindent 4 }} {{- range $key, $value := .Values.server.ingress.labels }} {{ $key }}: {{ $value | quote }} {{- end }} diff --git a/charts/argo-workflows/templates/server/server-sa.yaml b/charts/argo-workflows/templates/server/server-sa.yaml index 5b419a65..c0e2a255 100644 --- a/charts/argo-workflows/templates/server/server-sa.yaml +++ b/charts/argo-workflows/templates/server/server-sa.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: ServiceAccount metadata: - name: {{ .Values.server.serviceAccount }} + name: {{ template "argo-workflows.serverServiceAccountName" . }} annotations: {{ toYaml .Values.server.serviceAccountAnnotations | indent 4 }} {{- end -}} diff --git a/charts/argo-workflows/templates/server/server-service.yaml b/charts/argo-workflows/templates/server/server-service.yaml index ba4d74f6..7938a8a7 100644 --- a/charts/argo-workflows/templates/server/server-service.yaml +++ b/charts/argo-workflows/templates/server/server-service.yaml @@ -2,14 +2,10 @@ apiVersion: v1 kind: Service metadata: - name: {{ .Release.Name }}-{{ .Values.server.name }} + name: {{ template "argo-workflows.server.fullname" . }} labels: - chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} - {{- if .Values.server.serviceLabels }} - {{- toYaml .Values.server.serviceLabels | nindent 4 }} - {{- end }} + {{- include "argo-workflows.labels" (dict "context" . "component" .Values.server.name "name" .Values.server.name) | nindent 4 }} + app.kubernetes.io/version: {{ default .Chart.AppVersion .Values.server.image.tag | quote }} {{- if .Values.server.serviceAnnotations }} annotations: {{ toYaml .Values.server.serviceAnnotations | indent 4}}{{- end }} @@ -21,7 +17,7 @@ spec: {{- end }} targetPort: 2746 selector: - app: {{ .Release.Name }}-{{ .Values.server.name }} + {{- include "argo-workflows.selectorLabels" (dict "context" . "name" .Values.server.name) | nindent 4 }} sessionAffinity: None type: {{ .Values.server.serviceType }} {{- if and (eq .Values.server.serviceType "LoadBalancer") .Values.server.loadBalancerIP }}