mirror of https://git.rancher.io/charts
124 lines
2.9 KiB
YAML
124 lines
2.9 KiB
YAML
{{- $namespaces := dict "_0" .Release.Namespace -}}
|
|
apiVersion: batch/v1
|
|
kind: Job
|
|
metadata:
|
|
name: {{ .Chart.Name }}-patch-sa
|
|
namespace: {{ .Release.Namespace }}
|
|
labels:
|
|
app: {{ .Chart.Name }}-patch-sa
|
|
annotations:
|
|
"helm.sh/hook": post-install, post-upgrade
|
|
"helm.sh/hook-delete-policy": hook-succeeded, before-hook-creation
|
|
spec:
|
|
template:
|
|
metadata:
|
|
name: {{ .Chart.Name }}-patch-sa
|
|
labels:
|
|
app: {{ .Chart.Name }}-patch-sa
|
|
spec:
|
|
serviceAccountName: {{ .Chart.Name }}-patch-sa
|
|
securityContext:
|
|
runAsNonRoot: true
|
|
runAsUser: 1000
|
|
restartPolicy: Never
|
|
containers:
|
|
{{- range $_, $ns := $namespaces }}
|
|
- name: patch-sa-{{ $ns }}
|
|
image: {{ template "system_default_registry" $ }}{{ $.Values.global.kubectl.repository }}:{{ $.Values.global.kubectl.tag }}
|
|
imagePullPolicy: {{ $.Values.global.kubectl.pullPolicy }}
|
|
command: ["kubectl", "patch", "serviceaccount", "default", "-p", "{\"automountServiceAccountToken\": false}"]
|
|
args: ["-n", "{{ $ns }}"]
|
|
{{- end }}
|
|
---
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
kind: ClusterRole
|
|
metadata:
|
|
name: {{ .Chart.Name }}-patch-sa
|
|
labels:
|
|
app: {{ .Chart.Name }}-patch-sa
|
|
rules:
|
|
- apiGroups:
|
|
- ""
|
|
resources:
|
|
- serviceaccounts
|
|
verbs: ['get', 'patch']
|
|
{{- if .Values.global.cattle.psp.enabled }}
|
|
- apiGroups: ['policy']
|
|
resources: ['podsecuritypolicies']
|
|
verbs: ['use']
|
|
resourceNames:
|
|
- {{ .Chart.Name }}-patch-sa
|
|
{{- end }}
|
|
---
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
kind: ClusterRoleBinding
|
|
metadata:
|
|
name: {{ .Chart.Name }}-patch-sa
|
|
labels:
|
|
app: {{ .Chart.Name }}-patch-sa
|
|
roleRef:
|
|
apiGroup: rbac.authorization.k8s.io
|
|
kind: ClusterRole
|
|
name: {{ .Chart.Name }}-patch-sa
|
|
subjects:
|
|
- kind: ServiceAccount
|
|
name: {{ .Chart.Name }}-patch-sa
|
|
namespace: {{ .Release.Namespace }}
|
|
---
|
|
apiVersion: v1
|
|
kind: ServiceAccount
|
|
metadata:
|
|
name: {{ .Chart.Name }}-patch-sa
|
|
namespace: {{ .Release.Namespace }}
|
|
labels:
|
|
app: {{ .Chart.Name }}-patch-sa
|
|
---
|
|
{{- if .Capabilities.APIVersions.Has "policy/v1beta1/PodSecurityPolicies" }}
|
|
apiVersion: policy/v1beta1
|
|
kind: PodSecurityPolicy
|
|
metadata:
|
|
name: {{ .Chart.Name }}-patch-sa
|
|
namespace: {{ .Release.Namespace }}
|
|
labels:
|
|
app: {{ .Chart.Name }}-patch-sa
|
|
spec:
|
|
privileged: false
|
|
hostNetwork: false
|
|
hostIPC: false
|
|
hostPID: false
|
|
runAsUser:
|
|
rule: 'MustRunAsNonRoot'
|
|
seLinux:
|
|
rule: 'RunAsAny'
|
|
supplementalGroups:
|
|
rule: 'MustRunAs'
|
|
ranges:
|
|
- min: 1
|
|
max: 65535
|
|
fsGroup:
|
|
rule: 'MustRunAs'
|
|
ranges:
|
|
- min: 1
|
|
max: 65535
|
|
readOnlyRootFilesystem: false
|
|
volumes:
|
|
- 'secret'
|
|
{{- end }}
|
|
{{- range $_, $ns := $namespaces }}
|
|
---
|
|
apiVersion: networking.k8s.io/v1
|
|
kind: NetworkPolicy
|
|
metadata:
|
|
name: default-allow-all
|
|
namespace: {{ $ns }}
|
|
spec:
|
|
podSelector: {}
|
|
ingress:
|
|
- {}
|
|
egress:
|
|
- {}
|
|
policyTypes:
|
|
- Ingress
|
|
- Egress
|
|
{{- end }}
|