Authentication and Authorisation in Kubernetes
Authentication and Authorisation in Kubernetes:
Who wants to talk to kubernetes cluster??? Either a user or an application.
So if an user or application want to talk to kubernetes cluster, He needs auhentication and authorisation.
Authentication:
- If an user needs to talk to k8 cluster, the authentication is provided by kubeconfig file
- For example, if a user named admin wants to talk to k8 cluster, he needs kubernetes config file, the default location of this file is(~/.kube/config)
- This file contains the information of
1.User
2.Cluster
3.Context - Generally admin user, manages who wants to communicate with cluster by creating seperate config files for each user(This is in theory in practice all the developers users the same admin config file,which he shares with all the developers with in the team, by editing namespace)
- If any one want to authenticate to kube api server, he needs 3 things
1.ca.crt(certificate of CA, local to the cluster)
2.user.crt(User certificate signed by ca with hiscertificate and private key)
3.user.key(private key of the user) - Similarly if an application wants authorization, it needs these 3 files which are provided by service accounts
- Service accounts are used by applications to talk to cluster, when we create a service account an associated secret object is always created which contains details of 3 files.
- When we create a namespace, 1 service account is always created with name default and its secret is also created with name default suffixed with randon string, which is used to talk to api server within the cluster.
Authorization:
- For users or service accounts, authorization inside the cluster are managed by roles,rolebindings,clusterroles and clusterrolebindings
- The scope of roles and rolebindings are within namespace and the scope of clusterroles and clusterrolebindings is within cluster to all namespaces that is the only difference
- We will create set of roles which contains exacly 3 fileds
1.apiGroups
2.resources
3.verbs - we will rolebinding we list users who uses above roles.If we have large numner of users it is complex to manage,so in rolebindings we will specify group and add users to the group.
- Creating custom config file for deveoper to access k8 cluster(authentication) and creating roles and role bindings(authorizatiom) - video by meandopensource
- Everything you need to know about service accounts: here
Comments
Post a Comment