Skip to content

Commit

Permalink
fix(charts): least privilege on controller rbac (#421)
Browse files Browse the repository at this point in the history
  • Loading branch information
adupays authored Dec 6, 2024
1 parent 827f23f commit 0aee2c5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 37 deletions.
20 changes: 1 addition & 19 deletions deploy/charts/burrito/templates/controllers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ metadata:
{{- toYaml .metadata.annotations | nindent 4 }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
kind: RoleBinding
metadata:
name: burrito-controllers
labels:
Expand All @@ -158,22 +158,4 @@ subjects:
- kind: ServiceAccount
name: burrito-controllers
namespace: {{ $.Release.Namespace }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: burrito-controllers-secrets
namespace: {{ $.Release.Namespace }}
labels:
{{- toYaml .metadata.labels | nindent 4 }}
annotations:
{{- toYaml .metadata.annotations | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: burrito-controllers-secrets
subjects:
- kind: ServiceAccount
name: burrito-controllers
namespace: {{ $.Release.Namespace }}
{{- end }}
20 changes: 2 additions & 18 deletions deploy/charts/burrito/templates/rbac-controllers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ rules:
- list
- create
- update
- watch
- get
- apiGroups:
- config.terraform.padok.cloud
resources:
Expand Down Expand Up @@ -160,21 +162,3 @@ rules:
- update
- patch
- delete
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
app.kubernetes.io/component: controllers
app.kubernetes.io/name: burrito-controllers
app.kubernetes.io/part-of: burrito
name: burrito-controllers-secrets
rules:
- apiGroups:
- ""
resources:
- secrets
verbs:
- watch
- list
- get
20 changes: 20 additions & 0 deletions deploy/charts/burrito/templates/tenant.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{{- $metadataControllers := .Values.controllers.metadata }}

{{- range $tenant := .Values.tenants }}
{{- if $tenant.namespace.create }}
apiVersion: v1
Expand All @@ -13,6 +15,24 @@ spec:
- kubernetes
---
{{- end }}
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: burrito-controllers
labels:
{{- toYaml $metadataControllers.labels | nindent 4 }}
annotations:
{{- toYaml $metadataControllers.annotations | nindent 4 }}
namespace: {{ $tenant.namespace.name }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: burrito-controllers
subjects:
- kind: ServiceAccount
name: burrito-controllers
namespace: {{ $.Release.Namespace }}
---
# Default service account for running Burrito pods, this makes it optional to create at least one service account for each tenant
apiVersion: v1
kind: ServiceAccount
Expand Down

0 comments on commit 0aee2c5

Please sign in to comment.