-
-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Kubernetes RBAC and PodSecurityPolicy (#946)
* Add Kubernetes RBAC and PodSecurityPolicy * Rename pspEnabled to podSecurityEnabled and improve text description * Adjust the logic to use the serviceAccount.name when defined * Fix linting * Narrow down clusterrole/clusterrolebinding to role/rolebinding * Fix linting * Improve documentation Co-authored-by: Tom Kerkhove <kerkhove.tom@gmail.com>
- Loading branch information
1 parent
48b7571
commit 44cedb3
Showing
8 changed files
with
132 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
charts/promitor-agent-scraper/templates/podsecuritypolicy.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{{- if and .Values.rbac.create .Values.rbac.podSecurityPolicyEnabled }} | ||
apiVersion: policy/v1beta1 | ||
kind: PodSecurityPolicy | ||
metadata: | ||
name: {{ template "promitor-agent-scraper.fullname" . }} | ||
labels: | ||
app: {{ template "promitor-agent-scraper.fullname" . }} | ||
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" | ||
release: "{{ .Release.Name }}" | ||
heritage: "{{ .Release.Service }}" | ||
spec: | ||
# Prevents running in privileged mode | ||
privileged: false | ||
# Required to prevent escalations to root. | ||
allowPrivilegeEscalation: false | ||
volumes: | ||
- configMap | ||
- secret | ||
hostNetwork: false | ||
hostIPC: false | ||
hostPID: false | ||
runAsUser: | ||
rule: RunAsAny | ||
seLinux: | ||
rule: RunAsAny | ||
supplementalGroups: | ||
rule: 'MustRunAs' | ||
ranges: | ||
# Forbid adding the root group. | ||
- min: 1 | ||
max: 65535 | ||
fsGroup: | ||
rule: 'MustRunAs' | ||
ranges: | ||
# Forbid adding the root group. | ||
- min: 1 | ||
max: 65535 | ||
readOnlyRootFilesystem: false | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{{- if and .Values.rbac.create .Values.rbac.podSecurityPolicyEnabled }} | ||
apiVersion: rbac.authorization.k8s.io/v1beta1 | ||
kind: Role | ||
metadata: | ||
labels: | ||
app: {{ template "promitor-agent-scraper.name" . }} | ||
chart: {{ template "promitor-agent-scraper.chart" . }} | ||
release: "{{ .Release.Name }}" | ||
heritage: "{{ .Release.Service }}" | ||
name: {{ template "promitor-agent-scraper.fullname" . }} | ||
rules: | ||
- apiGroups: | ||
- policy | ||
resources: | ||
- podsecuritypolicies | ||
resourceNames: | ||
- {{ template "promitor-agent-scraper.fullname" . }} | ||
verbs: | ||
- use | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{{- if and .Values.rbac.create .Values.rbac.podSecurityPolicyEnabled }} | ||
apiVersion: rbac.authorization.k8s.io/v1beta1 | ||
kind: RoleBinding | ||
metadata: | ||
labels: | ||
app: {{ template "promitor-agent-scraper.name" . }} | ||
chart: {{ template "promitor-agent-scraper.chart" . }} | ||
release: "{{ .Release.Name }}" | ||
heritage: "{{ .Release.Service }}" | ||
name: {{ template "promitor-agent-scraper.fullname" . }} | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: Role | ||
name: {{ template "promitor-agent-scraper.fullname" . }} | ||
subjects: | ||
- kind: ServiceAccount | ||
name: {{ template "promitor-agent-scraper.serviceaccountname" . }} | ||
{{- end -}} |
14 changes: 14 additions & 0 deletions
14
charts/promitor-agent-scraper/templates/serviceaccount.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{{- if and .Values.rbac.create .Values.rbac.serviceAccount.create -}} | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: {{ template "promitor-agent-scraper.serviceaccountname" . }} | ||
labels: | ||
app: {{ template "promitor-agent-scraper.name" . }} | ||
chart: {{ template "promitor-agent-scraper.chart" . }} | ||
release: "{{ .Release.Name }}" | ||
heritage: "{{ .Release.Service }}" | ||
{{- if .Values.rbac.serviceAccount.annotations }} | ||
annotations: {{ toYaml .Values.rbac.serviceAccount.annotations | nindent 4 }} | ||
{{- end }} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters