Skip to content

Commit

Permalink
feat: [PL-56708]: adding PDB function (#123)
Browse files Browse the repository at this point in the history
Signed-off-by: Akash Shrivastava <[email protected]>
  • Loading branch information
avaakash authored Sep 6, 2024
1 parent 96dffe7 commit 8084215
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/common/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: library
# 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: 1.3.54
version: 1.3.55

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
47 changes: 47 additions & 0 deletions src/common/templates/_pdb.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{{/*
Create Pod Distribution Budget Configurations
Usage example:
{{- include "harnesscommon.pdb.renderPodDistributionBudget" . }}
*/}}
{{- define "harnesscommon.pdb.renderPodDistributionBudget" -}}
{{- $ := .ctx }}
{{- if or $.Values.global.pdb.create $.Values.pdb.create }}
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: {{ default $.Chart.Name $.Values.nameOverride | trunc 63 | trimSuffix "-" }}
namespace: {{ $.Release.Namespace }}
{{- if $.Values.global.commonLabels }}
labels: {{- include "harnesscommon.tplvalues.render" ( dict "value" .Values.global.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if $.Values.global.commonAnnotations }}
annotations: {{- include "harnesscommon.tplvalues.render" ( dict "value" .Values.global.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
{{- $minAvailable := "50%" }}
{{- $maxUnavailable := "" }}

{{- if $.Values.global.pdb.minAvailable }}
{{- $minAvailable = $.Values.global.pdb.minAvailable }}
{{- end }}
{{- if $.Values.pdb.minAvailable }}
{{- $minAvailable = $.Values.pdb.minAvailable }}
{{- end }}
{{- if $.Values.global.pdb.maxUnavailable }}
{{- $maxUnavailable = $.Values.global.pdb.maxUnavailable }}
{{- end }}
{{- if $.Values.pdb.maxUnavailable }}
{{- $maxUnavailable = $.Values.pdb.maxUnavailable }}
{{- end }}

{{- if $minAvailable }}
minAvailable: {{ $minAvailable }}
{{- end }}
{{- if $maxUnavailable }}
maxUnavailable: {{ $maxUnavailable }}
{{- end }}
{{- $selectorFunction := printf "%s.selectorLabels" $.Chart.Name }}
selector:
matchLabels: {{ include $selectorFunction $ | nindent 6 }}
{{- end }}
{{- end }}

0 comments on commit 8084215

Please sign in to comment.