119 lines
3.7 KiB
YAML
119 lines
3.7 KiB
YAML
{{- /*
|
|
# Copyright (c) HashiCorp, Inc.
|
|
# SPDX-License-Identifier: BUSL-1.1
|
|
*/ -}}
|
|
|
|
{{- if .Values.hooks.upgradeCRDs.enabled -}}
|
|
---
|
|
apiVersion: v1
|
|
kind: ServiceAccount
|
|
metadata:
|
|
name: {{ template "vso.chart.fullname" . }}-upgrade-crds
|
|
namespace: {{ .Release.Namespace }}
|
|
labels:
|
|
app.kubernetes.io/component: controller-manager
|
|
{{- include "vso.chart.labels" . | nindent 4 }}
|
|
annotations:
|
|
helm.sh/hook: pre-upgrade
|
|
helm.sh/hook-delete-policy: "hook-succeeded,before-hook-creation"
|
|
helm.sh/hook-weight: "1"
|
|
{{ include "vso.imagePullSecrets" . }}
|
|
---
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
kind: ClusterRole
|
|
metadata:
|
|
name: {{ template "vso.chart.fullname" . }}-upgrade-crds
|
|
labels:
|
|
app.kubernetes.io/component: rbac
|
|
{{ include "vso.chart.labels" . | indent 4 }}
|
|
annotations:
|
|
helm.sh/hook: pre-upgrade
|
|
helm.sh/hook-delete-policy: "hook-succeeded,before-hook-creation"
|
|
helm.sh/hook-weight: "2"
|
|
rules:
|
|
- apiGroups:
|
|
- apiextensions.k8s.io
|
|
resources:
|
|
- customresourcedefinitions
|
|
verbs:
|
|
- create
|
|
- delete
|
|
- get
|
|
- list
|
|
- patch
|
|
- update
|
|
---
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
kind: ClusterRoleBinding
|
|
metadata:
|
|
name: {{ template "vso.chart.fullname" . }}-upgrade-crds
|
|
labels:
|
|
app.kubernetes.io/component: rbac
|
|
{{ include "vso.chart.labels" . | indent 4 }}
|
|
annotations:
|
|
helm.sh/hook: pre-upgrade
|
|
helm.sh/hook-delete-policy: "hook-succeeded,before-hook-creation"
|
|
helm.sh/hook-weight: "2"
|
|
subjects:
|
|
- kind: ServiceAccount
|
|
name: {{ template "vso.chart.fullname" . }}-upgrade-crds
|
|
namespace: {{ .Release.Namespace }}
|
|
roleRef:
|
|
kind: ClusterRole
|
|
name: {{ template "vso.chart.fullname" . }}-upgrade-crds
|
|
apiGroup: rbac.authorization.k8s.io
|
|
---
|
|
apiVersion: batch/v1
|
|
kind: Job
|
|
metadata:
|
|
name: {{ printf "%s-%s" "upgrade-crds" (include "vso.chart.fullname" .) | trunc 63 | trimSuffix "-" }}
|
|
namespace: {{ .Release.Namespace }}
|
|
labels:
|
|
app.kubernetes.io/component: controller-manager
|
|
{{- include "vso.chart.labels" . | nindent 4 }}
|
|
annotations:
|
|
# This is what defines this resource as a hook. Without this line, the
|
|
# job is considered part of the release.
|
|
helm.sh/hook: pre-upgrade
|
|
helm.sh/hook-delete-policy: "hook-succeeded,before-hook-creation"
|
|
helm.sh/hook-weight: "99"
|
|
{{- if .Values.controller.annotations }}
|
|
{{- toYaml .Values.controller.annotations | nindent 4 }}
|
|
{{- end }}
|
|
spec:
|
|
backoffLimit: {{ .Values.hooks.upgradeCRDs.backoffLimit | default 5 }}
|
|
template:
|
|
metadata:
|
|
name: {{ printf "%s-%s" "upgrade-crds" (include "vso.chart.fullname" .) | trunc 63 | trimSuffix "-" }}
|
|
spec:
|
|
serviceAccountName: {{ template "vso.chart.fullname" . }}-upgrade-crds
|
|
securityContext:
|
|
{{- toYaml .Values.controller.podSecurityContext | nindent 8 }}
|
|
containers:
|
|
- name: pre-upgrade-crds
|
|
image: {{ .Values.controller.manager.image.repository }}:{{ .Values.controller.manager.image.tag }}
|
|
imagePullPolicy: {{ .Values.controller.manager.image.pullPolicy }}
|
|
env:
|
|
- name: VSO_UPGRADE_CRDS_TIMEOUT
|
|
value: {{ .Values.hooks.upgradeCRDs.executionTimeout }}
|
|
command:
|
|
- /scripts/upgrade-crds
|
|
{{- with .Values.hooks.resources }}
|
|
resources:
|
|
{{- toYaml . | nindent 10 }}
|
|
{{- end}}
|
|
{{- with .Values.controller.securityContext }}
|
|
securityContext:
|
|
{{- toYaml .| nindent 10 }}
|
|
{{- end}}
|
|
restartPolicy: Never
|
|
{{- with .Values.controller.nodeSelector }}
|
|
nodeSelector:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
{{- with .Values.controller.tolerations }}
|
|
tolerations:
|
|
{{- toYaml .| nindent 8 }}
|
|
{{- end }}
|
|
{{- end -}}
|