You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by je...@apache.org on 2022/03/10 02:27:34 UTC
[airflow] branch main updated: Add webserver PodDisruptionBudget (#21735)
This is an automated email from the ASF dual-hosted git repository.
jedcunningham pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 161fcbf Add webserver PodDisruptionBudget (#21735)
161fcbf is described below
commit 161fcbfb89c4b2387923954b9ab30ed8a0aee457
Author: Roberto Dedoro <34...@users.noreply.github.com>
AuthorDate: Thu Mar 10 10:26:01 2022 +0800
Add webserver PodDisruptionBudget (#21735)
---
.../webserver/webserver-poddisruptionbudget.yaml | 46 ++++++++++++++++++++++
chart/tests/test_pdb_webserver.py | 35 ++++++++++++++++
chart/values.schema.json | 37 ++++++++++++++++-
chart/values.yaml | 8 ++++
4 files changed, 124 insertions(+), 2 deletions(-)
diff --git a/chart/templates/webserver/webserver-poddisruptionbudget.yaml b/chart/templates/webserver/webserver-poddisruptionbudget.yaml
new file mode 100644
index 0000000..ea5af88
--- /dev/null
+++ b/chart/templates/webserver/webserver-poddisruptionbudget.yaml
@@ -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 }}
diff --git a/chart/tests/test_pdb_webserver.py b/chart/tests/test_pdb_webserver.py
new file mode 100644
index 0000000..a25c3c5
--- /dev/null
+++ b/chart/tests/test_pdb_webserver.py
@@ -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
diff --git a/chart/values.schema.json b/chart/values.schema.json
index cf0d0b8..39c49a4 100644
--- a/chart/values.schema.json
+++ b/chart/values.schema.json
@@ -1605,7 +1605,10 @@
"properties": {
"maxUnavailable": {
"description": "Max unavailable pods for scheduler.",
- "type": "integer",
+ "type": [
+ "integer",
+ "string"
+ ],
"default": 1
}
}
@@ -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",
@@ -3296,7 +3326,10 @@
"properties": {
"maxUnavailable": {
"description": "Max unavailable pods for PgBouncer.",
- "type": "integer",
+ "type": [
+ "integer",
+ "string"
+ ],
"default": 1
}
}
diff --git a/chart/values.yaml b/chart/values.yaml
index b58e9b3..810c1e0 100644
--- a/chart/values.yaml
+++ b/chart/values.yaml
@@ -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: ~