-
Notifications
You must be signed in to change notification settings - Fork 164
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
Enable rotation of service account tokens #2839
Conversation
af7d263
to
d646ebf
Compare
Signed-off-by: Martin Linkhorst <[email protected]>
Signed-off-by: Martin Linkhorst <[email protected]>
Signed-off-by: Martin Linkhorst <[email protected]>
Signed-off-by: Martin Linkhorst <[email protected]>
0654dc0
to
1fa08bc
Compare
Ultimately, this has to be split into two PRs to make the rollout safe:
|
a1288a8
to
929878e
Compare
Merging this doesn't enable it yet. It needs to be enabled with a config item. |
@mikkeloscar @szuecs I would like to get your opinion on adding This is necessary because the new tokens are mounted with slightly different file permissions (more secure). Previously, inside the container it looked like this (note the file permissions, owner and group): $ ls -la /var/run/secrets/kubernetes.io/serviceaccount/..data/
-rw-r--r-- 1 root root 872 Jan 13 10:17 token So, the token was readable by everybody, including non-root users in the container (e.g. 1000 for skipper would be able to read it) With the new token system token mounts looks like the following (note the slightly different file permission): $ ls -la /var/run/secrets/kubernetes.io/serviceaccount/..data/
-rw-r----- 1 root root 908 Jan 13 09:58 token This means non-root users cannot read the token anymore (e.g. skipper). One way to fix it is to use $ ls -la /meta/aws-iam/..data/
-rw-r--r-- 1 root 1000 69 Jan 13 10:34 role-arn This should not matter since the files were world-readable before. However, the service account token mounts now look like this: $ ls -la /var/run/secrets/kubernetes.io/serviceaccount/..data/
-rw-r----- 1 root 1000 908 Jan 13 09:58 token which means they can now be read by the main process (e.g. skipper, external-dns, etc.) Do you see any issues with this? |
@linki I don't see any issues with changing the file permissions. |
9f40c1d
to
929878e
Compare
If you change all securityContext.fsgroups it seems to be fine for me. |
Signed-off-by: Martin Linkhorst <[email protected]>
6344bed
to
0940b38
Compare
👍 |
1 similar comment
👍 |
Adds timestamps to
ServiceAccountTokens
so that they can be rejected by the API server when they have been expired (viaiat
,exp
andnbf
fields). Tokens will also be rejected once the corresponding Pod terminates.exp
: expires atiat
: issued atnbf
: not valid before (equals issued at)Like before Kubernetes injects ServiceAccountToken mounts into the Pod but they look different now.
The feature uses
projected
volumes under the hood. With this it's possible to retain the original filesystem structure which is three files that are now gathered from different sources.Instead of a ServiceAccount secret with three entries the following is used:
namespace
: via downward APIca.crt
: a shared configmap containing only the root cert of the clustertoken
: new volume typeserviceAccountToken
that provides an expiring tokenCurrently, the "old" secret still exists and contains a non-expiring ServiceAccountToken which still gets accepted by the API server.
The only different for clients is the requirement to reload refreshed tokens from the filesystem before they expire.
Part of: https://github.bus.zalan.do/teapot/issues/issues/1993
Todo:
--controllers
flag on controller manager)client-go
works fine)In order for non-root applications to read the credentials you might need to add the following to your pod spec. This requirement might go away in future versions. Also see here.
Original feature issue: kubernetes/kubernetes#70679