Authorisation
- Once someone gains access to the cluster, what can they do?
- An admin can perform the following:
kubectl get nodes kubectl get pods kubectl delete node <node_name> - Others also need to access the cluster such as Continuous Delivery things like Jenkins.
- We also need to take into account
DevelopersandBots. We don’t wantDevelopersto runkubectl delete node <node_name> - Want to restrict access to users to their namespaces.
- There are multiple Authorisation Mechanisms available:
- Node
- Users access the
kube apiserverand thekubeletalso accesses thekube apiserver. - The
kubeletReads - Services, Endpoints, Nodes and Pods. - The
kubeletWrites - Node status, Pod status and Events. - The above requests are handled by the Node Authoriser.
- The
kubeletshould be part of the System Nodes group. Any request coming from the System Nodes Group or Authoriser is granted.
- Users access the
- ABAC - Attribute-Based Access Control
- Associate a user / group of users with a set of permissions.
- For example, the
dev-usercreates a load of pods. They are providedCan view PODSs,Can create PODsandCan Delete PODsaccess. - The JSON format would be
"kind": "Policy", "spec": {"user": "dev-user", "namespace": "*", "resource": "pods", "apiGroup": "*"}- The above file is passed into the
kube apiserver.
- The above file is passed into the
- A policy definition file is given to each user / group.
- Any changes needs the policy file to be edited manually and the
kube api-serverto be restarted.
- Any changes needs the policy file to be edited manually and the
- RBAC - instead of giving a user / group a set of permissions, a role is defined.
- For example a
Developerrole has the following permissions:Can view PODs,Can create PODs,Can Delete PODs. - Another example is creating a role for
Securityusers. Permissions would beCan view CSR,Can approve CSR - Any changes are done at the Role level and are then applied to all users.
- For example a
- Webhook - if you want toutsource all authorisation mechanisms.
Open Policy Agentis a third party tool.- Can have Kubernetes make a call to the
Open Policy Agent. - Then the
Open Policy Agentdecides if a user is allowed or not.
- AlwaysAllow - allows all requests without performing authorisation.
- AlwaysDeny - Denies all requests.
- Node
- How do you set the above modes? These are set on the
kube api-server, under--authorization-mode=<mode_name>- If you do not specify the optoin,
AlwaysAllowis set by default. - Can add multiple mode s with commas, for example
--authorization-mode=Node,RBAC,Webhooketc.
- If you do not specify the optoin,
- If there are multiple authorisation settings added, the requests will be filtered in the order the settings have been placed in the
authorization-modeoption.- When a module denies a request, it moves to the next setting in the chain. As soon as a module approves a request, no more checks are done and the user has access to the item.