[WIP] Optional support for custom default service account #6586
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This introduces an injection of a custom default service account named after the resource in the format:
default-<kind>-<name>
. E.g. if you deploy aDeployment
with the namemy-app
the serviceAccountName used in the pod will bedefault-deployment-my-app
if you didn't specify a custom serviceAccountName already. This is done for the following kinds:Deployment
,StatefulSet
,StackSet
,Crobjob
.The motivation for this is that we have pods running with
default
service account and reading from the Kubernetes API. This is a leftover from before RBAC was introduced and the intention is that all such use cases be replaced with a custom service account as defined here: https://cloud.docs.zalando.net/howtos/service-accounts/The problem is that since all workloads run with
default
service account by default, it's hard to identify those workloads that run withdefault
AND read from the Kubernetes api. We have metrics from the audit-events: https://teapot.docs.zalando.net/application/kubernetes/#apiserver-client-visibility but the user is alwayssystem:serviceaccounts:<namespace>:default
so it's hard to identify which deployment/statefulset/pods that actually is doing it.By introducing a custom default service account for all main resource types we effectively give each deployment/statefulset/etc. their own identity which will make it simple to identify in the metrics.
The intention is to roll it out behind a flag and only enable it per cluster where there are a need for it because
default
service account is reading from the apiserver. There are some clusters where thedefault
service account is bound to RBAC permissions. In those clusters we can't enable this because we would have to also change the bindings to not drop permissions (not entirely sure if it matters in practice, but would start by just looking into those specific cases).