Factory/kubevirt-chart/templates/crd-upgrade-hooks.yaml

81 lines
2.4 KiB
YAML

apiVersion: v1
kind: ConfigMap
metadata:
namespace: {{ .Release.Namespace }}
name: kubevirt-crd-manifest
{{ template "kubevirt.crdUpgradeHook.annotations" (dict "hookWeight" 1) }}
data:
crd: |-
{{ $.Files.Get "crds/kubevirt.yaml" | nindent 4 }}
---
apiVersion: v1
kind: ServiceAccount
metadata:
namespace: {{ .Release.Namespace }}
name: {{ template "kubevirt.crdUpgradeHook.name" . }}
{{ template "kubevirt.crdUpgradeHook.annotations" (dict "hookWeight" 2) }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ template "kubevirt.crdUpgradeHook.name" . }}
{{ template "kubevirt.crdUpgradeHook.annotations" (dict "hookWeight" 2) }}
rules:
- apiGroups: [ "" ]
resources: [ "configmaps" ]
resourceNames:
- "kubevirt-crd-manifest"
verbs: [ "get" ]
- apiGroups: [ "apiextensions.k8s.io" ]
resources: [ "customresourcedefinitions" ]
resourceNames:
- "kubevirts.kubevirt.io"
verbs: [ "get", "patch" ]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ template "kubevirt.crdUpgradeHook.name" . }}
{{ template "kubevirt.crdUpgradeHook.annotations" (dict "hookWeight" 3) }}
subjects:
- kind: ServiceAccount
namespace: {{ .Release.Namespace }}
name: {{ template "kubevirt.crdUpgradeHook.name" . }}
roleRef:
kind: ClusterRole
name: {{ template "kubevirt.crdUpgradeHook.name" . }}
apiGroup: rbac.authorization.k8s.io
---
apiVersion: batch/v1
kind: Job
metadata:
namespace: {{ .Release.Namespace }}
name: {{ template "kubevirt.crdUpgradeHook.name" . }}
{{ template "kubevirt.crdUpgradeHook.annotations" (dict "hookWeight" 4) }}
spec:
template:
metadata:
name: {{ template "kubevirt.crdUpgradeHook.name" . }}
spec:
serviceAccountName: {{ template "kubevirt.crdUpgradeHook.name" . }}
restartPolicy: {{ .Values.hookRestartPolicy }}
containers:
- name: {{ template "kubevirt.crdUpgradeHook.name" . }}
securityContext:
{{- toYaml .Values.hookSecurityContext | nindent 12 }}
image: {{ .Values.hookImage }}
args:
- apply
- -f
- /etc/manifests/crd.yaml
volumeMounts:
- name: crd-volume
mountPath: /etc/manifests
volumes:
- name: crd-volume
configMap:
name: kubevirt-crd-manifest
items:
- key: crd
path: crd.yaml