-
Notifications
You must be signed in to change notification settings - Fork 142
Expand file tree
/
Copy pathhook-upgrade-crds.yaml
More file actions
126 lines (125 loc) · 4.05 KB
/
Copy pathhook-upgrade-crds.yaml
File metadata and controls
126 lines (125 loc) · 4.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
{{- /*
# 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" .Values.controller.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 "-" }}
labels:
app.kubernetes.io/component: controller-manager
{{- if .Values.controller.extraLabels }}
{{- toYaml .Values.controller.extraLabels | nindent 8 }}
{{- end }}
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}}
{{- if .Values.controller.priorityClassName }}
priorityClassName: {{ .Values.controller.priorityClassName }}
{{- end }}
restartPolicy: Never
{{- with .Values.controller.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.controller.tolerations }}
tolerations:
{{- toYaml .| nindent 8 }}
{{- end }}
{{- end -}}