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
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.14.2
70 changes: 70 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,76 @@ extraObjects:
restartPolicy: OnFailure
```

## Local Development

### Prerequisites

- **[uv](https://docs.astral.sh/uv/)**: Fast Python package installer and resolver
- **Docker**: Required for running Kubernetes in Docker (kind) during local testing
- **helm**: Required for chart dependencies and templating

### Setting Up Your Development Environment

1. Install uv and python

```bash
# Install uv (if not already installed)
curl -LsSf https://astral.sh/uv/install.sh | sh

# Install the Python version specified in .python-version
uv python install
```

2. Create and activate a virtual environment:

```bash
uv venv
source .venv/bin/activate
```

3. Install dependencies:

```bash
uv sync
```

4. Install pre-commit hooks:

```bash
pre-commit install
```

5. Update Helm chart dependencies:

```bash
helm dep update
```

### Running Tests

The project uses `pytest` for testing the Helm chart. Tests are located in the `tests/` directory.

#### Run pytests:

```bash

# Run specific test file
pytest tests/chart/test_ingress.py

# Run tests matching a pattern
pytest "tests/chart/test_ingress.py::TestIngress::test_airflow_ingress_class_name_with_dag_server[1.31.0]"
```

#### Run pre-commit hooks manually:

```bash
# Run on all files
pre-commit run --all-files

# Run specific hook
pre-commit run ruff-check --all-files
```

## Contributing

Check out [our contributing guide!](CONTRIBUTING.md)
Expand Down
9 changes: 9 additions & 0 deletions bin/install-ci-tools
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ set -e

KIND_VERSION="0.31.0" # https://github.com/kubernetes-sigs/kind/releases
HELM_VERSION="3.20.0" # https://github.com/helm/helm/releases
UV_VERSION="0.10.7" # https://github.com/astral-sh/uv/releases

# Determine the platform we are running on
OS=$(uname | tr '[:upper:]' '[:lower:]')
Expand Down Expand Up @@ -46,4 +47,12 @@ else
chmod +x ./kubectl
fi

echo "Installing uv version ${UV_VERSION}..."
if [[ -f /tmp/bin/uv ]]; then
echo "Already installed in /tmp/bin. Skipping!"
else
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/astral-sh/uv/releases/download/${UV_VERSION}/uv-installer.sh | sh
mv "$HOME/.local/bin/uv" /tmp/bin/
fi

Comment on lines +50 to +57

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed? Was there a problem in CI without this?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this change is strictly related to failing tests (which were failing before this PR, e.g. this run. 'uvis used in allairflow-test` jobs in CircleCI here:

bin/run-ci: line 140: uv: command not found

cd "$CURRENT_DIR"
9 changes: 9 additions & 0 deletions templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ metadata:
{{- end }}
{{- end }}
spec:
{{- if .Values.ingress.ingressClassName }}
ingressClassName: {{ .Values.ingress.ingressClassName }}
{{- end }}
tls:
- secretName: {{ .Values.ingress.tlsSecretName | default "~" }}
hosts:
Expand Down Expand Up @@ -117,6 +120,9 @@ metadata:
{{- end }}
{{- end }}
spec:
{{- if .Values.ingress.ingressClassName }}
ingressClassName: {{ .Values.ingress.ingressClassName }}
{{- end }}
tls:
- secretName: {{ .Values.ingress.tlsSecretName | default "~" }}
hosts:
Expand Down Expand Up @@ -189,6 +195,9 @@ metadata:
{{- end }}
{{- end }}
spec:
{{- if .Values.ingress.ingressClassName }}
ingressClassName: {{ .Values.ingress.ingressClassName }}
{{- end }}
tls:
- secretName: {{ .Values.ingress.tlsSecretName | default "~" }}
hosts:
Expand Down
77 changes: 77 additions & 0 deletions tests/chart/test_ingress.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,80 @@ def test_airflow_ingress_with_dag_server_ingress_annotation_and_tls_secret(self,

assert ingressAnnotations == docs[1]["metadata"]["annotations"]
assert docs[1]["spec"]["tls"][0]["secretName"] == tls_secret_name

def test_airflow_ingress_class_name(self, kube_version):
"""Test airflow ingress with ingressClassName."""
docs = render_chart(
kube_version=kube_version,
show_only="templates/ingress.yaml",
values={
"ingress": {
"enabled": True,
"baseDomain": "example.com",
"ingressClassName": "nginx",
}
},
)
assert len(docs) == 1
doc = docs[0]
assert "Ingress" == doc["kind"]
assert "nginx" == doc["spec"]["ingressClassName"]

def test_airflow_ingress_class_name_with_celery_executor(self, kube_version):
"""Test airflow and flower ingress with ingressClassName and CeleryExecutor."""
docs = render_chart(
kube_version=kube_version,
show_only="templates/ingress.yaml",
values={
"airflow": {"executor": "CeleryExecutor"},
"ingress": {
"enabled": True,
"baseDomain": "example.com",
"ingressClassName": "nginx-internal",
},
},
)
assert len(docs) == 2

# Airflow ingress
assert "Ingress" == docs[0]["kind"]
assert "nginx-internal" == docs[0]["spec"]["ingressClassName"]

# Flower ingress
assert "Ingress" == docs[1]["kind"]
assert "nginx-internal" == docs[1]["spec"]["ingressClassName"]

def test_airflow_ingress_class_name_with_dag_server(self, kube_version):
"""Test dag server ingress with ingressClassName."""
docs = render_chart(
kube_version=kube_version,
show_only="templates/ingress.yaml",
values={
"ingress": {
"baseDomain": "example.com",
"ingressClassName": "custom-ingress",
},
"dagDeploy": {"enabled": True},
},
)

assert len(docs) == 1
assert docs[0]["metadata"]["name"] == "release-name-dag-server-ingress"
assert "custom-ingress" == docs[0]["spec"]["ingressClassName"]

def test_airflow_ingress_class_name_not_set(self, kube_version):
"""Test airflow ingress without ingressClassName (default behavior)."""
docs = render_chart(
kube_version=kube_version,
show_only="templates/ingress.yaml",
values={
"ingress": {
"enabled": True,
"baseDomain": "example.com",
}
},
)
assert len(docs) == 1
doc = docs[0]
assert "Ingress" == doc["kind"]
assert "ingressClassName" not in doc["spec"]
3 changes: 3 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,9 @@ ingress:
# Enable ingress resource
enabled: false

# Enables using a specific ingress class for the deployment. If not set, will default to the cluster default.
ingressClassName: ~

# Enable for cert-manager or kube-lego
acme: false

Expand Down