DEV Community

Kubernetes: Certificates, Tokens, Authentication and Service Accounts

Daniel Albuschat on May 19, 2019

Mostly for personal/learning experiences, I have created quite a few Kubernetes clusters, such as the one on my Raspberry Pi rack. I also created t...
Collapse
 
mwtzzz profile image
Michael Martinez

You're Unvalidated Assumption is correct. Kubernetes does not have a database to store usernames, so you can refer to any arbitrary username you want in the Subject of your certificate, k8s will make authorization decisions based on role/bindings given that username.

Collapse
 
qbaze profile image
qbaze

Very useful! Thanks.

Collapse
 
amrutaranade profile image
Amruta Ranade

Oh this is so helpful! I am experimenting with Kubernetes - trying out different auth/custom CA cert scenarios. Thanks for sharing your experience :)

Collapse
 
danielkun profile image
Daniel Albuschat

Thanks!
I have been told by multiple sources, however, that using Service Account tokens isn't a silver bullet and not recommended, either O_o

The reason is that the tokens are "ephemeral", whatever that means. I have yet to find out when/why they will be recreated. I personally don't see the disadvantage to certs, though, since you should totally periodically roll your credentials anyways, so I'd suggest to do this with certs, too. But it turns out, as described in the article, that rolling (and therefore invalidating the old) certs is a huge PITA.

It's all still a mystery to me.

Collapse
 
valiantljk profile image
jialin

'-A' unknown flag

Collapse
 
danielkun profile image
Daniel Albuschat

Hey jialin,

the -A flag was introduced in a recent kubectl version. I guess you are using a previous version, so you'd need to update to use kubectl -A.

Greetings!