Skip to content

Commit

Permalink
Merge pull request #5 from evgkrsk/add-pdb
Browse files Browse the repository at this point in the history
Add PDB support
  • Loading branch information
evgkrsk authored Apr 24, 2022
2 parents 6845cfc + 2eec963 commit a5726e8
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 75 deletions.
4 changes: 4 additions & 0 deletions charts/universal-chart/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Changelog
## 3.1.0 - April 24, 2022

* feat: add PDB support and tests

## 3.0.4 - April 15, 2022

* Fix Helm hooks custom annotations
Expand Down
2 changes: 1 addition & 1 deletion charts/universal-chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
description: Nixys universal Helm chart for deploy your apps to Kubernetes
name: universal-chart
version: 3.0.4
version: 3.1.0
maintainers:
- name: Roman Andreev
email: [email protected]
Expand Down
159 changes: 85 additions & 74 deletions charts/universal-chart/README.md

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions charts/universal-chart/results/pdb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
# Source: universal-chart/templates/pdb.yaml
kind: PodDisruptionBudget
apiVersion: policy/v1
metadata:
name: test-pdb1
namespace: "default"
labels:
app.kubernetes.io/name: test
app.kubernetes.io/instance: test
app.kubernetes.io/managed-by: Helm
foo: bar
spec:
minAvailable: 1
selector:
matchLabels:
app.kubernetes.io/name: test
app.kubernetes.io/instance: test
foo: bar
---
# Source: universal-chart/templates/pdb.yaml
kind: PodDisruptionBudget
apiVersion: policy/v1
metadata:
name: test-pdb2
namespace: "default"
labels:
app.kubernetes.io/name: test
app.kubernetes.io/instance: test
app.kubernetes.io/managed-by: Helm
bar: foo
spec:
maxUnavailable: 2
selector:
matchLabels:
app.kubernetes.io/name: test
app.kubernetes.io/instance: test
bar: foo
14 changes: 14 additions & 0 deletions charts/universal-chart/samples/pdb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pdbs:
pdb1:
labels:
foo: bar
minAvailable: 1
maxUnavailable: 2
extraSelectorLabels:
foo: bar
pdb2:
labels:
bar: foo
maxUnavailable: 2
extraSelectorLabels:
bar: foo
8 changes: 8 additions & 0 deletions charts/universal-chart/templates/helpers/_capabilities.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,11 @@
{{- print "networking.k8s.io/v1" -}}
{{- end }}
{{- end -}}

{{- define "helpers.capabilities.pdb.apiVersion" -}}
{{- if semverCompare "<1.21-0" (include "helpers.capabilities.kubeVersion" $) -}}
{{- print "policy/v1beta1" -}}
{{- else -}}
{{- print "policy/v1" -}}
{{- end -}}
{{- end -}}
24 changes: 24 additions & 0 deletions charts/universal-chart/templates/pdb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{- range $name, $pdb := .Values.pdbs }}
---
kind: PodDisruptionBudget
apiVersion: {{ include "helpers.capabilities.pdb.apiVersion" $ }}
metadata:
name: {{ include "helpers.app.fullname" (dict "name" $name "context" $) }}
namespace: {{ $.Release.Namespace | quote }}
labels:
{{- include "helpers.app.labels" $ | nindent 4 }}
{{- with .labels }}{{- include "helpers.tplvalues.render" (dict "value" . "context" $) | nindent 4 }}{{- end }}
spec:
{{- if not (empty .minAvailable) }}
minAvailable: {{ .minAvailable }}
{{- else }}
{{- if not (empty .maxUnavailable) }}
maxUnavailable: {{ .maxUnavailable }}
{{- end }}
{{- end }}
selector:
matchLabels:
{{- include "helpers.app.selectorLabels" $ | nindent 6 }}
{{- with $.Values.generic.extraSelectorLabels }}{{- include "helpers.tplvalues.render" (dict "value" . "context" $) | nindent 6 }}{{- end -}}
{{- with .extraSelectorLabels }}{{- include "helpers.tplvalues.render" (dict "value" . "context" $) | nindent 6 }}{{- end -}}
{{- end -}}

0 comments on commit a5726e8

Please sign in to comment.