Skip to content

Commit

Permalink
add dagOnlyDeployment feature flag in astronomer helm chart (#2096)
Browse files Browse the repository at this point in the history
* add dagonlydeployment feature in astronomer

* add houston config flag for dagDeployment

* update test case for dag only deploy feature

* fix wrong config location

* fix indent

* fix comments

* Use reusable data. Use obvious test data.

---------

Co-authored-by: Daniel Hoherd <daniel.hoherd@gmail.com>
  • Loading branch information
pgvishnuram and danielhoherd committed Jan 31, 2024
1 parent a458ec6 commit f1ce304
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
17 changes: 17 additions & 0 deletions charts/astronomer/templates/houston/houston-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ data:
deployments:
fluentdIndexPrefix: {{ include "fluentd.IndexPattern" .}}
enableHoustonInternalAuthorization: {{ include "houston.InternalAuthorization" . }}
dagOnlyDeployment: {{ .Values.global.dagOnlyDeployment.enabled }}
namespaceFreeFormEntry: {{ .Values.global.namespaceFreeFormEntry }}
# Airflow chart settings
# Static helm configurations for this chart are found below.
Expand Down Expand Up @@ -133,6 +134,22 @@ data:
{{- end }}
{{- end }}
{{- if .Values.global.dagOnlyDeployment.enabled }}
# enables dag only deployment for airflow deployments
dagDeploy:
enabled: {{ .Values.global.dagOnlyDeployment.enabled }}
images:
dagServer:
repository: {{ (splitList ":" .Values.global.dagOnlyDeployment.image ) | first | quote }}
tag: {{ (splitList ":" .Values.global.dagOnlyDeployment.image ) | last }}
{{- if .Values.global.dagOnlyDeployment.enabled }}
securityContext: {{- .Values.global.dagOnlyDeployment.securityContext | toYaml | nindent 10 }}
{{- end }}
{{- if .Values.global.dagOnlyDeployment.resources }}
resources: {{- .Values.global.dagOnlyDeployment.resources | toYaml | nindent 10 }}
{{- end }}
{{- end }}
# These values get passed directly into the airflow helm deployments
helm:
{{- if and .Values.global.ssl.enabled .Values.global.ssl.mode }}
Expand Down
57 changes: 57 additions & 0 deletions tests/chart_tests/test_astronomer_dag_only_deploy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import pytest
import yaml
from tests import supported_k8s_versions
from tests.chart_tests.helm_template_generator import render_chart


@pytest.mark.parametrize(
"kube_version",
supported_k8s_versions,
)
class TestDagOnlyDeploy:
def test_dagonlydeploy_with_defaults(self, kube_version):
"""Test dagonlydeploy Service defaults."""
docs = render_chart(
kube_version=kube_version,
values={},
show_only=["charts/astronomer/templates/houston/houston-configmap.yaml"],
)

prod = yaml.safe_load(docs[0]["data"]["production.yaml"])
assert prod["deployments"]["dagOnlyDeployment"] is False

def test_dagonlydeploy_config_enabled(self, kube_version):
"""Test dagonlydeploy Service defaults."""
resources = {
"requests": {"memory": "888Mi", "cpu": "666m"},
"limits": {"memory": "999Mi", "cpu": "777m"},
}
docs = render_chart(
kube_version=kube_version,
values={
"global": {
"dagOnlyDeployment": {
"enabled": True,
"image": "someregistry.io/my-custom-image:my-custom-tag",
"securityContext": {"fsGroup": 55555},
"resources": resources,
}
}
},
show_only=["charts/astronomer/templates/houston/houston-configmap.yaml"],
)

doc = docs[0]
prod = yaml.safe_load(doc["data"]["production.yaml"])
assert prod["deployments"]["dagOnlyDeployment"] is True
assert prod["deployments"]["dagDeploy"] == {
"enabled": True,
"images": {
"dagServer": {
"repository": "someregistry.io/my-custom-image",
"tag": "my-custom-tag",
}
},
"securityContext": {"fsGroup": 55555},
"resources": resources,
}
7 changes: 7 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ global:

enableHoustonInternalAuthorization: false

dagOnlyDeployment:
enabled: false
image: quay.io/astronomer/ap-dag-deploy:0.3.1
securityContext:
fsGroup: 50000
resources: {}

logging:
indexNamePrefix: ~

Expand Down

0 comments on commit f1ce304

Please sign in to comment.