Skip to content

Commit

Permalink
refact(charts): add pod security policy for cstor charts (#249)
Browse files Browse the repository at this point in the history
Signed-off-by: prateekpandey14 <[email protected]>
  • Loading branch information
prateekpandey14 authored Feb 15, 2021
1 parent 1e03600 commit 509823f
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ name: ci

on:
pull_request:
paths-ignore:
- 'deploy/helm/**'
branches:
# on pull requests to master and release branches
- master
Expand Down
2 changes: 1 addition & 1 deletion deploy/helm/charts/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: CStor-Operator helm chart for Kubernetes
type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
version: 2.5.2
version: 2.5.3
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application.
appVersion: 2.5.0
Expand Down
30 changes: 30 additions & 0 deletions deploy/helm/charts/templates/csi-node-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,34 @@ roleRef:
kind: ClusterRole
name: openebs-cstor-csi-registrar-role
apiGroup: rbac.authorization.k8s.io
{{- if .Values.rbac.pspEnabled }}
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: openebs-cstor-csi-node-role
labels:
{{- include "cstor.csiNode.labels" . | nindent 4 }}
rules:
- apiGroups: ['policy']
resources: ['podsecuritypolicies']
verbs: ['use']
resourceNames:
- openebs-cstor-csi-node-psp
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: openebs-cstor-csi-node-binding
labels:
{{- include "cstor.csiNode.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: openebs-cstor-csi-node-role
subjects:
- kind: ServiceAccount
name: {{ .Values.serviceAccount.csiNode.name }}
namespace: {{ $.Release.Namespace }}
{{- end }}
{{- end }}
2 changes: 0 additions & 2 deletions deploy/helm/charts/templates/csi-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ spec:
- name: {{ .Values.cstorCSIPlugin.name }}
securityContext:
privileged: true
capabilities:
add: ["CAP_MKNOD", "CAP_SYS_ADMIN", "SYS_ADMIN"]
allowPrivilegeEscalation: true
image: "{{ .Values.cstorCSIPlugin.image.registry }}{{ .Values.cstorCSIPlugin.image.repository }}:{{ .Values.cstorCSIPlugin.image.tag }}"
imagePullPolicy: {{ .Values.cstorCSIPlugin.image.pullPolicy }}
Expand Down
24 changes: 24 additions & 0 deletions deploy/helm/charts/templates/psp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{- if .Values.rbac.pspEnabled }}
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
name: openebs-cstor-csi-node-psp
labels:
{{- include "cstor.csiNode.labels" . | nindent 4 }}
spec:
privileged: true
allowPrivilegeEscalation: true
allowedCapabilities: ['*']
volumes: ['*']
hostNetwork: true
hostIPC: true
hostPID: true
runAsUser:
rule: 'RunAsAny'
seLinux:
rule: 'RunAsAny'
supplementalGroups:
rule: 'RunAsAny'
fsGroup:
rule: 'RunAsAny'
{{- end }}

0 comments on commit 509823f

Please sign in to comment.