karmada/charts/templates/post-install-job.yaml

117 lines
3.7 KiB
YAML

{{- $name := include "karmada.name" . -}}
{{- $namespace := include "karmada.namespace" . -}}
{{- if eq .Values.installMode "host" }}
{{- if eq .Values.certs.mode "custom" }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $name }}-static-resources
namespace: {{ $namespace }}
data:
{{- print "webhook-configuration.yaml: " | nindent 2 }} |-
{{- include "karmada.webhook.configuration" . | nindent 4 }}
{{- print "system-namespace.yaml: " | nindent 2 }} |-
{{- include "karmada.systemNamespace" . | nindent 4 }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $name }}-crds
namespace: {{ $namespace }}
data:
{{ range $path, $bytes := .Files.Glob (printf "_crds/**")}}
{{ $name := base $path }}
{{- (printf "%s: " $name) | nindent 2 }} |-
{{- $.Files.Get $path | nindent 4 }}
{{ end }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $name }}-crds-bases
namespace: {{ $namespace }}
data:
{{ range $path, $bytes := .Files.Glob (printf "_crds/bases/**")}}
{{ $name := base $path }}
{{- (printf "%s: " $name) | nindent 2 }} |-
{{- $.Files.Get $path | nindent 4 }}
{{ end }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $name }}-crds-patches
namespace: {{ $namespace }}
data:
{{- print "webhook_in_clusterresourcebindings.yaml: " | nindent 2 }} |-
{{- include "karmada.crd.patch.webhook.clusterresourcebinding" . | nindent 4 }}
{{- print "webhook_in_resourcebindings.yaml: " | nindent 2 }} |-
{{- include "karmada.crd.patch.webhook.resourcebinding" . | nindent 4 }}
---
{{- end }}
apiVersion: batch/v1
kind: Job
metadata:
name: "{{ $name }}-post-install"
namespace: {{ $namespace }}
labels:
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
app.kubernetes.io/instance: {{ $name | quote }}
app.kubernetes.io/version: {{ .Chart.AppVersion }}
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
annotations:
# This is what defines this resource as a hook. Without this line, the
# job is considered part of the release.
"helm.sh/hook": post-install
"helm.sh/hook-weight": "0"
"helm.sh/hook-delete-policy": hook-succeeded
spec:
parallelism: 1
completions: 1
template:
metadata:
name: {{ $name }}
labels:
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
app.kubernetes.io/instance: {{ $name | quote }}
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
spec:
restartPolicy: Never
containers:
- name: post-install
image: {{ .Values.postInstallJob.postInstallContainerImage }}
command:
- /bin/sh
- -c
- |
bash <<'EOF'
set -ex
kubectl kustomize /crds | kubectl apply --kubeconfig /etc/kubeconfig -f -
kubectl apply -f /static-resources --kubeconfig /etc/kubeconfig
EOF
volumeMounts:
- name: {{ $name }}-crds-bases
mountPath: /crds/bases
- name: {{ $name }}-crds-patches
mountPath: /crds/patches
- name: {{ $name }}-crds
mountPath: /crds
- name: {{ $name }}-static-resources
mountPath: /static-resources
{{ include "karmada.kubeconfig.volumeMount" . | nindent 10 }}
volumes:
- name: {{ $name }}-crds-bases
configMap:
name: {{ $name }}-crds-bases
- name: {{ $name }}-crds-patches
configMap:
name: {{ $name }}-crds-patches
- name: {{ $name }}-crds
configMap:
name: {{ $name }}-crds
- name: {{ $name }}-static-resources
configMap:
name: {{ $name }}-static-resources
{{ include "karmada.kubeconfig.volume" . | nindent 8 }}
{{- end }}