rancher-partner-charts/charts/bitnami/airflow/templates/scheduler/deployment.yaml

216 lines
12 KiB
YAML

{{- $kube := (contains "KubernetesExecutor" .Values.executor) -}}
apiVersion: {{ include "common.capabilities.deployment.apiVersion" . }}
kind: Deployment
metadata:
name: {{ printf "%s-scheduler" (include "common.names.fullname" .) }}
namespace: {{ .Release.Namespace | quote }}
labels: {{- include "common.labels.standard" . | nindent 4 }}
app.kubernetes.io/component: scheduler
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" (dict "value" .Values.commonLabels "context" $) | nindent 4 }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" (dict "value" .Values.commonAnnotations "context" $) | trim | nindent 4 }}
{{- end }}
spec:
selector:
matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }}
app.kubernetes.io/component: scheduler
replicas: {{ .Values.scheduler.replicaCount }}
{{- if .Values.scheduler.updateStrategy }}
strategy: {{- toYaml .Values.scheduler.updateStrategy | nindent 4 }}
{{- end }}
template:
metadata:
labels: {{- include "common.labels.standard" . | nindent 8 }}
app.kubernetes.io/component: scheduler
{{- if .Values.scheduler.podLabels }}
{{- include "common.tplvalues.render" (dict "value" .Values.scheduler.podLabels "context" $) | nindent 8 }}
{{- end }}
annotations:
checksum/configmap: {{ include (print $.Template.BasePath "/config/configmap.yaml") . | sha256sum }}
{{- if .Values.scheduler.podAnnotations }}
{{- include "common.tplvalues.render" (dict "value" .Values.scheduler.podAnnotations "context" $) | nindent 8 }}
{{- end }}
spec:
{{- include "airflow.imagePullSecrets" . | nindent 6 }}
{{- if .Values.scheduler.hostAliases }}
hostAliases: {{- include "common.tplvalues.render" (dict "value" .Values.scheduler.hostAliases "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.scheduler.affinity }}
affinity: {{- include "common.tplvalues.render" (dict "value" .Values.scheduler.affinity "context" $) | nindent 8 }}
{{- else }}
affinity:
podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.scheduler.podAffinityPreset "component" "scheduler" "context" $) | nindent 10 }}
podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.scheduler.podAntiAffinityPreset "component" "scheduler" "context" $) | nindent 10 }}
nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.scheduler.nodeAffinityPreset.type "key" .Values.scheduler.nodeAffinityPreset.key "values" .Values.scheduler.nodeAffinityPreset.values) | nindent 10 }}
{{- end }}
{{- if .Values.scheduler.nodeSelector }}
nodeSelector: {{- include "common.tplvalues.render" (dict "value" .Values.scheduler.nodeSelector "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.scheduler.terminationGracePeriodSeconds }}
terminationGracePeriodSeconds: {{ .Values.scheduler.terminationGracePeriodSeconds }}
{{- end }}
{{- if .Values.scheduler.tolerations }}
tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.scheduler.tolerations "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.scheduler.topologySpreadConstraints }}
topologySpreadConstraints: {{- include "common.tplvalues.render" (dict "value" .Values.scheduler.topologySpreadConstraints "context" .) | nindent 8 }}
{{- end }}
{{- if .Values.scheduler.priorityClassName }}
priorityClassName: {{ .Values.scheduler.priorityClassName | quote }}
{{- end }}
{{- if .Values.scheduler.schedulerName }}
schedulerName: {{ .Values.scheduler.schedulerName }}
{{- end }}
serviceAccountName: {{ include "airflow.serviceAccountName" . }}
{{- if .Values.scheduler.podSecurityContext.enabled }}
securityContext: {{- omit .Values.scheduler.podSecurityContext "enabled" | toYaml | nindent 8 }}
{{- end }}
initContainers:
{{- include "airflow.git.containers.clone" (dict "securityContext" .Values.scheduler.containerSecurityContext "context" $) | trim | nindent 8 }}
{{- if .Values.dags.existingConfigmap }}
{{- include "airflow.loadDAGsInitContainer" (dict "component" "scheduler" "context" . ) | trim | nindent 8 }}
{{- end }}
{{- if .Values.initContainers }}
{{- include "common.tplvalues.render" (dict "value" .Values.initContainers "context" $) | trim | nindent 8 }}
{{- end }}
{{- if .Values.scheduler.initContainers }}
{{- include "common.tplvalues.render" (dict "value" .Values.scheduler.initContainers "context" $) | trim | nindent 8 }}
{{- end }}
containers:
{{- include "airflow.git.containers.sync" (dict "securityContext" .Values.scheduler.containerSecurityContext "context" $) | trim | nindent 8 }}
- name: airflow-scheduler
image: {{ include "airflow.schedulerImage" . | quote }}
imagePullPolicy: {{ .Values.scheduler.image.pullPolicy | quote }}
{{- if .Values.scheduler.containerSecurityContext.enabled }}
securityContext: {{- omit .Values.scheduler.containerSecurityContext "enabled" | toYaml | nindent 12 }}
{{- end }}
{{- if .Values.diagnosticMode.enabled }}
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
{{- else if .Values.scheduler.command }}
command: {{- include "common.tplvalues.render" (dict "value" .Values.scheduler.command "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.diagnosticMode.enabled }}
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
{{- else if .Values.scheduler.args }}
args: {{- include "common.tplvalues.render" (dict "value" .Values.scheduler.args "context" $) | nindent 12 }}
{{- end }}
env:
{{- include "airflow.configure.airflow.common" . | nindent 12 }}
{{- include "airflow.configure.database" . | nindent 12 }}
{{- include "airflow.configure.redis" . | nindent 12 }}
{{- include "airflow.configure.airflow.kubernetesExecutor" . | nindent 12 }}
- name: AIRFLOW_EXECUTOR
value: {{ .Values.executor }}
- name: AIRFLOW_WEBSERVER_HOST
value: {{ include "common.names.fullname" . }}
- name: AIRFLOW_WEBSERVER_PORT_NUMBER
value: {{ .Values.service.ports.http | quote }}
{{- if .Values.extraEnvVars }}
{{- include "common.tplvalues.render" (dict "value" .Values.extraEnvVars "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.scheduler.extraEnvVars }}
{{- include "common.tplvalues.render" (dict "value" .Values.scheduler.extraEnvVars "context" $) | nindent 12 }}
{{- end }}
{{- if or .Values.scheduler.extraEnvVarsCM .Values.scheduler.extraEnvVarsSecret .Values.scheduler.extraEnvVarsSecret .Values.extraEnvVarsCM .Values.extraEnvVarsSecret .Values.extraEnvVarsSecrets }}
envFrom:
{{- if .Values.extraEnvVarsCM }}
- configMapRef:
name: {{ .Values.extraEnvVarsCM }}
{{- end }}
{{- if .Values.extraEnvVarsSecret }}
- secretRef:
name: {{ .Values.extraEnvVarsSecret }}
{{- end }}
{{- if .Values.scheduler.extraEnvVarsCM }}
- configMapRef:
name: {{ .Values.scheduler.extraEnvVarsCM }}
{{- end }}
{{- if .Values.scheduler.extraEnvVarsSecret }}
- secretRef:
name: {{ .Values.scheduler.extraEnvVarsSecret }}
{{- end }}
{{- if .Values.extraEnvVarsSecrets }}
{{- range .Values.extraEnvVarsSecrets }}
- secretRef:
name: {{ . }}
{{- end }}
{{- end }}
{{- if .Values.scheduler.extraEnvVarsSecrets }}
{{- range .Values.scheduler.extraEnvVarsSecrets }}
- secretRef:
name: {{ . }}
{{- end }}
{{- end }}
{{- end }}
{{- if not .Values.diagnosticMode.enabled }}
{{- if .Values.scheduler.customLivenessProbe }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.scheduler.customLivenessProbe "context" $) | trim | nindent 12 }}
{{- end }}
{{- if .Values.scheduler.customReadinessProbe }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.scheduler.customReadinessProbe "context" $) | trim | nindent 12 }}
{{- end }}
{{- if .Values.scheduler.customStartupProbe }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.scheduler.customStartupProbe "context" $) | nindent 12 }}
{{- end }}
{{- end }}
{{- if .Values.scheduler.lifecycleHooks }}
lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.scheduler.lifecycleHooks "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.scheduler.resources }}
resources: {{- toYaml .Values.scheduler.resources | nindent 12 }}
{{- end }}
volumeMounts:
{{- if .Files.Glob "files/dags/*.py" }}
- name: local-dag-files
mountPath: /opt/bitnami/airflow/dags/local
{{- end }}
{{- if .Values.dags.existingConfigmap }}
- name: external-dag-files
mountPath: /opt/bitnami/airflow/dags/external
{{- end }}
{{- if or .Values.configuration .Values.existingConfigmap }}
- name: custom-configuration-file
mountPath: /opt/bitnami/airflow/airflow.cfg
subPath: airflow.cfg
{{- end }}
{{- if $kube }}
- name: custom-configuration-file
mountPath: /opt/bitnami/airflow/pod_template.yaml
subPath: pod_template.yaml
{{- end }}
{{- if .Values.extraVolumeMounts }}
{{- include "common.tplvalues.render" (dict "value" .Values.extraVolumeMounts "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.scheduler.extraVolumeMounts }}
{{- include "common.tplvalues.render" (dict "value" .Values.scheduler.extraVolumeMounts "context" $) | nindent 12 }}
{{- end }}
{{- include "airflow.git.maincontainer.volumeMounts" . | trim | nindent 12 }}
{{- if .Values.sidecars }}
{{- include "common.tplvalues.render" (dict "value" .Values.sidecars "context" $) | trim | nindent 8 }}
{{- end }}
{{- if .Values.scheduler.sidecars }}
{{- include "common.tplvalues.render" (dict "value" .Values.scheduler.sidecars "context" $) | trim | nindent 8 }}
{{- end }}
volumes:
{{- if .Values.dags.existingConfigmap }}
- name: load-external-dag-files
configMap:
name: {{ tpl .Values.dags.existingConfigmap $ }}
- name: external-dag-files
emptyDir: {}
{{- end }}
{{- if or .Values.configuration .Values.existingConfigmap $kube }}
- name: custom-configuration-file
configMap:
name: {{ include "airflow.configMapName" . }}
{{- end }}
{{- if .Values.extraVolumes }}
{{- include "common.tplvalues.render" (dict "value" .Values.extraVolumes "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.scheduler.extraVolumes }}
{{- include "common.tplvalues.render" (dict "value" .Values.scheduler.extraVolumes "context" $) | nindent 8 }}
{{- end }}
{{- include "airflow.git.volumes" . | trim | nindent 8 }}