144 lines
4.3 KiB
YAML
144 lines
4.3 KiB
YAML
{{- if .Values.installCrdsOnUpgrade.enabled }}
|
|
{{- $serviceAccountName := printf "%s-install-missing-crds" (include "kuma.name" .) }}
|
|
apiVersion: v1
|
|
kind: ServiceAccount
|
|
metadata:
|
|
name: {{ $serviceAccountName }}
|
|
annotations:
|
|
"helm.sh/hook": "pre-upgrade"
|
|
"helm.sh/hook-weight": "-1"
|
|
"helm.sh/hook-delete-policy": "before-hook-creation,hook-succeeded,hook-failed"
|
|
labels:
|
|
{{- include "kuma.labels" . | nindent 4 }}
|
|
{{- with .Values.installCrdsOnUpgrade.imagePullSecrets }}
|
|
imagePullSecrets:
|
|
{{- range . }}
|
|
- name: {{ . | quote }}
|
|
{{- end }}
|
|
{{- end }}
|
|
---
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
kind: ClusterRole
|
|
metadata:
|
|
name: {{ include "kuma.name" . }}-install-missing-crds
|
|
annotations:
|
|
"helm.sh/hook": "pre-upgrade"
|
|
"helm.sh/hook-weight": "-1"
|
|
"helm.sh/hook-delete-policy": "before-hook-creation,hook-succeeded,hook-failed"
|
|
labels:
|
|
{{- include "kuma.labels" . | nindent 4 }}
|
|
rules:
|
|
- apiGroups:
|
|
- "apiextensions.k8s.io"
|
|
resources:
|
|
- customresourcedefinitions
|
|
verbs:
|
|
- create
|
|
- list
|
|
- get
|
|
---
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
kind: ClusterRoleBinding
|
|
metadata:
|
|
name: {{ include "kuma.name" . }}-install-missing-crds
|
|
annotations:
|
|
"helm.sh/hook": "pre-upgrade"
|
|
"helm.sh/hook-weight": "-1"
|
|
"helm.sh/hook-delete-policy": "before-hook-creation,hook-succeeded,hook-failed"
|
|
labels:
|
|
{{- include "kuma.labels" . | nindent 4 }}
|
|
roleRef:
|
|
apiGroup: rbac.authorization.k8s.io
|
|
kind: ClusterRole
|
|
name: {{ include "kuma.name" . }}-install-missing-crds
|
|
subjects:
|
|
- kind: ServiceAccount
|
|
name: {{ $serviceAccountName }}
|
|
namespace: {{ .Release.Namespace }}
|
|
---
|
|
apiVersion: v1
|
|
kind: ConfigMap
|
|
metadata:
|
|
name: {{ include "kuma.name" . }}-install-missing-crds-scripts
|
|
namespace: {{ .Release.Namespace }}
|
|
annotations:
|
|
"helm.sh/hook": "pre-upgrade"
|
|
"helm.sh/hook-weight": "-1"
|
|
"helm.sh/hook-delete-policy": "before-hook-creation,hook-succeeded"
|
|
labels:
|
|
{{- include "kuma.labels" . | nindent 4 }}
|
|
data:
|
|
install_missing_crds.sh: |
|
|
#!/usr/bin/env sh
|
|
|
|
if [ -s /kuma/missing/crds.yaml ]; then
|
|
echo "/kuma/missing/crds.yaml found and is not empty, adding crds"
|
|
kubectl create -f /kuma/missing/crds.yaml
|
|
else
|
|
echo "/kuma/missing/crds.yaml not found or empty, it looks like there is no missing crds"
|
|
fi
|
|
save_missing_crds.sh: |
|
|
#!/usr/bin/env sh
|
|
|
|
missing_crds="$(kumactl install crds --only-missing)"
|
|
|
|
if [ -n "${missing_crds}" ]; then
|
|
echo "found missing crds - saving to /kuma/missing/crds.yaml"
|
|
echo "${missing_crds}" > /kuma/missing/crds.yaml
|
|
fi
|
|
---
|
|
apiVersion: batch/v1
|
|
kind: Job
|
|
metadata:
|
|
name: {{ template "kuma.name" . }}-install-missing-crds
|
|
namespace: {{ .Release.Namespace }}
|
|
labels:
|
|
{{ include "kuma.labels" . | nindent 4 }}
|
|
annotations:
|
|
"helm.sh/hook": "pre-upgrade"
|
|
"helm.sh/hook-delete-policy": "before-hook-creation,hook-succeeded"
|
|
spec:
|
|
template:
|
|
metadata:
|
|
name: {{ template "kuma.name" . }}-install-missing-crds-job
|
|
labels:
|
|
{{ include "kuma.labels" . | nindent 8 }}
|
|
spec:
|
|
serviceAccountName: {{ $serviceAccountName }}
|
|
{{- with .Values.hooks.nodeSelector }}
|
|
nodeSelector:
|
|
{{ toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
restartPolicy: OnFailure
|
|
containers:
|
|
- name: pre-upgrade-job
|
|
image: {{ include "kubectl.formatImage" (dict "image" .Values.kubectl.image "root" $) | quote }}
|
|
command:
|
|
- '/kuma/scripts/install_missing_crds.sh'
|
|
volumeMounts:
|
|
- mountPath: /kuma/missing
|
|
name: missing-crds
|
|
readOnly: true
|
|
- mountPath: /kuma/scripts
|
|
name: scripts
|
|
readOnly: true
|
|
initContainers:
|
|
- name: pre-upgrade-job-init
|
|
image: {{ include "kuma.formatImage" (dict "image" .Values.kumactl.image "root" $) | quote }}
|
|
volumeMounts:
|
|
- mountPath: /kuma/missing
|
|
name: missing-crds
|
|
- mountPath: /kuma/scripts
|
|
name: scripts
|
|
readOnly: true
|
|
command:
|
|
- '/kuma/scripts/save_missing_crds.sh'
|
|
volumes:
|
|
- name: scripts
|
|
configMap:
|
|
name: {{ include "kuma.name" . }}-install-missing-crds-scripts
|
|
defaultMode: 0755
|
|
- name: missing-crds
|
|
emptyDir: {}
|
|
{{- end }}
|