Skip to content

Commit

Permalink
charts/vault: Fix API versions for k8s < 1.21 for the vault chart (ba…
Browse files Browse the repository at this point in the history
…nk-vaults#1422)

* Fix API versions for k8s < 1.21 for the vault chart

* Bump up vault chart version to v1.14.2

* Updating only the chart version
  • Loading branch information
adamantal authored Sep 16, 2021
1 parent 1bed6b8 commit 5ba0ab7
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 3 deletions.
2 changes: 1 addition & 1 deletion charts/vault/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v1
name: vault
version: 1.14.1
version: 1.14.2
appVersion: 1.14.1
description: A Helm chart for Vault, a tool for managing secrets
home: https://www.vaultproject.io/
Expand Down
42 changes: 42 additions & 0 deletions charts/vault/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,45 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Return the target Kubernetes version.
https://github.com/bitnami/charts/blob/master/bitnami/common/templates/_capabilities.tpl
*/}}
{{- define "vault.capabilities.kubeVersion" -}}
{{- default .Capabilities.KubeVersion.Version .Values.kubeVersion -}}
{{- end -}}

{{/*
Return the appropriate apiVersion for policy.
*/}}
{{- define "vault.capabilities.policy.apiVersion" -}}
{{- if semverCompare "<1.21-0" (include "vault.capabilities.kubeVersion" .) -}}
{{- print "policy/v1beta1" -}}
{{- else -}}
{{- print "policy/v1" -}}
{{- end -}}
{{- end -}}

{{/*
Return the appropriate apiVersion for ingress.
*/}}
{{- define "vault.capabilities.ingress.apiVersion" -}}
{{- if .Values.ingress -}}
{{- if .Values.ingress.apiVersion -}}
{{- .Values.ingress.apiVersion -}}
{{- else if semverCompare "<1.14-0" (include "vault.capabilities.kubeVersion" .) -}}
{{- print "extensions/v1beta1" -}}
{{- else if semverCompare "<1.19-0" (include "vault.capabilities.kubeVersion" .) -}}
{{- print "networking.k8s.io/v1beta1" -}}
{{- else -}}
{{- print "networking.k8s.io/v1" -}}
{{- end }}
{{- else if semverCompare "<1.14-0" (include "vault.capabilities.kubeVersion" .) -}}
{{- print "extensions/v1beta1" -}}
{{- else if semverCompare "<1.19-0" (include "vault.capabilities.kubeVersion" .) -}}
{{- print "networking.k8s.io/v1beta1" -}}
{{- else -}}
{{- print "networking.k8s.io/v1" -}}
{{- end -}}
{{- end -}}
2 changes: 1 addition & 1 deletion charts/vault/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{- if .Values.ingress.enabled -}}
{{- $serviceName := include "vault.fullname" . -}}
{{- $servicePort := .Values.service.port -}}
apiVersion: networking.k8s.io/v1
apiVersion: {{ include "vault.capabilities.ingress.apiVersion" . }}
kind: Ingress
metadata:
name: {{ template "vault.fullname" . }}
Expand Down
2 changes: 1 addition & 1 deletion charts/vault/templates/pdb.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- if .Values.podDisruptionBudget.enabled }}
apiVersion: policy/v1
apiVersion: {{ include "vault.capabilities.policy.apiVersion" . }}
kind: PodDisruptionBudget
metadata:
name: {{ template "vault.fullname" . }}
Expand Down
3 changes: 3 additions & 0 deletions charts/vault/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -309,3 +309,6 @@ podDisruptionBudget:

## Assign a PriorityClassName to pods if set
priorityClassName: ""

# Override cluster version
kubeVersion: ""

0 comments on commit 5ba0ab7

Please sign in to comment.