diff --git a/charts/uplink/Chart.yaml b/charts/uplink/Chart.yaml index 92a3cb59b..f4744322a 100644 --- a/charts/uplink/Chart.yaml +++ b/charts/uplink/Chart.yaml @@ -2,9 +2,11 @@ apiVersion: v1 appVersion: "1.0" description: A Helm chart for uplink.jenkins.io name: uplink -version: 0.2.0 +version: 0.3.0 maintainers: - name: olblak - name: dduportal - name: hlemeur - name: smerle +poddisruptionbudget: + minAvailable: 1 diff --git a/charts/uplink/templates/_helpers.tpl b/charts/uplink/templates/_helpers.tpl index dc06527c0..33a3e482b 100644 --- a/charts/uplink/templates/_helpers.tpl +++ b/charts/uplink/templates/_helpers.tpl @@ -31,13 +31,21 @@ Create chart name and version as used by the chart label. {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} {{- end -}} +{{/* +Selector labels +*/}} +{{- define "uplink.selectorLabels" -}} +app.kubernetes.io/name: {{ include "uplink.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + + {{/* Common labels */}} {{- define "uplink.labels" -}} -app.kubernetes.io/name: {{ include "uplink.name" . }} +{{ include "uplink.selectorLabels" . }} helm.sh/chart: {{ include "uplink.chart" . }} -app.kubernetes.io/instance: {{ .Release.Name }} {{- if .Chart.AppVersion }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} diff --git a/charts/uplink/templates/pdb.yaml b/charts/uplink/templates/pdb.yaml new file mode 100644 index 000000000..3e52ae7e2 --- /dev/null +++ b/charts/uplink/templates/pdb.yaml @@ -0,0 +1,18 @@ +{{- if (gt (int .Values.replicaCount) 1) }} +apiVersion: policy/v1 +kind: PodDisruptionBudget +metadata: + name: {{ include "uplink.fullname" . }} + labels: + {{- include "uplink.labels" . | nindent 4 }} +spec: + {{- with .Values.poddisruptionbudget.minAvailable }} + minAvailable: {{ . }} + {{- end }} + {{- with .Values.poddisruptionbudget.maxUnavailable }} + maxUnavailable: {{ . }} + {{- end }} + selector: + matchLabels: + {{- include "uplink.selectorLabels" . | nindent 6 }} +{{- end }} diff --git a/charts/uplink/tests/custom_values_test.yaml b/charts/uplink/tests/custom_values_test.yaml index e2382df02..ba2df3b49 100644 --- a/charts/uplink/tests/custom_values_test.yaml +++ b/charts/uplink/tests/custom_values_test.yaml @@ -1,6 +1,7 @@ suite: test secret.yaml templates: - secret.yaml + - pdb.yaml set: postgresql: url: "example-url" @@ -10,6 +11,7 @@ set: sentry.dsn: "example-dsn" tests: - it: should ensure the secret is created with custom credentials + template: secret.yaml asserts: - isKind: of: Secret @@ -28,3 +30,18 @@ tests: - equal: path: data['sentry.dsn'] value: "ZXhhbXBsZS1kc24=" # Base64 encoded value of "example-dsn" + - it: should ensure the pdb has correct spec + template: pdb.yaml + set: + replicaCount: 2 + poddisruptionbudget.minAvailable: 2 + poddisruptionbudget.maxUnavailable: 1 + asserts: + - isKind: + of: PodDisruptionBudget + - equal: + path: spec.minAvailable + value: 2 + - equal: + path: spec.selector.matchLabels['app.kubernetes.io/name'] + value: "uplink" diff --git a/charts/uplink/tests/defaults_test.yaml b/charts/uplink/tests/defaults_test.yaml index 55b8952e5..1a7f09d02 100644 --- a/charts/uplink/tests/defaults_test.yaml +++ b/charts/uplink/tests/defaults_test.yaml @@ -1,8 +1,10 @@ suite: test default behavior of secret.yaml with default values templates: - secret.yaml + - pdb.yaml tests: - it: should render with default values without error + template: secret.yaml asserts: - isKind: of: Secret @@ -17,3 +19,8 @@ tests: path: data.client.secret - notExists: path: data.sentry.dsn + - it: should not generate any pdb with default values + template: pdb.yaml + asserts: + - hasDocuments: + count: 0