In this guide, you will define a Role object that grants permissions specifically for creating and managing Deployment resources within a namespace. You will construct a YAML manifest file for this Role and then apply it to the cluster using kubectl.
Before you start
It is essential that your team is prepared for this verification process.
Make sure that:
Task 5 (node verification) has been successfully completed.
The cluster is healthy with the control plane and worker nodes in a Ready state.
Ensure you are logged in to the control plane node, under the k3s user and in screen session (screen -x group_session).
How to use Role-Based Access Controls (RBAC) in Kubernetes
Set up RBAC by creating the c2sr-sa service account, applying the necessary ClusterRole and ClusterRoleBinding, assigning a service account token, and configuring GHCR secrets.
Step 1: Create a cluster role
Using a text editor like vim or nano, create a new file named cluster-role.yaml and paste the following content into it.
clusterrole.rbac.authorization.k8s.io/c2sr-deployment-role created
Step 3: Verify the cluster role
kubectl get clusterrole
Expected Output:
NAME CREATED AT
admin 2025-06-19T15:39:07Z
c2sr-deployment-role 2025-06-20T02:43:22Z
cluster-admin 2025-06-19T15:39:07Z
clustercidrs-node 2025-06-19T15:39:13Z
edit 2025-06-19T15:39:07Z
k3s-cloud-controller-manager 2025-06-19T15:39:11Z
Seeing your role listed alongside the default system roles (admin, cluster-admin, etc.) confirms that the apply command was successful and Kubernetes has stored your new role definition.
Custom ClusterRole Defined: A new, cluster-wide set of permissions (c2sr-deployment-role) was successfully created and applied, defining a reusable set of extensive permissions for deployment tasks.
Service Account Provisioned: A dedicated identity for automation, the c2sr-sa ServiceAccount, was successfully created within the default namespace.
RBAC Permissions Granted: A ClusterRoleBinding was created to successfully link the c2sr-deployment-role to the c2sr-sa ServiceAccount, granting it the defined permissions across the entire cluster.
Authentication Token Generated: A non-expiring token Secret was created and associated with the c2sr-sa ServiceAccount, providing a durable credential required for external systems to authenticate.
Credentials Retrieved: The full secret object, including the authentication token, has been retrieved and saved for use in the next stage of the project.
The cluster's Role-Based Access Control (RBAC) system has been successfully configured to support external automation. A complete security principal—consisting of an identity (ServiceAccount), permissions (ClusterRole), a link between them (ClusterRoleBinding), and a credential (Secret token)—is now fully provisioned.
The system is prepared for the integration of a CI/CD pipeline, which can now be configured with the retrieved token to securely authenticate and manage deployments on the cluster.
Reflection
Please take a moment to write down any questions, issues, or doubts you encountered during this milestone. This will help guide the next discussion and ensure everyone is on the same page before moving forward.
Next Steps
All group members should have a copy of the c2sr-sa-token yaml. It will be used in the next tasks.
exit (ctrl + a then d) from the screen session.
exit from the ssh session on the control plane.
Return to the terminal on your computer.
Rejoin the common Discord lobby to await further instructions or support your peers.