Skip to content

Commit

Permalink
feature: allow users to opt out of cluster scoped RBAC (#48)
Browse files Browse the repository at this point in the history
Goldpinger optionally searches for Pods in every namespace, but used to
have unconditional cluster scoped RBAC to do so. Combined with the fact
that it's role refers to an unrestricted PSP, users should be able to
opt out of this cluster scoped binding.

This commit does a couple of things:
- splits `podsecuritypolicy.yaml` into `role.yaml` and
  `rolebinding.yaml`, so it's more like its cluster scoped equivalents
- make both cluster scoped as namespaced role/-binding optional

Signed-off-by: Jorik Jonker <[email protected]>
  • Loading branch information
jonkerj authored Jan 13, 2022
1 parent 68ab86f commit a4d67a1
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 18 deletions.
2 changes: 1 addition & 1 deletion charts/goldpinger/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ name: goldpinger
sources:
- https://github.com/bloomberg/goldpinger
- https://github.com/okgolove/helm-charts
version: 5.0.0
version: 5.0.1
3 changes: 2 additions & 1 deletion charts/goldpinger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ The following table lists the configurable parameters of the Goldpinger chart an
| `image.repository` | Goldpinger image | `bloomberg/goldpinger` |
| `image.tag` | Goldpinger image tag | `3.2.0` |
| `pullPolicy` | Image pull policy | `IfNotPresent` |
| `rbac.create` | Install required rbac clusterrole | `true` |
| `rbac.create` | Install required rbac resources | `true` |
| `rbac.clusterscoped` | Install optional cluster scoped rbac | `true` |
| `serviceAccount.create` | Enable ServiceAccount creation | `true` |
| `serviceAccount.name` | ServiceAccount for Goldpinger pods | `default` |
| `goldpinger.port` | Goldpinger app port listen to | `80` |
Expand Down
2 changes: 1 addition & 1 deletion charts/goldpinger/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.rbac.create }}
{{- if and .Values.rbac.create .Values.rbac.clusterscoped }}
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
Expand Down
2 changes: 1 addition & 1 deletion charts/goldpinger/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.rbac.create }}
{{- if and .Values.rbac.create .Values.rbac.clusterscoped }}
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
Expand Down
21 changes: 21 additions & 0 deletions charts/goldpinger/templates/role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{- if or .Values.podSecurityPolicy.enabled (not .Values.rbac.clusterscoped) }}
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ include "goldpinger.fullname" . }}-pod-security-policy
labels:
{{- include "goldpinger.labels" . | nindent 4 }}
rules:
{{- if not .Values.rbac.clusterscoped }}
- apiGroups: [""]
resources: ["pods"]
verbs: ["list"]
{{- end }}
{{- if .Values.podSecurityPolicy.enabled }}
- apiGroups: ["extensions"]
resources: ["podsecuritypolicies"]
resourceNames: [{{ .Values.podSecurityPolicy.policyName | quote }}]
verbs: ["use"]
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
{{- if .Values.podSecurityPolicy.enabled }}
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ include "goldpinger.fullname" . }}-pod-security-policy
labels:
{{- include "goldpinger.labels" . | nindent 4 }}
rules:
- apiGroups: ["extensions"]
resources: ["podsecuritypolicies"]
resourceNames: [{{ .Values.podSecurityPolicy.policyName | quote }}]
verbs: ["use"]
---
{{- if or .Values.podSecurityPolicy.enabled (not .Values.rbac.clusterscoped) }}
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
Expand Down
1 change: 1 addition & 0 deletions charts/goldpinger/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ image:

rbac:
create: true
clusterscoped: true
serviceAccount:
create: true
name:
Expand Down

0 comments on commit a4d67a1

Please sign in to comment.