Skip to content
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
22 changes: 22 additions & 0 deletions chart/docs/customizing-labels.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,28 @@ Customizing Pod Labels
The Helm Chart allows you to customize labels for your Airflow objects. You can set global labels that apply to all objects and pods defined in the chart,
as well as component-specific labels for individual Airflow components.

Default Labels
~~~~~~~~~~~~~~

Resources managed directly by the Airflow chart include the following Kubernetes-recommended labels by default:

.. code-block:: yaml

app.kubernetes.io/part-of: airflow
app.kubernetes.io/name: airflow
app.kubernetes.io/instance: <Helm release name>
app.kubernetes.io/version: <Airflow application version>
helm.sh/chart: <chart name>-<chart version>
app.kubernetes.io/managed-by: <Helm release service>

Resources with a component label also include ``app.kubernetes.io/component`` with the same value. Pod templates include
``app.kubernetes.io/part-of``, ``app.kubernetes.io/name``, ``app.kubernetes.io/instance``,
``app.kubernetes.io/version``, and ``app.kubernetes.io/component``.

The chart's workload, service, policy, and autoscaling selectors use ``app.kubernetes.io/part-of``,
``app.kubernetes.io/instance``, and ``app.kubernetes.io/component`` instead of the legacy ``tier``, ``release``, and
``component`` labels removed in chart 2.0.

Global Labels
~~~~~~~~~~~~~

Expand Down
8 changes: 5 additions & 3 deletions chart/docs/customizing-workers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,11 @@ As an example, let's say you want to set ``priorityClassName`` on your workers:
metadata:
name: placeholder-name
labels:
tier: airflow
component: worker
release: {{ .Release.Name }}
app.kubernetes.io/name: airflow
app.kubernetes.io/part-of: airflow
app.kubernetes.io/component: worker
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/version: {{ .Chart.AppVersion }}
spec:
priorityClassName: high-priority
containers:
Expand Down
4 changes: 1 addition & 3 deletions chart/files/pod-template-file.kubernetes-helm-yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ kind: Pod
metadata:
name: placeholder-name
labels:
tier: airflow
component: worker
release: {{ .Release.Name }}
{{- include "airflow.standardPodLabels" (dict "root" . "component" "worker") | nindent 4 }}
{{- if or .Values.labels .Values.workers.kubernetes.labels }}
{{- mustMerge .Values.workers.kubernetes.labels .Values.labels | toYaml | nindent 4 }}
{{- end }}
Expand Down
41 changes: 41 additions & 0 deletions chart/templates/_helpers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,47 @@ If release name contains chart name it will be used as a full name.
{{- end }}
{{- end }}

{{/*
Sanitize a value for use as a Kubernetes label value.
*/}}
{{- define "airflow.labelValue" -}}
{{- . | toString | replace "+" "_" | trunc 63 | trimAll "-_." -}}
{{- end }}

{{/*
Kubernetes recommended labels for chart resources.
*/}}
{{- define "airflow.standardLabels" -}}
{{- $root := .root -}}
{{- $labels := dict
"app.kubernetes.io/instance" (include "airflow.labelValue" $root.Release.Name)
"app.kubernetes.io/managed-by" (include "airflow.labelValue" $root.Release.Service)
"app.kubernetes.io/name" (include "airflow.labelValue" $root.Chart.Name)
"app.kubernetes.io/part-of" "airflow"
Comment thread
mihirduvedi marked this conversation as resolved.
Resolved
"app.kubernetes.io/version" (include "airflow.labelValue" $root.Chart.AppVersion)
"helm.sh/chart" (include "airflow.labelValue" (printf "%s-%s" $root.Chart.Name $root.Chart.Version))
-}}
{{- with .component }}
{{- $_ := set $labels "app.kubernetes.io/component" (include "airflow.labelValue" .) -}}
{{- end }}
{{- toYaml $labels -}}
{{- end }}

{{/*
Kubernetes recommended labels for chart-managed pods.
*/}}
{{- define "airflow.standardPodLabels" -}}
{{- $root := .root -}}
{{- $labels := dict
"app.kubernetes.io/component" (include "airflow.labelValue" (required "component is required for standard pod labels" .component))
"app.kubernetes.io/instance" (include "airflow.labelValue" $root.Release.Name)
"app.kubernetes.io/name" (include "airflow.labelValue" $root.Chart.Name)
"app.kubernetes.io/part-of" "airflow"
"app.kubernetes.io/version" (include "airflow.labelValue" $root.Chart.AppVersion)
-}}
{{- toYaml $labels -}}
{{- end }}

{{- define "airflow.serviceAccountName" -}}
{{ if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
Expand Down
18 changes: 6 additions & 12 deletions chart/templates/api-server/api-server-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ kind: Deployment
metadata:
name: {{ include "airflow.fullname" . }}-api-server
labels:
tier: airflow
component: api-server
release: {{ .Release.Name }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
heritage: {{ .Release.Service }}
{{- include "airflow.standardLabels" (dict "root" . "component" "api-server") | nindent 4 }}
{{- with .Values.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
Expand Down Expand Up @@ -71,15 +67,13 @@ spec:
{{- end }}
selector:
matchLabels:
tier: airflow
component: api-server
release: {{ .Release.Name }}
app.kubernetes.io/part-of: airflow
app.kubernetes.io/component: api-server
app.kubernetes.io/instance: {{ .Release.Name }}
template:
metadata:
labels:
tier: airflow
component: api-server
release: {{ .Release.Name }}
{{- include "airflow.standardPodLabels" (dict "root" . "component" "api-server") | nindent 8 }}
{{- if or .Values.labels .Values.apiServer.labels }}
{{- mustMerge .Values.apiServer.labels .Values.labels | toYaml | nindent 8 }}
{{- end }}
Expand Down Expand Up @@ -123,7 +117,7 @@ spec:
- podAffinityTerm:
labelSelector:
matchLabels:
component: api-server
app.kubernetes.io/component: api-server
topologyKey: kubernetes.io/hostname
weight: 100
{{- end }}
Expand Down
6 changes: 1 addition & 5 deletions chart/templates/api-server/api-server-hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ kind: HorizontalPodAutoscaler
metadata:
name: {{ include "airflow.fullname" . }}-api-server
labels:
tier: airflow
component: api-server-horizontalpodautoscaler
release: {{ .Release.Name }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
heritage: {{ .Release.Service }}
{{- include "airflow.standardLabels" (dict "root" . "component" "api-server-horizontalpodautoscaler") | nindent 4 }}
deploymentName: {{ .Release.Name }}-api-server
{{- if or .Values.labels .Values.apiServer.labels }}
{{- mustMerge .Values.apiServer.labels .Values.labels | toYaml | nindent 4 }}
Expand Down
6 changes: 1 addition & 5 deletions chart/templates/api-server/api-server-httproute.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ kind: HTTPRoute
metadata:
name: {{ $fullname }}-api-server-httproute
labels:
tier: airflow
component: airflow-api-server-httproute
release: {{ .Release.Name }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
heritage: {{ .Release.Service }}
{{- include "airflow.standardLabels" (dict "root" . "component" "airflow-api-server-httproute") | nindent 4 }}
{{- if or .Values.labels .Values.apiServer.labels .Values.apiServer.httpRoute.labels }}
{{- mustMerge .Values.apiServer.httpRoute.labels .Values.apiServer.labels .Values.labels | toYaml | nindent 4 }}
{{- end }}
Expand Down
6 changes: 1 addition & 5 deletions chart/templates/api-server/api-server-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ kind: Ingress
metadata:
name: {{ $fullname }}-ingress
labels:
tier: airflow
component: airflow-ingress
release: {{ .Release.Name }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
heritage: {{ .Release.Service }}
{{- include "airflow.standardLabels" (dict "root" . "component" "airflow-ingress") | nindent 4 }}
{{- if or .Values.labels .Values.apiServer.labels }}
{{- mustMerge .Values.apiServer.labels .Values.labels | toYaml | nindent 4 }}
{{- end }}
Expand Down
12 changes: 4 additions & 8 deletions chart/templates/api-server/api-server-networkpolicy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,16 @@ kind: NetworkPolicy
metadata:
name: {{ include "airflow.fullname" . }}-api-server-policy
labels:
tier: airflow
component: airflow-api-server-policy
release: {{ .Release.Name }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
heritage: {{ .Release.Service }}
{{- include "airflow.standardLabels" (dict "root" . "component" "airflow-api-server-policy") | nindent 4 }}
{{- if or .Values.labels .Values.apiServer.labels }}
{{- mustMerge .Values.apiServer.labels .Values.labels | toYaml | nindent 4 }}
{{- end }}
spec:
podSelector:
matchLabels:
tier: airflow
component: api-server
release: {{ .Release.Name }}
app.kubernetes.io/part-of: airflow
app.kubernetes.io/component: api-server
app.kubernetes.io/instance: {{ .Release.Name }}
policyTypes:
- Ingress
{{- if .Values.apiServer.networkPolicy.ingress.from }}
Expand Down
12 changes: 4 additions & 8 deletions chart/templates/api-server/api-server-poddisruptionbudget.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,15 @@ kind: PodDisruptionBudget
metadata:
name: {{ include "airflow.fullname" . }}-api-server-pdb
labels:
tier: airflow
component: api-server
release: {{ .Release.Name }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
heritage: {{ .Release.Service }}
{{- include "airflow.standardLabels" (dict "root" . "component" "api-server") | nindent 4 }}
{{- if or .Values.labels .Values.apiServer.labels }}
{{- mustMerge .Values.apiServer.labels .Values.labels | toYaml | nindent 4 }}
{{- end }}
spec:
selector:
matchLabels:
tier: airflow
component: api-server
release: {{ .Release.Name }}
app.kubernetes.io/part-of: airflow
app.kubernetes.io/component: api-server
app.kubernetes.io/instance: {{ .Release.Name }}
{{- toYaml .Values.apiServer.podDisruptionBudget.config | nindent 2 }}
{{- end }}
12 changes: 4 additions & 8 deletions chart/templates/api-server/api-server-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ kind: Service
metadata:
name: {{ include "airflow.fullname" . }}-api-server
labels:
tier: airflow
component: api-server
release: {{ .Release.Name }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
heritage: {{ .Release.Service }}
{{- include "airflow.standardLabels" (dict "root" . "component" "api-server") | nindent 4 }}
{{- if or .Values.labels .Values.apiServer.labels }}
{{- mustMerge .Values.apiServer.labels .Values.labels | toYaml | nindent 4 }}
{{- end }}
Expand All @@ -40,9 +36,9 @@ metadata:
spec:
type: {{ .Values.apiServer.service.type }}
selector:
tier: airflow
component: api-server
release: {{ .Release.Name }}
app.kubernetes.io/part-of: airflow
app.kubernetes.io/component: api-server
app.kubernetes.io/instance: {{ .Release.Name }}
ports:
{{ range .Values.apiServer.service.ports }}
-
Expand Down
6 changes: 1 addition & 5 deletions chart/templates/api-server/api-server-serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ automountServiceAccountToken: {{ .Values.apiServer.serviceAccount.automountServi
metadata:
name: {{ include "apiServer.serviceAccountName" . }}
labels:
tier: airflow
component: api-server
release: {{ .Release.Name }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
heritage: {{ .Release.Service }}
{{- include "airflow.standardLabels" (dict "root" . "component" "api-server") | nindent 4 }}
{{- if or .Values.labels .Values.apiServer.labels }}
{{- mustMerge .Values.apiServer.labels .Values.labels | toYaml | nindent 4 }}
{{- end }}
Expand Down
10 changes: 2 additions & 8 deletions chart/templates/cleanup/cleanup-cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ kind: CronJob
metadata:
name: {{ include "airflow.fullname" . }}-cleanup
labels:
tier: airflow
component: airflow-cleanup-pods
release: {{ .Release.Name }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
heritage: {{ .Release.Service }}
{{- include "airflow.standardLabels" (dict "root" . "component" "airflow-cleanup-pods") | nindent 4 }}
{{- with .Values.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
Expand All @@ -60,9 +56,7 @@ spec:
template:
metadata:
labels:
tier: airflow
component: airflow-cleanup-pods
release: {{ .Release.Name }}
{{- include "airflow.standardPodLabels" (dict "root" . "component" "airflow-cleanup-pods") | nindent 12 }}
{{- if or .Values.labels .Values.cleanup.labels }}
{{- mustMerge .Values.cleanup.labels .Values.labels | toYaml | nindent 12 }}
{{- end }}
Expand Down
6 changes: 1 addition & 5 deletions chart/templates/cleanup/cleanup-serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ automountServiceAccountToken: {{ .Values.cleanup.serviceAccount.automountService
metadata:
name: {{ include "cleanup.serviceAccountName" . }}
labels:
tier: airflow
component: airflow-cleanup-pods
release: {{ .Release.Name }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
heritage: {{ .Release.Service }}
{{- include "airflow.standardLabels" (dict "root" . "component" "airflow-cleanup-pods") | nindent 4 }}
{{- if or .Values.labels .Values.cleanup.labels }}
{{- mustMerge .Values.cleanup.labels .Values.labels | toYaml | nindent 4 }}
{{- end }}
Expand Down
6 changes: 1 addition & 5 deletions chart/templates/configmaps/api-server-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ kind: ConfigMap
metadata:
name: {{ template "airflow_api_server_config_configmap_name" . }}
labels:
tier: airflow
component: config
release: {{ .Release.Name }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
heritage: {{ .Release.Service }}
{{- include "airflow.standardLabels" (dict "root" . "component" "config") | nindent 4 }}
{{- with .Values.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
Expand Down
6 changes: 1 addition & 5 deletions chart/templates/configmaps/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ kind: ConfigMap
metadata:
name: {{ template "airflow_config" . }}
labels:
tier: airflow
component: config
release: {{ .Release.Name }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
heritage: {{ .Release.Service }}
{{- include "airflow.standardLabels" (dict "root" . "component" "config") | nindent 4 }}
{{- with .Values.labels }}
{{- toYaml . | nindent 4 }}
{{- end -}}
Expand Down
5 changes: 1 addition & 4 deletions chart/templates/configmaps/extra-configmaps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ kind: ConfigMap
metadata:
name: {{ tpl $configMapName $Global | quote }}
labels:
tier: airflow
release: {{ $Global.Release.Name }}
chart: "{{ $Global.Chart.Name }}-{{ $Global.Chart.Version }}"
heritage: {{ $Global.Release.Service }}
{{- include "airflow.standardLabels" (dict "root" $Global) | nindent 4 }}
{{- with $Global.Values.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
Expand Down
6 changes: 1 addition & 5 deletions chart/templates/configmaps/otel-collector-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ kind: ConfigMap
metadata:
name: {{ include "airflow.fullname" . }}-otel-collector
labels:
tier: airflow
component: config
release: {{ .Release.Name }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
heritage: {{ .Release.Service }}
{{- include "airflow.standardLabels" (dict "root" . "component" "config") | nindent 4 }}
{{- with .Values.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
Expand Down
6 changes: 1 addition & 5 deletions chart/templates/configmaps/statsd-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ kind: ConfigMap
metadata:
name: {{ include "airflow.fullname" . }}-statsd
labels:
tier: airflow
component: config
release: {{ .Release.Name }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
heritage: {{ .Release.Service }}
{{- include "airflow.standardLabels" (dict "root" . "component" "config") | nindent 4 }}
{{- with .Values.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
Expand Down
Loading