diff --git a/charts/enterprise/metallb/Chart.yaml b/charts/enterprise/metallb/Chart.yaml index 8b38b15e07b..a9906d160bf 100644 --- a/charts/enterprise/metallb/Chart.yaml +++ b/charts/enterprise/metallb/Chart.yaml @@ -22,7 +22,7 @@ sources: - https://github.com/metallb/metallb - https://metallb.universe.tf type: application -version: 5.0.0 +version: 5.0.1 annotations: truecharts.org/catagories: | - core diff --git a/charts/enterprise/metallb/templates/_wait.tpl b/charts/enterprise/metallb/templates/_wait.tpl new file mode 100644 index 00000000000..587f2532329 --- /dev/null +++ b/charts/enterprise/metallb/templates/_wait.tpl @@ -0,0 +1,68 @@ +{{- define "metallb.wait" -}} +{{- $fullName := include "tc.common.names.fullname" . -}} +--- +apiVersion: batch/v1 +kind: Job +metadata: + namespace: {{ .Release.Namespace }} + name: {{ $fullName }}-wait + annotations: + "helm.sh/hook": pre-install, pre-upgrade + "helm.sh/hook-weight": "-1" + "helm.sh/hook-delete-policy": hook-succeeded,before-hook-creation +spec: + template: + spec: + serviceAccountName: {{ $fullName }}-wait + containers: + - name: {{ $fullName }}-wait + image: {{ .Values.ubuntuImage.repository }}:{{ .Values.ubuntuImage.tag }} + command: + - "/bin/sh" + - "-c" + - | + /bin/bash <<'EOF' + kubectl wait --namespace metallb-system --for=condition=ready pod --selector=app=metallb --timeout=90s + EOF + restartPolicy: OnFailure +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: {{ $fullName }}-wait + annotations: + "helm.sh/hook": pre-install, pre-upgrade + "helm.sh/hook-weight": "-2" + "helm.sh/hook-delete-policy": hook-succeeded,before-hook-creation +rules: + - apiGroups: ["*"] + resources: ["pods"] + verbs: ["get", "list", "watch"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: {{ $fullName }}-wait + annotations: + "helm.sh/hook": pre-install, pre-upgrade + "helm.sh/hook-weight": "-2" + "helm.sh/hook-delete-policy": hook-succeeded,before-hook-creation +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: {{ $fullName }}-wait +subjects: + - kind: ServiceAccount + name: {{ $fullName }}-wait + namespace: {{ .Release.Namespace }} +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ $fullName }}-wait + namespace: {{ .Release.Namespace }} + annotations: + "helm.sh/hook": pre-install, pre-upgrade + "helm.sh/hook-weight": "-2" + "helm.sh/hook-delete-policy": hook-succeeded,before-hook-creation +{{- end -}} diff --git a/charts/enterprise/metallb/templates/common.yaml b/charts/enterprise/metallb/templates/common.yaml index 43c8116c6bb..d545fb257f6 100644 --- a/charts/enterprise/metallb/templates/common.yaml +++ b/charts/enterprise/metallb/templates/common.yaml @@ -13,3 +13,5 @@ {{- include "metallb.comm" . }} {{- include "metallb.pool" . }} + +{{- include "metallb.wait" . }}