Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(charts): least privilege on controller rbac #421

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading