Skip to content
Merged
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
46 changes: 46 additions & 0 deletions chart/templates/webserver/webserver-poddisruptionbudget.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# 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.

################################
## Airflow Webserver PodDisruptionBudget
#################################
{{- if .Values.webserver.podDisruptionBudget.enabled }}
kind: PodDisruptionBudget
{{- if semverCompare ">= 1.21.x" (include "kubeVersion" .) }}
apiVersion: policy/v1
{{- else }}
apiVersion: policy/v1beta1
{{- end }}
metadata:
name: {{ .Release.Name }}-webserver-pdb
labels:
tier: airflow
component: webserver
release: {{ .Release.Name }}
chart: {{ .Chart.Name }}
heritage: {{ .Release.Service }}
{{- with .Values.labels }}
{{ toYaml . | indent 4 }}
{{- end }}
spec:
selector:
matchLabels:
tier: airflow
component: webserver
release: {{ .Release.Name }}
{{ toYaml .Values.webserver.podDisruptionBudget.config | indent 2 }}
{{- end }}
35 changes: 35 additions & 0 deletions chart/tests/test_pdb_webserver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# 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.

import unittest

from tests.helm_template_generator import render_chart


class WebserverPdbTest(unittest.TestCase):
def test_should_pass_validation_with_just_pdb_enabled_v1(self):
render_chart(
values={"webserver": {"podDisruptionBudget": {"enabled": True}}},
show_only=["templates/webserver/webserver-poddisruptionbudget.yaml"],
) # checks that no validation exception is raised

def test_should_pass_validation_with_just_pdb_enabled_v1beta1(self):
render_chart(
values={"webserver": {"podDisruptionBudget": {"enabled": True}}},
show_only=["templates/webserver/webserver-poddisruptionbudget.yaml"],
kubernetes_version='1.16.0',
) # checks that no validation exception is raised
37 changes: 35 additions & 2 deletions chart/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1605,7 +1605,10 @@
"properties": {
"maxUnavailable": {
"description": "Max unavailable pods for scheduler.",
"type": "integer",
"type": [
"integer",
"string"
],
"default": 1
}
}
Expand Down Expand Up @@ -2476,6 +2479,33 @@
}
}
},
"podDisruptionBudget": {
"description": "Webserver pod disruption budget.",
"type": "object",
"additionalProperties": false,
"properties": {
"enabled": {
"description": "Enable pod disruption budget.",
"type": "boolean",
"default": false
},
"config": {
"description": "Disruption budget configuration.",
"type": "object",
"additionalProperties": false,
"properties": {
"maxUnavailable": {
"description": "Max unavailable pods for webserver.",
"type": [
"integer",
"string"
],
"default": 1
}
}
}
}
},
"extraNetworkPolicies": {
"description": "Additional NetworkPolicies as needed (Deprecated - renamed to `webserver.networkPolicy.ingress.from`).",
"type": "array",
Expand Down Expand Up @@ -3296,7 +3326,10 @@
"properties": {
"maxUnavailable": {
"description": "Max unavailable pods for PgBouncer.",
"type": "integer",
"type": [
"integer",
"string"
],
"default": 1
}
}
Expand Down
8 changes: 8 additions & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,14 @@ webserver:
# Annotations to add to webserver kubernetes service account.
annotations: {}

# Webserver pod disruption budget
podDisruptionBudget:
enabled: false

# PDB configuration
config:
maxUnavailable: 1

# Allow overriding Update Strategy for Webserver
strategy: ~

Expand Down