Config - Service Accounts Flashcards
What kind of accounts exist in Kubernetes? Who are they used by?
- User account (humans: admins, developers)
- Service Account (machines: monitoring application that interacts with Kubernetes API)
What are Service Accounts used for?
- used for authenticating a machine/appliaction that wants to interact with the kube-api
- like a dashboard, that pulls information from the api
How do you create a Service Account?
‘kubectl create serviceaccount < account-name>’
What is created with the creation of the service account and where must it be used? (Deprecated)
- simultaneously with the serviceaccount a token is created
- the token must be used by the external appliaction wanting to interact with the kube api
- Token is stored as a secret object
What is the sequence when a service account is created?
- create service account
- create token
- create secret-object to include the token
- link secret object to service account
What is the token generated with a service account used as and when?
- during REST-API calls
- used as a Authentication Bearer Token
What is different, when the application itself is also hosted on the cluster?
Process can be done easier:
- by mounting the secret-object as a volume in the pod, hosting the third-party application
By default how many service accounts are created?
- -
- one ‘default’ service account per namespace
When are the ‘default’ service accounts used?
- whenever a pod is created, the default secret object is mounted as a volumeMount to that pod
What is the default service account allowed to do?
- limited capabilities
- only allowed to run basic Kubernetes api queries
How do you define a Service Account for a pod?
Pod yaml:
spec: containers: serviceAccountName: dashboard-sa
Testsss
How can you explicitly specify not to use the default service account?
in pod-yaml, under spec:
automountServiceAccountToken: false
What is the purpose of the TokenRequestAPI?
- to provide a way to provision Kubernetes Service Account tokens that are more secure and scalable
- as the default token has no expiery date
What has changed with version 1.22?
- when a new pod is created it no longer receives the default token
- instead a token with a defined lifetime is generated through the TokenRequestAPI by the service account admission controller
- this token is then mounted as a projected volume to the pod
What changed with version 1.24?
- when a service account is created it no longer creates a token / secret object
- you must run the command ‘kubectl create token < service-account-name>’ to generate a token for that service
- it has a expiery date