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

🐛 feat(rbac): use real ServiceAccount instead of default #519

Merged
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
2 changes: 2 additions & 0 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ spec:
labels:
control-plane: controller-manager
spec:
serviceAccountName: manager
automountServiceAccountToken: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: is this set to false and best practice, when the default SA is used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand the question correctly, yes, it's best-practice to set this to false when not using a custom serviceAccount to prevent the accidental usage of the default serviceAccount

In general it's best-practice to not use the default serviceAccount anyways

containers:
- command:
- /manager
Expand Down
1 change: 1 addition & 0 deletions config/rbac/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ resources:
- role_binding.yaml
- leader_election_role.yaml
- leader_election_role_binding.yaml
- service_account.yaml
2 changes: 1 addition & 1 deletion config/rbac/leader_election_role_binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ roleRef:
name: leader-election-role
subjects:
- kind: ServiceAccount
name: default
name: manager
namespace: system
2 changes: 1 addition & 1 deletion config/rbac/role_binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ roleRef:
name: manager-role
subjects:
- kind: ServiceAccount
name: default
name: manager
namespace: system
5 changes: 5 additions & 0 deletions config/rbac/service_account.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: manager
namespace: system
2 changes: 2 additions & 0 deletions hack/charts/cluster-api-operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
serviceAccountName: capi-operator-manager
automountServiceAccountToken: true
{{- with .Values.securityContext }}
securityContext:
{{- toYaml . | nindent 8 }}
Expand Down
15 changes: 13 additions & 2 deletions test/e2e/resources/full-chart-install.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
---
# Source: cluster-api-operator/templates/operator-components.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
clusterctl.cluster.x-k8s.io/core: capi-operator
name: capi-operator-manager
namespace: 'default'
---
# Source: cluster-api-operator/templates/operator-components.yaml
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
Expand Down Expand Up @@ -17702,7 +17711,7 @@ roleRef:
name: capi-operator-manager-role
subjects:
- kind: ServiceAccount
name: default
name: capi-operator-manager
namespace: 'default'
---
# Source: cluster-api-operator/templates/operator-components.yaml
Expand Down Expand Up @@ -17767,7 +17776,7 @@ roleRef:
name: capi-operator-leader-election-role
subjects:
- kind: ServiceAccount
name: default
name: capi-operator-manager
namespace: 'default'
---
# Source: cluster-api-operator/templates/operator-components.yaml
Expand Down Expand Up @@ -17818,6 +17827,8 @@ spec:
control-plane: controller-manager
clusterctl.cluster.x-k8s.io/core: capi-operator
spec:
serviceAccountName: capi-operator-manager
automountServiceAccountToken: true
containers:
- args:
- --v=2
Expand Down
Loading