• Login
Saturday, March 7, 2026
The Cloud Guru
  • Home
  • AWS
  • Data Center
  • GCP
  • Technology
  • Tutorials
  • Blog
    • Blog
    • Reviews
No Result
View All Result
Saturday, March 7, 2026
  • Home
  • AWS
  • Data Center
  • GCP
  • Technology
  • Tutorials
  • Blog
    • Blog
    • Reviews
No Result
View All Result
The Cloud Guru
No Result
View All Result

Controlling Access in Kubernetes with RBAC

Team TCG by Team TCG
October 7, 2022
in Kubernetes
0 0
0
Home Kubernetes
0
SHARES
9
VIEWS
Share on FacebookShare on Twitter

Introduction

Role-based access control is an important component when it comes to managing a Kubernetes cluster securely. The more users and automated processes there are that need to interface with the Kubernetes API, the more important controlling access becomes. In this lab, you will have the opportunity to practice your skills with the Kubernetes RBAC system by implementing your own RBAC permissions to appropriately limit user access.

Solution

Log in to the lab server using the credentials provided:

ssh cloud_user@<PUBLIC_IP_ADDRESS>

Note: When copying and pasting code into Vim from the lab guide, first enter :set paste (and then i to enter insert mode) to avoid adding unnecessary spaces and hashes.

Create a Role for the dev User

  1. Test access by attempting to list pods as the dev user:kubectl get pods -n beebox-mobile --kubeconfig dev-k8s-config We’ll get an error message.
  2. Create a role spec file:vi pod-reader-role.yml
  3. Add the following to the file:apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: namespace: beebox-mobile name: pod-reader rules: – apiGroups: [“”] resources: [“pods”, “pods/log”] verbs: [“get”, “watch”, “list”]
  4. Save and exit the file by pressing Escape followed by :wq.
  5. Create the role:kubectl apply -f pod-reader-role.yml

Bind the Role to the dev User and Verify Your Setup Works

  1. Create the RoleBinding spec file:vi pod-reader-rolebinding.yml
  2. Add the following to the file:apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: pod-reader namespace: beebox-mobile subjects: – kind: User name: dev apiGroup: rbac.authorization.k8s.io roleRef: kind: Role name: pod-reader apiGroup: rbac.authorization.k8s.io
  3. Save and exit the file by pressing Escape followed by :wq.
  4. Create the RoleBinding:kubectl apply -f pod-reader-rolebinding.yml
  5. Test access again to verify you can successfully list pods:kubectl get pods -n beebox-mobile --kubeconfig dev-k8s-config This time, we should see a list of pods (there’s just one).
  6. Verify the dev user can read pod logs:kubectl logs beebox-auth -n beebox-mobile --kubeconfig dev-k8s-config We’ll get an Auth processing... message.
  7. Verify the dev user cannot make changes by attempting to delete a pod:kubectl delete pod beebox-auth -n beebox-mobile --kubeconfig dev-k8s-config We’ll get an error, which is what we want.
Tags: How toTutorials
Previous Post

Backing up and Restoring Kubernetes Data in etcd

Next Post

Reduce Storage Costs with EFS

Team TCG

Team TCG

Related Posts

GCP

Distributed Load Testing Using Kubernetes

Activate Cloud Shell Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB...

by Team TCG
October 1, 2023
GCP

Deploying Memcached on Kubernetes Engine

Overview In this lab, you'll learn how to deploy a cluster of distributed Memcached servers on Kubernetes Engine using Kubernetes, Helm, and Mcrouter. Memcached is one of...

by Team TCG
October 1, 2023
GCP

Continuous Delivery Pipelines with Spinnaker and Kubernetes Engine

Overview This post shows you how to create a continuous delivery pipeline using Google Kubernetes Engine, Google Cloud Source Repositories,...

by Team TCG
October 1, 2023
2 Minute Tutorials

Setting up Jenkins on Kubernetes Engine on GCP

Activate Cloud Shell Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB...

by Team TCG
October 1, 2023
books

Protected: Kubernetes

by Team TCG
May 15, 2023
Kubernetes

Backing up and Restoring Kubernetes Data in etcd

Backing up and Restoring Kubernetes Data in etcd

by Team TCG
October 2, 2022
Next Post

Reduce Storage Costs with EFS

  • Trending
  • Comments
  • Latest

Azure Compliance: Policy, Blueprints, and Compliance Manager

September 21, 2025

Understanding Azure Subscriptions and Resource Groups

December 23, 2024

Azure Sphere: Securing IoT Devices

October 21, 2025

Azure Case Study: How Spotify Uses Azure

January 15, 2025

AWS SnowMobile

0

Passwordless Login Using SSH Keygen in 5 Easy Steps

0

Create a new swap partition on RHEL system

0

Configuring NTP using chrony

0

Cloud Monitoring: CloudWatch vs Azure Monitor vs Operations Suite

December 31, 2025

Infrastructure as Code: CloudFormation vs ARM Templates vs Deployment Manager

December 31, 2025

Cloud CLI Tools: AWS CLI vs Azure CLI vs gcloud

December 30, 2025

Hybrid Cloud Solutions: AWS Outposts, Azure Stack, and GCP Anthos

December 30, 2025

Recommended

Cloud Monitoring: CloudWatch vs Azure Monitor vs Operations Suite

December 31, 2025

Infrastructure as Code: CloudFormation vs ARM Templates vs Deployment Manager

December 31, 2025

Cloud CLI Tools: AWS CLI vs Azure CLI vs gcloud

December 30, 2025

Hybrid Cloud Solutions: AWS Outposts, Azure Stack, and GCP Anthos

December 30, 2025

About Us

Let's Simplify the cloud for everyone. Whether you are a technologist or a management guru, you will find something very interesting. We promise.

Categories

  • 2 Minute Tutorials (7)
  • AI (3)
  • Ansible (1)
  • Architecture (3)
  • Artificial Intelligence (3)
  • AWS (508)
  • Azure (3)
  • books (2)
  • Consolidation (4)
  • Containers (1)
  • Data Analytics (1)
  • Data Center (11)
  • Design (1)
  • GCP (13)
  • HOW To's (17)
  • Innovation (1)
  • Kubernetes (8)
  • LifeStyle (2)
  • LINUX (6)
  • Microsoft (2)
  • news (3)
  • People (4)
  • Reviews (1)
  • RHEL (2)
  • Security (2)
  • Self-Improvement and Professional Development (1)
  • Serverless (2)
  • Social (2)
  • Switch (1)
  • Technology (473)
  • Terraform (3)
  • Tools (1)
  • Tutorials (13)
  • Uncategorized (9)
  • Video (1)
  • Videos (1)

Tags

2Min's (7) Agile (1) AI (5) Appication Modernization (1) Application modernization (1) Architecture (1) AWS (43) AZURE (4) BigQuery (1) books (2) Case Studies (17) CI/CD (1) Cloud Computing (525) Cloud Optimization (1) Comparo (17) Consolidation (1) Courses (1) Data Analytics (1) Data Center (8) Emerging (1) GCP (11) Generative AI (1) How to (14) Hybrid Cloud (5) Innovation (2) Kubernetes (4) LINUX (5) lunch&learn (473) memcache (1) Microsoft (1) monitoring (1) NEWS (2) NSX (1) Opinion (3) SDDC (2) security (1) Self help (2) Shorties (1) Stories (1) Team Building (1) Technology (3) Tutorials (20) vmware (3) vSAN (1) Weekend Long Read (1)
  • About
  • Advertise
  • Privacy & Policy

© 2023 The Cloud Guru - Let's Simplify !!

No Result
View All Result
  • Home
  • AWS
  • HOW To’s
  • Tutorials
  • GCP
  • 2 Minute Tutorials
  • Data Center
  • Artificial Intelligence
  • Azure
  • Videos
  • Innovation

© 2023 The Cloud Guru - Let's Simplify !!

Welcome Back!

Sign In with Facebook
Sign In with Google
Sign In with Linked In
OR

Login to your account below

Forgotten Password?

Create New Account!

Sign Up with Facebook
Sign Up with Google
Sign Up with Linked In
OR

Fill the forms bellow to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In