CHART NAME: {{ .Chart.Name }}
CHART VERSION: {{ .Chart.Version }}
APP VERSION: {{ .Chart.AppVersion }}

⚠ WARNING: Since August 28th, 2025, only a limited subset of images/charts are available for free.
    Subscribe to Bitnami Secure Images to receive continued support and security updates.
    More info at https://bitnami.com and https://github.com/bitnami/containers/issues/83267

{{- $releaseNamespace := include "common.names.namespace" . }}
{{- $clusterDomain := .Values.clusterDomain }}
{{- $airflowWebServiceName := include "airflow.web.fullname" . }}
{{- $airflowSecretName := include "airflow.secretName" . }}
{{- $baseUrl := (include "airflow.baseUrl" .) }}

** Please be patient while the chart is being deployed **

{{- if .Values.diagnosticMode.enabled }}

The chart has been deployed in diagnostic mode. All probes have been disabled and the command has been overwritten with:

  command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 4 }}
  args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 4 }}

Get the list of pods by executing:

    kubectl get pods --namespace {{ $releaseNamespace }} -l app.kubernetes.io/instance={{ .Release.Name }}

Access the pod you want to debug by executing

    kubectl exec --namespace {{ $releaseNamespace }} -ti <NAME OF THE POD> -- bash

In order to replicate the container startup scripts execute this command:

    /opt/bitnami/scripts/airflow/entrypoint.sh /opt/bitnami/scripts/airflow/run.sh

{{- else }}

{{- if and (contains "127.0.0.1" $baseUrl) (not (eq "ClusterIP" .Values.service.type)) }}
###############################################################################
### ERROR: You did not provide an external URL in your 'helm install' call ###
###############################################################################

This deployment will be incomplete until you configure Airflow with a resolvable
host. To configure Airflow with the URL of your service:

1. Get the Airflow URL by running:

  {{- if eq "NodePort" .Values.service.type }}

    export AIRFLOW_HOST=$(kubectl get nodes --namespace {{ $releaseNamespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
    export AIRFLOW_PORT=$(kubectl get --namespace {{ $releaseNamespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ $airflowWebServiceName }})

  {{- else if eq "LoadBalancer" .Values.service.type }}

  NOTE: It may take a few minutes for the LoadBalancer IP to be available.
        Watch the status with: 'kubectl get svc --namespace {{ $releaseNamespace }} -w {{ $airflowWebServiceName }}'

    export AIRFLOW_HOST=$(kubectl get svc --namespace {{ $releaseNamespace }} {{ $airflowWebServiceName }} --template "{{ "{{ range (index .status.loadBalancer.ingress 0) }}{{ . }}{{ end }}" }}")
    export AIRFLOW_PORT=80

  {{- end }}

2. Complete your Airflow deployment by running:

    {{ include "common.utils.secret.getvalue" (dict "secret" $airflowSecretName "field" "airflow-password" "context" $) }}
    {{ include "common.utils.secret.getvalue" (dict "secret" $airflowSecretName "field" "airflow-fernet-key" "context" $) }}
    {{ include "common.utils.secret.getvalue" (dict "secret" $airflowSecretName "field" "airflow-secret-key" "context" $) }}
    helm upgrade --namespace {{ $releaseNamespace }} {{ .Release.Name }} oci://registry-1.docker.io/bitnamicharts/{{ .Chart.Name }} \
      --set service.type={{ .Values.service.type }} \
      --set web.baseUrl=http://$AIRFLOW_HOST:$AIRFLOW_PORT \
      --set auth.password=$AIRFLOW_PASSWORD \
      --set auth.fernetKey=$AIRFLOW_FERNETKEY \
      --set auth.secretKey=$AIRFLOW_SECRETKEY

{{- else }}

Airflow can be accessed via port {{ .Values.service.ports.http }} on the following DNS name from within your cluster:

    {{ printf "%s.%s.svc.%s" $airflowWebServiceName $releaseNamespace $clusterDomain }}

To connect to Airflow from outside the cluster, perform the following steps:

{{- if .Values.ingress.enabled }}

1. Get the Airflow URL and associate its hostname to your cluster external IP:

    export CLUSTER_IP=$(minikube ip) # On Minikube. Use: `kubectl cluster-info` on others K8s clusters
    echo "Airflow URL: http{{ if .Values.ingress.tls }}s{{ end }}://{{ .Values.ingress.hostname }}"
    echo "$CLUSTER_IP  {{ .Values.ingress.hostname }}" | sudo tee -a /etc/hosts

{{- else if eq .Values.service.type "ClusterIP" }}

1.  Create a port-forward to the service:

    kubectl port-forward --namespace {{ $releaseNamespace }} svc/{{ $airflowWebServiceName }} {{ .Values.service.ports.http }}:{{ .Values.service.ports.http }} &
    echo "Airflow URL: http{{ if .Values.web.tls }}s{{ end }}://127.0.0.1:{{ .Values.service.ports.http }}"

{{- else if eq .Values.service.type "NodePort" }}

1. Obtain the NodePort IP and port:

    export NODE_IP=$(kubectl get nodes --namespace {{ $releaseNamespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
    export NODE_PORT=$(kubectl get svc --namespace {{ $releaseNamespace }} {{ $airflowWebServiceName }} -o jsonpath="{.spec.ports[0].nodePort}")
    echo "Airflow URL: http{{ if .Values.web.tls }}s{{ end }}://${NODE_IP}:$NODE_PORT"

{{- else if eq .Values.service.type "LoadBalancer" }}

1. Obtain the LoadBalancer IP:

  NOTE: It may take a few minutes for the LoadBalancer IP to be available.
        Watch the status with: 'kubectl get svc --namespace {{ .Release.Namespace }} -w {{ $airflowWebServiceName }}'

    export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ $airflowWebServiceName }} --template "{{ "{{ range (index .status.loadBalancer.ingress 0) }}{{ . }}{{ end }}" }}")
    echo "Airflow URL: http{{ if .Values.web.tls }}s{{ end }}://${SERVICE_IP}:{{ .Values.service.ports.http }}"

{{- end }}

2. Open a browser and access Airflow using the obtained URL.

3. Get your Airflow login credentials by running:

    {{ include "common.utils.secret.getvalue" (dict "secret" $airflowSecretName "field" "airflow-password" "context" $) }}
    echo User:     {{ .Values.auth.username }}
    echo Password: $AIRFLOW_PASSWORD

{{- end }}
{{- end }}

{{ include "airflow.validateValues" . }}
{{- include "common.warnings.rollingTag" .Values.image }}
{{- include "common.warnings.rollingTag" .Values.metrics.image }}
{{- include "common.warnings.resources" (dict "sections" (list "scheduler" "web" "worker" "defaultSidecars.syncDAGsPlugins" "defaultInitContainers.loadDAGsPlugins" "metrics") "context" $) }}
{{- include "common.warnings.modifiedImages" (dict "images" (list .Values.image .Values.metrics.image) "context" $) }}
{{- include "common.errors.insecureImages" (dict "images" (list .Values.image .Values.metrics.image) "context" $) }}
