chart/kustomize-overlays/keda/README.rst
.. Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
.. http://www.apache.org/licenses/LICENSE-2.0
.. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
This overlay produces a KEDA <https://keda.sh/>__ ScaledObject plus a
TriggerAuthentication for the chart-rendered Celery workers. It is a
standalone addition: no resource produced by the Helm chart is modified.
It is the Kustomize equivalent of enabling workers.celery.keda.enabled
in values.yaml, and is the recommended migration path for users who
want to keep Celery autoscaling without relying on chart-side templating.
KEDA <https://keda.sh/docs/latest/deploy/>__ installed in the cluster.<release>-airflow-metadata) reachable
from KEDA's namespace - usually the same namespace as the chart release.TriggerAuthentication/airflow-keda-postgres-auth - reads the metadata
DB connection string directly from the chart's metadata Secret.ScaledObject/airflow-worker - targets the chart-rendered worker
Deployment and scales it based on the count of running and queued task
instances.Reference this overlay from your own kustomization and substitute the release name. A minimal example:
.. code-block:: yaml
# my-overlay/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: airflow
resources:
- github.com/apache/airflow/chart/kustomize-overlays/keda?ref=helm-chart/1.21.0
replacements:
- source:
kind: ConfigMap
name: airflow-overlay-config
fieldPath: data.releaseName
targets:
- select:
kind: ScaledObject
name: airflow-worker
fieldPaths:
- spec.scaleTargetRef.name
options:
delimiter: "-"
index: 0
- select:
kind: TriggerAuthentication
name: airflow-keda-postgres-auth
fieldPaths:
- spec.secretTargetRef.0.name
options:
delimiter: "-"
index: 0
configMapGenerator:
- name: airflow-overlay-config
literals:
- releaseName=airflow
Apply with:
.. code-block:: bash
kubectl apply -k my-overlay/
For a quick test, you can also just sed the placeholder:
.. code-block:: bash
kustomize build chart/kustomize-overlays/keda | \
sed 's/RELEASE-NAME/airflow/g' | \
kubectl apply -f -
The default query mirrors the chart for a single Celery queue named
default with worker_concurrency=16. If you set different values in
your chart install, edit scaledobject.yaml accordingly:
16 with the value of config.celery.worker_concurrency.queue IN ('default') to list every entry from
workers.celery.queue (comma-separated in values.yaml, single-quoted
here).If pgbouncer is enabled and you do not want KEDA polling through it, change
the key field in triggerauthentication.yaml from connection to
kedaConnection. The chart writes a direct-to-Postgres connection string
under that key for exactly this purpose.
If your worker is deployed as a StatefulSet (i.e. you set
workers.celery.persistence.enabled=true), change kind: Deployment to
kind: StatefulSet under scaleTargetRef in scaledobject.yaml.
What the chart currently does ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
When workers.celery.keda.enabled=true, the chart renders:
ScaledObject named <release>-worker targeting the worker
Deployment or StatefulSet.KEDA_DB_CONN (or AIRFLOW_CONN_AIRFLOW_DB) env var, which is
itself sourced from the metadata Secret.workers.celery.keda.* in values.yaml.What this overlay provides ^^^^^^^^^^^^^^^^^^^^^^^^^^
ScaledObject as a standalone resource.TriggerAuthentication that reads the connection string directly
from the chart's metadata Secret. This avoids the indirection through
the worker pod env var, and means the overlay does not need to patch any
chart-rendered resource.How to switch ^^^^^^^^^^^^^
Install or upgrade the chart with workers.celery.keda.enabled=false.
Render this overlay with the substitutions described above.
Apply the rendered manifests.
Confirm KEDA reports ScaledObject Ready and the worker scales
on demand. Useful command:
.. code-block:: bash
kubectl describe scaledobject airflow-worker -n <namespace>
If you previously set custom pollingInterval, cooldownPeriod,
minReplicaCount, maxReplicaCount, advanced, or query under
workers.celery.keda, copy them into scaledobject.yaml before
applying.
This overlay carries status: not-tested. It builds successfully but has
no functional CI coverage yet. Treat it as a starting point and adapt it
to your environment. Feedback and improvements via pull request are very
welcome under the helm-chart refurbish umbrella issue <https://github.com/apache/airflow/issues/64037>__.