We getting close to going to production with our new clusters based on Microk8s.
Currently we’re hardening the clusters according to the CIS benchmark: https://github.com/aquasecurity/kube-bench
Right now we’re looking at disabling token based authentication, which is enabled by default in Microk8s.
When I remove the kube-apiserver argument: --token-auth-file=${SNAP_DATA}/credentials/known_tokens.csv
and optionally delete the known_tokens.csv file then token based access no longer works.
So far so good.
When disabling tokens, what about the existing users defined in known_tokens.csv?
Do I try to update the admin user so it authenticates via certificate instead?
If yes, how?
If no, should the clusterrole be deleted? I guess it can’t be used anymore if so.
Should I use the more commonly used cluster-admin for a new admin user?
and what about the remaining entries in the file. Will proxy, controller-manager, kubelet and scheduler still work or should their authentication be updated to use certificates?
Kubelet at least must use certificates via the setting the kubelet arguments: –tls-cert-file and –tls-private-key-file
Well, in the lack of responses, here’s our solution (if anyone else is interested):
Setup TLS bootstrapping for kubelet as described in: TLS bootstrapping | Kubernetes
This creates a bootstrap that’ll generate client certificates for kubelet.
Remember to set the following arguments in kubelet config:
and set this in kube-apiserver: --kubelet-certificate-authority=${SNAP_DATA}/certs/ca.crt
Since bootstrapping of certificates is not (yet?) possible for scheduler, kube-controller and proxy then manually create certificates for them including the admin user:
Replace tokens in config files (client.config, controller.config, proxy.config and scheduler.config): cd /var/snap/microk8s/current/credentials
Replace last line containing token with (example for admin, which also could be done in ~/.kube/config):
Disable token based access: vi /var/snap/microk8s/current/args/kube-apiserver
Delete or comment out this line: --token-auth-file=${SNAP_DATA}/credentials/known_tokens.csv