mirror of https://git.rancher.io/charts
110 lines
3.1 KiB
YAML
110 lines
3.1 KiB
YAML
{{- if .Values.postInstall.labelNamespace.enabled }}
|
|
apiVersion: batch/v1
|
|
kind: Job
|
|
metadata:
|
|
name: gatekeeper-update-namespace-label
|
|
labels:
|
|
app: '{{ template "gatekeeper.name" . }}'
|
|
chart: '{{ template "gatekeeper.name" . }}'
|
|
gatekeeper.sh/system: "yes"
|
|
heritage: '{{ .Release.Service }}'
|
|
release: '{{ .Release.Name }}'
|
|
annotations:
|
|
"helm.sh/hook": post-install
|
|
"helm.sh/hook-weight": "-5"
|
|
"helm.sh/hook-delete-policy": hook-succeeded,before-hook-creation
|
|
spec:
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: '{{ template "gatekeeper.name" . }}'
|
|
release: '{{ .Release.Name }}'
|
|
spec:
|
|
restartPolicy: OnFailure
|
|
{{- if .Values.postInstall.labelNamespace.image.pullSecrets }}
|
|
imagePullSecrets:
|
|
{{- .Values.postInstall.labelNamespace.image.pullSecrets | toYaml | nindent 12 }}
|
|
{{- end }}
|
|
serviceAccount: gatekeeper-update-namespace-label
|
|
nodeSelector:
|
|
kubernetes.io/os: linux
|
|
containers:
|
|
- name: kubectl-label
|
|
image: '{{ template "system_default_registry" . }}{{ .Values.postInstall.labelNamespace.image.repository }}:{{ .Values.postInstall.labelNamespace.image.tag }}'
|
|
imagePullPolicy: {{ .Values.postInstall.labelNamespace.image.pullPolicy }}
|
|
args:
|
|
- label
|
|
- ns
|
|
- {{ .Release.Namespace }}
|
|
- admission.gatekeeper.sh/ignore=no-self-managing
|
|
- --overwrite
|
|
securityContext:
|
|
allowPrivilegeEscalation: false
|
|
capabilities:
|
|
drop:
|
|
- all
|
|
readOnlyRootFilesystem: true
|
|
runAsGroup: 999
|
|
runAsNonRoot: true
|
|
runAsUser: 1000
|
|
---
|
|
apiVersion: v1
|
|
kind: ServiceAccount
|
|
metadata:
|
|
name: gatekeeper-update-namespace-label
|
|
labels:
|
|
release: {{ .Release.Name }}
|
|
heritage: {{ .Release.Service }}
|
|
annotations:
|
|
"helm.sh/hook": post-install
|
|
"helm.sh/hook-weight": "-5"
|
|
"helm.sh/hook-delete-policy": hook-succeeded,before-hook-creation
|
|
---
|
|
{{- if .Values.rbac.create }}
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
kind: Role
|
|
metadata:
|
|
name: gatekeeper-update-namespace-label
|
|
labels:
|
|
release: {{ .Release.Name }}
|
|
heritage: {{ .Release.Service }}
|
|
annotations:
|
|
"helm.sh/hook": post-install
|
|
"helm.sh/hook-weight": "-5"
|
|
"helm.sh/hook-delete-policy": hook-succeeded,before-hook-creation
|
|
rules:
|
|
- apiGroups:
|
|
- ""
|
|
resources:
|
|
- namespaces
|
|
verbs:
|
|
- get
|
|
- update
|
|
- patch
|
|
resourceNames:
|
|
- {{ .Release.Namespace }}
|
|
{{- end }}
|
|
---
|
|
{{- if .Values.rbac.create }}
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
kind: RoleBinding
|
|
metadata:
|
|
name: gatekeeper-update-namespace-label
|
|
labels:
|
|
release: {{ .Release.Name }}
|
|
heritage: {{ .Release.Service }}
|
|
annotations:
|
|
"helm.sh/hook": post-install
|
|
"helm.sh/hook-weight": "-5"
|
|
"helm.sh/hook-delete-policy": hook-succeeded,before-hook-creation
|
|
roleRef:
|
|
apiGroup: rbac.authorization.k8s.io
|
|
kind: Role
|
|
name: gatekeeper-update-namespace-label
|
|
subjects:
|
|
- kind: ServiceAccount
|
|
name: gatekeeper-update-namespace-label
|
|
namespace: {{ .Release.Namespace | quote }}
|
|
{{- end }}
|
|
{{- end }}
|