This commit is contained in:
Laszlo Fogas
2021-02-15 16:22:51 +01:00
parent f097c20ed8
commit 64a680dcdf
12 changed files with 128 additions and 39 deletions
+1 -1
View File
@@ -15,4 +15,4 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.13.2
version: 0.14.0
+15 -2
View File
@@ -103,9 +103,22 @@ spec:
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
{{- if or .Values.spreadAcrossNodes .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- if .Values.spreadAcrossNodes }}
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: "app.kubernetes.io/instance"
operator: In
values:
- {{ .Release.Name }}
topologyKey: "kubernetes.io/hostname"
{{- end }}
{{- if .Values.affinity }}
{{- toYaml .Values.affinity | nindent 8 }}
{{- end }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
+12
View File
@@ -0,0 +1,12 @@
{{- if and (.Values.podDisruptionBudgetEnabled) (gt (.Values.replicas | int64) 1) }}
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: {{ .Release.Name }}
namespace: {{ .Release.Namespace }}
spec:
minAvailable: 1
selector:
matchLabels:
{{- include "helm-chart.selectorLabels" . | nindent 6 }}
{{- end }}
@@ -0,0 +1,27 @@
suite: test deployment
templates:
- deployment.yaml
- configmap.yaml
tests:
- it: Should spread pods across nodes
set:
spreadAccrossNodes: true
asserts:
- equal:
path: spec.template.spec.affinity
value:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: "app.kubernetes.io/instance"
operator: In
values:
- RELEASE-NAME
topologyKey: "kubernetes.io/hostname"
- it: Should not spread pods across nodes
set:
spreadAcrossNodes: false
asserts:
- isNull:
path: spec.template.spec.affinity
+11
View File
@@ -0,0 +1,11 @@
suite: test prometheus rule
templates:
- pdb.yaml
tests:
- it: Should set Pod Disruption budget
set:
replicas: 2
asserts:
- equal:
path: spec.minAvailable
value: 1
+14
View File
@@ -96,6 +96,20 @@
1
]
},
"podDisruptionBudgetEnabled": {
"$id": "#/properties/podDisruptionBudgetEnabled",
"type": "boolean",
"title": "Pod Disruption Budget",
"description": "If pod disruption budgets is enabled, node maintenance won't affect the availability of your application",
"default": true
},
"spreadAcrossNodes": {
"$id": "#/properties/spreadAcrossNodes",
"type": "boolean",
"title": "Spread pods across nodes",
"description": "This setting prevents pods to be placed on the same node",
"default": true
},
"nameOverride": {
"$id": "#/properties/nameOverride",
"type": "string",
+3 -1
View File
@@ -29,7 +29,6 @@ nodeSelector: {}
tolerations: []
affinity: {}
probe:
enabled: false
@@ -51,3 +50,6 @@ debugSidecar:
image: debian:stable-slim
shell: "/bin/bash"
command: "while true; do sleep 30; done;"
podDisruptionBudgetEnabled: true
spreadAcrossNodes: true