This is an automated email from the ASF dual-hosted git repository.
zhangjintao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-helm-chart.git
The following commit(s) were added to refs/heads/master by this push:
new 6cab066 feat: add pod topology spread constraints (#581)
6cab066 is described below
commit 6cab0660d30b78210d153dec38f64285c4102db7
Author: ikatlinsky <[email protected]>
AuthorDate: Tue Jul 25 15:20:12 2023 +0200
feat: add pod topology spread constraints (#581)
---
charts/apisix-dashboard/README.md | 1 +
charts/apisix-dashboard/templates/deployment.yaml | 4 ++++
charts/apisix-dashboard/values.yaml | 4 ++++
charts/apisix-ingress-controller/README.md | 2 ++
charts/apisix-ingress-controller/templates/deployment.yaml | 8 ++++++++
charts/apisix-ingress-controller/values.yaml | 4 ++++
charts/apisix/README.md | 1 +
charts/apisix/ci/topology-constrains-values.yaml | 9 +++++++++
charts/apisix/templates/_pod.tpl | 4 ++++
charts/apisix/values.yaml | 3 +++
10 files changed, 40 insertions(+)
diff --git a/charts/apisix-dashboard/README.md
b/charts/apisix-dashboard/README.md
index 8a4c43d..25e5e03 100644
--- a/charts/apisix-dashboard/README.md
+++ b/charts/apisix-dashboard/README.md
@@ -98,4 +98,5 @@ _See [helm upgrade](https://helm.sh/docs/helm/helm_upgrade/)
for command documen
| serviceAccount.create | bool | `true` | Specifies whether a service account
should be created |
| serviceAccount.name | string | `""` | The name of the service account to
use. If not set and create is true, a name is generated using the fullname
template |
| tolerations | list | `[]` | Tolerations for pod assignment |
+| topologySpreadConstraints | list | `[]` | Topology Spread Constraints for
pod assignment spread across your cluster among failure-domains ref:
https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/#spread-constraints-for-pods
|
| updateStrategy | object | `{}` | Update strategy for apisix dashboard
deployment |
diff --git a/charts/apisix-dashboard/templates/deployment.yaml
b/charts/apisix-dashboard/templates/deployment.yaml
index 2866549..98ccb11 100644
--- a/charts/apisix-dashboard/templates/deployment.yaml
+++ b/charts/apisix-dashboard/templates/deployment.yaml
@@ -102,3 +102,7 @@ spec:
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
+ {{- with .Values.topologySpreadConstraints }}
+ topologySpreadConstraints:
+ {{- tpl (. | toYaml) $ | nindent 8 }}
+ {{- end }}
diff --git a/charts/apisix-dashboard/values.yaml
b/charts/apisix-dashboard/values.yaml
index 89bc9eb..7d8234f 100644
--- a/charts/apisix-dashboard/values.yaml
+++ b/charts/apisix-dashboard/values.yaml
@@ -186,3 +186,7 @@ nodeSelector: {}
tolerations: []
affinity: {}
+
+# -- Topology Spread Constraints for pod assignment spread across your cluster
among failure-domains
+# ref:
https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/#spread-constraints-for-pods
+topologySpreadConstraints: []
diff --git a/charts/apisix-ingress-controller/README.md
b/charts/apisix-ingress-controller/README.md
index ffd6190..4ec592f 100644
--- a/charts/apisix-ingress-controller/README.md
+++ b/charts/apisix-ingress-controller/README.md
@@ -105,6 +105,7 @@ The same for container level, you need to set:
| Key | Type | Default | Description |
|-----|------|---------|-------------|
+| affinity | object | `{}` | |
| autoscaling.enabled | bool | `false` | |
| autoscaling.maxReplicas | int | `100` | |
| autoscaling.minReplicas | int | `1` | |
@@ -164,4 +165,5 @@ The same for container level, you need to set:
| serviceMonitor.labels | object | `{}` | @param serviceMonitor.labels
ServiceMonitor extra labels |
| serviceMonitor.metricRelabelings | object | `{}` | @param
serviceMonitor.metricRelabelings MetricRelabelConfigs to apply to samples
before ingestion. ref:
https://prometheus.io/docs/prometheus/latest/configuration/configuration/#metric_relabel_configs
|
| tolerations | list | `[]` | |
+| topologySpreadConstraints | list | `[]` | Topology Spread Constraints for
pod assignment spread across your cluster among failure-domains ref:
https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/#spread-constraints-for-pods
|
| updateStrategy | object | `{}` | Update strategy for apisix ingress
controller deployment |
diff --git a/charts/apisix-ingress-controller/templates/deployment.yaml
b/charts/apisix-ingress-controller/templates/deployment.yaml
index 34a0b49..b5cd0f1 100644
--- a/charts/apisix-ingress-controller/templates/deployment.yaml
+++ b/charts/apisix-ingress-controller/templates/deployment.yaml
@@ -123,3 +123,11 @@ spec:
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
+ {{- with .Values.affinity }}
+ affinity:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- with .Values.topologySpreadConstraints }}
+ topologySpreadConstraints:
+ {{- tpl (. | toYaml) $ | nindent 8 }}
+ {{- end }}
diff --git a/charts/apisix-ingress-controller/values.yaml
b/charts/apisix-ingress-controller/values.yaml
index 2ffce72..a69bab6 100644
--- a/charts/apisix-ingress-controller/values.yaml
+++ b/charts/apisix-ingress-controller/values.yaml
@@ -166,6 +166,10 @@ updateStrategy: {}
nodeSelector: {}
tolerations: []
+affinity: {}
+# -- Topology Spread Constraints for pod assignment spread across your cluster
among failure-domains
+# ref:
https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/#spread-constraints-for-pods
+topologySpreadConstraints: []
# -- namespace: "ingress-apisix"
diff --git a/charts/apisix/README.md b/charts/apisix/README.md
index 8771b08..864d790 100644
--- a/charts/apisix/README.md
+++ b/charts/apisix/README.md
@@ -97,6 +97,7 @@ The command removes all the Kubernetes components associated
with the chart and
| apisix.setIDFromPodUID | bool | `false` | Use Pod metadata.uid as the APISIX
id. |
| apisix.timezone | string | `""` | timezone is the timezone where apisix
uses. For example: "UTC" or "Asia/Shanghai" This value will be set on apisix
container's environment variable TZ. You may need to set the timezone to be
consistent with your local time zone, otherwise the apisix's logs may used to
retrieve event maybe in wrong timezone. |
| apisix.tolerations | list | `[]` | List of node taints to tolerate |
+| apisix.topologySpreadConstraints | list | `[]` | Topology Spread Constraints
for pod assignment spread across your cluster among failure-domains ref:
https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/#spread-constraints-for-pods
|
| autoscaling.enabled | bool | `false` | |
| autoscaling.maxReplicas | int | `100` | |
| autoscaling.minReplicas | int | `1` | |
diff --git a/charts/apisix/ci/topology-constrains-values.yaml
b/charts/apisix/ci/topology-constrains-values.yaml
new file mode 100644
index 0000000..029316b
--- /dev/null
+++ b/charts/apisix/ci/topology-constrains-values.yaml
@@ -0,0 +1,9 @@
+apisix:
+ replicaCount: 4
+ topologySpreadConstraints:
+ - maxSkew: 1
+ topologyKey: kubernetes.io/hostname
+ whenUnsatisfiable: ScheduleAnyway
+ labelSelector:
+ matchLabels:
+ app.kubernetes.io/name: apisix
diff --git a/charts/apisix/templates/_pod.tpl b/charts/apisix/templates/_pod.tpl
index 136a33f..77d4b8e 100644
--- a/charts/apisix/templates/_pod.tpl
+++ b/charts/apisix/templates/_pod.tpl
@@ -277,4 +277,8 @@ spec:
tolerations:
{{- toYaml . | nindent 4 }}
{{- end }}
+ {{- with .Values.apisix.topologySpreadConstraints }}
+ topologySpreadConstraints:
+ {{- tpl (. | toYaml) $ | nindent 4 }}
+ {{- end }}
{{- end -}}
diff --git a/charts/apisix/values.yaml b/charts/apisix/values.yaml
index 8c06456..0827740 100644
--- a/charts/apisix/values.yaml
+++ b/charts/apisix/values.yaml
@@ -155,6 +155,9 @@ apisix:
tolerations: []
# -- Set affinity for Apache APISIX deploy
affinity: {}
+ # -- Topology Spread Constraints for pod assignment spread across your
cluster among failure-domains
+ # ref:
https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/#spread-constraints-for-pods
+ topologySpreadConstraints: []
# -- timezone is the timezone where apisix uses.
# For example: "UTC" or "Asia/Shanghai"