Let’s set up role-based access control (RBAC) suitable for running the cluster in production. We will cover roles for using Calico. General RBAC for a production Kubernetes cluster is beyond the scope of this lab.
Using calicoctl
In order for the calicoctl tool to perform version mismatch verification (to make sure the versions for both the cluster and calicoctl are the same), whoever is using it needs to have get access to clusterinformations at the cluster level, i.e., not in a namespace. The network admin role below already has such access, but we will see that we will need to add it to the service owner user we will create turther on.
Network admin
A network admin is a person responsible for configuring and operating the Calico network as a whole. As such, they will need access to all Calico custom resources, as well as some associated Kubernetes resources.
Create the role
To test out the network admin role, we’ll create the key and certificate signing request. Note that we include /O=network-admins in the subject. This places Nik in the network-admins group.
We will sign this certificate using the main Kubernetes CA.
Next, we create a kubeconfig file for Nik.
Bind the role to the group network-admins.
Test Nik’s access by creating a global network set
Verify the global network set exists
Service owner
A service owner is a person responsible for operating one or more services in kubernetes. They should be able to define network policy for their service, but don’t need to view or mofidy any global configuratoin related to Calico.
Define the role
To test out the service owner role, we’ll create a user named Sam and grant then the role.
On the Kubernetes control plane node, create the key and certificate signing request.
We will sign this certificate using the main Kubernetes CA.
Next, we create a kubeconfig file for Sam.
We will limit Sam’s access to a single namespace. Create namespace.
Bind the role to Sam in the namespace
Also bind the calicoctl-user role to sam at the cluster level so that they can use calicoctl properly.
Sam cannot create global network set resources (like Nik can as network admin)
Result
However, Sam can create resources in their own namespace