SlideShare a Scribd company logo
Securing Access to Your Kubernetes Applications
Using Dex for Authentication
&
Role Based Access Control (RBAC) for Authorization
Deepika Dixit
Software Engineer
Introductions
Onkar Bhat
Engineering Manager
Securing Access to Your K8 Application
โ— You are the administrator of an IT department who wants to deploy an application in a Kubernetes cluster.
โ— You want to avoid adopting a new authentication workflow.
โ— Users in your organization are accustomed to using their existing Active Directory credentials for accessing apps.
โ— Can you authenticate users against it when they access applications in Kubernetes?
Dex can help you!
โ— Youโ€™ve solved the authentication piece of the puzzle.
โ— Do you have different types of users?
โ—‹ Cluster administrators
โ—‹ App administrators
โ—‹ Read only users
โ— How do you grant varying levels of access to these users
Kubernetes has your RBAC!
What is Dex ?
โ— Dex is an identity service that uses OpenID Connect to drive authentication for other apps.
โ— Dex acts as a portal to other identity providers through โ€œconnectors.โ€
What is a connector?
Implements the logic for authenticating against an upstream IDP
โ— LDAP
โ— Openshift OAuth
โ— GitHub
โ— Google
Install Dex Using Helm
โ— helm repo add dex https://charts.dexidp.io
โ— helm install dex dex/dex -f dex-values.yaml
NAME: dex
LAST DEPLOYED: Wed Mar 17 21:06:49 2021
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
1. Get the application URL by running these commands:
export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=dex,app.kubernetes.io/instance=dex" -o
jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace default $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace default port-forward $POD_NAME 8080:$CONTAINER_PORT
Dex Configuration
Dex
Client Registration
LDAP Connector
Port Forwarding
kubectl --namespace dex port-forward $POD_NAME 8080:$CONTAINER_PORT
Forwarding from 127.0.0.1:8080 -> 5556
Forwarding from [::1]:8080 -> 5556
Install and Run the Example Application
โ— git clone https://github.com/dexidp/dex.git
โ— cd dex/examples/example-app
โ— go build
โ— ./example-app --issuer http://127.0.0.1:8080
2021/03/16 20:52:02 listening on http://127.0.0.1:5555
demo
Demo
Claims:
{
"iss": "http://127.0.0.1:8080",
"sub": "CgVvbmthchIEbGRhcA",
"aud": "example-app",
"exp": 1616037593,
"iat": 1615951193,
"at_hash": "S9b817ZpFhdA6Ezw-nEEdA",
"email": "onkar",
"email_verified": true,
"groups": [
"K10admins"
],
"name": "onkar",
"preferred_username": "onkar"
}
What is Kubernetes RBAC?
1. Kubernetes defines RBAC as โ€œRole-based access control (RBAC) is a method of regulating access
to computer or network resources based on the roles of individual users within your organization.โ€
2. RBAC is a flexible and powerful method, where you define rules once and use them multiple times.
3. Allows access control over resources not just within a cluster but within the application as well.
4. Defines clearly โ€œwhoโ€ has access to โ€œwhatโ€.
5. Allows for dynamically calculating access as applications change and grow.
Why do you need RBAC?
โœ“ Multi-tenancy is an important concern, especially as clusters and applications mature after the initial
hurdles of infrastructure and setup.
โœ“ How to restrict users access to just their applications and components within their applications is a
crucial administrative decision.
โœ“ Users can have their own setup and be unaware of other users in the same cluster/system.
โœ“ Allows separation and security between users and applications.
Roles and ClusterRoles
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
namespace: default
name: example-role
Rules: # multiple rules can be added
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "watch", "list"]
- apiGroups: [""]
resources: ["secrets"]
verbs: ["get", "watch", "list"]
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
# "namespace" omitted since ClusterRoles
are not namespaced
name: example-clusterole
rules:
- apiGroups: [""]
resources: ["secrets"]
verbs: ["create", "get"
, "watch", "list"]
Rules and Resources
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
namespace: default
name: example-role
rules:
- apiGroups: ["mygroup.example.com"
]
resources: ["pods"]
resourceNames: ["mypod"]
verbs: ["get", "watch", "list"]
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
namespace: default
name: example-role-all
rules:
- apiGroups: ["*"]
resources: ["*"]
verbs: ["*"]
Subjects
Users
subjects:
- kind: User
name:
"alice@example.com"
Groups
subjects:
- kind: Group
name:
"frontend-admins"
Service Account
subjects:
- kind: ServiceAccount
name: default
namespace:
kube-system
RoleBindings
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: read-pods
namespace: default
subjects: # You can specify more than one "subject"
- kind: User
name: jane # "name" is case sensitive
apiGroup: rbac.authorization.k8s.io
roleRef: # "roleRef" specifies the binding to a Role / ClusterRole
kind: Role #this must be Role or ClusterRole
name: pod-reader # this must match the name of the Role or ClusterRole you wish to bind to
apiGroup: rbac.authorization.k8s.io
ClusterRoleBindings
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: read-secrets-global
subjects:
- kind: Group
name: manager # Name is case sensitive
apiGroup: rbac.authorization.k8s.io
- kind: ServiceAccount
name: test-sa
namespace: default
apiGroup: rbac.authorization.k8s.io
roleRef:
kind: ClusterRole
name: secret-reader
apiGroup: rbac.authorization.k8s.io
How, What, When?
Role v/s ClusterRole?
โ— Use Roles when rules are limited to a certain namespace
โ— Use ClusterRoles when rules are to be be defined across multiple namespaces and span
Resources/APIGroups not limited to a certain namespaces or if runtime namespace is not known in
advance
RoleBinding v/s ClusterRoleBinding?
โ— Use RoleBindings to limit subjects to a particular namespace
โ— Use ClusterRoleBindings to give cluster-wide access to subjects
Users v/s Groups?
โ— Use Users when specific user is known
โ— Use Groups to give all users belonging to the same group the same access level
How can I check what access a user has?
Kubectl auth can-i
โœ“ Kubectl tool to check user access
โœ“ Checks roles and bindings across the cluster to verify access
โœ“ Allows impersonation as user or group to verify access control across the list of subjects
demo
References
RBAC
https://kubernetes.io/docs/reference/access-authn-authz/rbac/
Dex
https://dexidp.io/
https://github.com/dexidp/helm-charts
#dexidp at kubernetes.slack.com
https://aws.amazon.com/blogs/security/how-to-configure-ldaps-endpoint-for-simple-ad/

More Related Content

PDF
Why your APIs should fly first class
PDF
OpenAPI 3.0, And What It Means for the Future of Swagger
PPTX
The Magic Behind Faster API Development, Testing and Delivery with API Virtua...
PPTX
Tools and techniques for APIs
PPTX
Advanced Automation in Your API Lifecycle
PPTX
Operational API design anti-patterns (Jason Harmon)
PPTX
WSO2 Product Release Webinar - WSO2 App Factory 2.1
ย 
PDF
TDD for Microservices
Why your APIs should fly first class
OpenAPI 3.0, And What It Means for the Future of Swagger
The Magic Behind Faster API Development, Testing and Delivery with API Virtua...
Tools and techniques for APIs
Advanced Automation in Your API Lifecycle
Operational API design anti-patterns (Jason Harmon)
WSO2 Product Release Webinar - WSO2 App Factory 2.1
ย 
TDD for Microservices

What's hot (20)

PDF
apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...
ย 
PPTX
Effective API Lifecycle Management
PDF
TDD for APIs in a Microservice World (Short Version) by Michael Kuehne-Schlin...
PPTX
Understanding and Executing on API Developer Experience
PDF
Versioning strategy for a complex internal API (Konstantin Yakushev)
PPTX
Continuous Integration and Delivery at Shapeways (Matt Boyle)
PDF
Build pipelines with TeamCity and Kotlin DSL
PPTX
Advanced Mocking for Swagger APIs
PDF
A Hitchhiker's Guide to Cloud-Native API Gateways
PDF
Deep Dive on CI/CD NYC Meet Up Group
PDF
apidays LIVE Hong Kong 2021 - Multi-Protocol APIs at Scale in Adidas by Jesus...
ย 
PDF
API Creation to Iteration without the Frustration
PPTX
The Swagger Format becomes the Open API Specification: Standardizing descript...
ย 
PDF
Workflows in WSO2 API Manager - WSO2 API Manager Community Call (12/15/2021)
ย 
PDF
BENEFIT OF FLUTTER APP DEVELOPMENT - INFOGRAPHICS
PPTX
Running the-next-generation-of-cloud-native-applications-using-open-applicati...
PPTX
apidays LIVE Paris 2021 - Inside API delivery Pipeline, the checklist! - Fran...
ย 
PDF
The API Lifecycle Series: Evolving API Development and Testing from Open Sour...
PDF
Designing APIs with OpenAPI Spec
PDF
API Design Collaboration
apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...
ย 
Effective API Lifecycle Management
TDD for APIs in a Microservice World (Short Version) by Michael Kuehne-Schlin...
Understanding and Executing on API Developer Experience
Versioning strategy for a complex internal API (Konstantin Yakushev)
Continuous Integration and Delivery at Shapeways (Matt Boyle)
Build pipelines with TeamCity and Kotlin DSL
Advanced Mocking for Swagger APIs
A Hitchhiker's Guide to Cloud-Native API Gateways
Deep Dive on CI/CD NYC Meet Up Group
apidays LIVE Hong Kong 2021 - Multi-Protocol APIs at Scale in Adidas by Jesus...
ย 
API Creation to Iteration without the Frustration
The Swagger Format becomes the Open API Specification: Standardizing descript...
ย 
Workflows in WSO2 API Manager - WSO2 API Manager Community Call (12/15/2021)
ย 
BENEFIT OF FLUTTER APP DEVELOPMENT - INFOGRAPHICS
Running the-next-generation-of-cloud-native-applications-using-open-applicati...
apidays LIVE Paris 2021 - Inside API delivery Pipeline, the checklist! - Fran...
ย 
The API Lifecycle Series: Evolving API Development and Testing from Open Sour...
Designing APIs with OpenAPI Spec
API Design Collaboration
Ad

Similar to Kasten securing access to your kubernetes applications (20)

PDF
RBAC in Kuberetes
PDF
Appsecco Kubernetes Hacking Masterclass Presentation Slides
PDF
Security considerations while deploying Containerized Applications by Neepend...
PDF
Role based access control - RBAC - Kubernetes
PDF
Kubernetes - Security Journey
PPTX
Apolicy achieving least privilege access in kubernetes - https://apolicy.io/
PDF
Attacking and Defending Kubernetes - Nithin Jois
PPTX
K8s security best practices
PDF
Kubernetes Hacking for Fun & Profit - BSides Bangalore - 28th June 2024
PPTX
K8s security best practices
PDF
5 Kubernetes Security Tools You Should Use
PDF
Kubernetes Security Best Practices for DevOps
PDF
K8s identity management
PPTX
Securing & Monitoring Your K8s Cluster with RBAC and Prometheusโ€.
PPTX
Kubernetes basics information along with stateful session info
PDF
Introduction to Kubernetes RBAC
ย 
PDF
Kubernetes Administration from Zero to Hero.pdf
PDF
DevOpsDaysRiga 2018: Andrew Martin - Continuous Kubernetes Security
PDF
Evolution of security strategies in K8s environments- All day devops
PDF
Kubernetes: Beyond Baby Steps
RBAC in Kuberetes
Appsecco Kubernetes Hacking Masterclass Presentation Slides
Security considerations while deploying Containerized Applications by Neepend...
Role based access control - RBAC - Kubernetes
Kubernetes - Security Journey
Apolicy achieving least privilege access in kubernetes - https://apolicy.io/
Attacking and Defending Kubernetes - Nithin Jois
K8s security best practices
Kubernetes Hacking for Fun & Profit - BSides Bangalore - 28th June 2024
K8s security best practices
5 Kubernetes Security Tools You Should Use
Kubernetes Security Best Practices for DevOps
K8s identity management
Securing & Monitoring Your K8s Cluster with RBAC and Prometheusโ€.
Kubernetes basics information along with stateful session info
Introduction to Kubernetes RBAC
ย 
Kubernetes Administration from Zero to Hero.pdf
DevOpsDaysRiga 2018: Andrew Martin - Continuous Kubernetes Security
Evolution of security strategies in K8s environments- All day devops
Kubernetes: Beyond Baby Steps
Ad

More from LibbySchulze (20)

PDF
Running distributed tests with k6.pdf
PPTX
Extending Kubectl.pptx
PPTX
Enhancing Data Protection Workflows with Kanister And Argo Workflows
PDF
Fallacies in Platform Engineering.pdf
PDF
Intro to Fluvio.pptx.pdf
PPTX
Enhance your Kafka Infrastructure with Fluvio.pptx
PDF
CNCF On-Demand Webinar_ LitmusChaos Project Updates.pdf
PDF
Oh The Places You'll Sign.pdf
PPTX
Rancher MasterClass - Avoiding-configuration-drift.pptx
PPTX
vFunction Konveyor Meetup - Why App Modernization Projects Fail - Aug 2022.pptx
PPTX
CNCF Live Webinar: Low Footprint Java Containers with GraalVM
PDF
EnRoute-OPA-Integration.pdf
PDF
AirGap_zusammen_neu.pdf
PDF
Copy of OTel Me All About OpenTelemetry The Current & Future State, Navigatin...
PDF
OTel Me All About OpenTelemetry The Current & Future State, Navigating the Pr...
PDF
CNCF_ A step to step guide to platforming your delivery setup.pdf
PDF
CNCF Online - Data Protection Guardrails using Open Policy Agent (OPA).pdf
PDF
Securing Windows workloads.pdf
PDF
Securing Windows workloads.pdf
PDF
Advancements in Kubernetes Workload Identity for Azure
Running distributed tests with k6.pdf
Extending Kubectl.pptx
Enhancing Data Protection Workflows with Kanister And Argo Workflows
Fallacies in Platform Engineering.pdf
Intro to Fluvio.pptx.pdf
Enhance your Kafka Infrastructure with Fluvio.pptx
CNCF On-Demand Webinar_ LitmusChaos Project Updates.pdf
Oh The Places You'll Sign.pdf
Rancher MasterClass - Avoiding-configuration-drift.pptx
vFunction Konveyor Meetup - Why App Modernization Projects Fail - Aug 2022.pptx
CNCF Live Webinar: Low Footprint Java Containers with GraalVM
EnRoute-OPA-Integration.pdf
AirGap_zusammen_neu.pdf
Copy of OTel Me All About OpenTelemetry The Current & Future State, Navigatin...
OTel Me All About OpenTelemetry The Current & Future State, Navigating the Pr...
CNCF_ A step to step guide to platforming your delivery setup.pdf
CNCF Online - Data Protection Guardrails using Open Policy Agent (OPA).pdf
Securing Windows workloads.pdf
Securing Windows workloads.pdf
Advancements in Kubernetes Workload Identity for Azure

Recently uploaded (20)

PDF
โ€œGoogle Algorithm Updates in 2025 Guideโ€
PDF
WebRTC in SignalWire - troubleshooting media negotiation
PDF
๐Ÿ’ฐ ๐”๐Š๐“๐ˆ ๐Š๐„๐Œ๐„๐๐€๐๐†๐€๐ ๐Š๐ˆ๐๐„๐‘๐Ÿ’๐ƒ ๐‡๐€๐‘๐ˆ ๐ˆ๐๐ˆ ๐Ÿ๐ŸŽ๐Ÿ๐Ÿ“ ๐Ÿ’ฐ
ย 
PDF
The Internet -By the Numbers, Sri Lanka Edition
ย 
DOCX
Unit-3 cyber security network security of internet system
PDF
An introduction to the IFRS (ISSB) Stndards.pdf
PDF
Triggering QUIC, presented by Geoff Huston at IETF 123
ย 
PPTX
cyber security Workshop awareness ppt.pptx
PPTX
SAP Ariba Sourcing PPT for learning material
PDF
LABUAN4D EXCLUSIVE SERVER STAR GAMING ASIA NO.1
PPTX
Internet___Basics___Styled_ presentation
PPTX
Slides PPTX World Game (s) Eco Economic Epochs.pptx
PPTX
Job_Card_System_Styled_lorem_ipsum_.pptx
PDF
Automated vs Manual WooCommerce to Shopify Migration_ Pros & Cons.pdf
PPTX
Digital Literacy And Online Safety on internet
PDF
Decoding a Decade: 10 Years of Applied CTI Discipline
PDF
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
ย 
PDF
LABUAN4D EXCLUSIVE SERVER STAR GAMING ASIA NO.1
PPTX
international classification of diseases ICD-10 review PPT.pptx
PDF
Vigrab.top โ€“ Online Tool for Downloading and Converting Social Media Videos a...
โ€œGoogle Algorithm Updates in 2025 Guideโ€
WebRTC in SignalWire - troubleshooting media negotiation
๐Ÿ’ฐ ๐”๐Š๐“๐ˆ ๐Š๐„๐Œ๐„๐๐€๐๐†๐€๐ ๐Š๐ˆ๐๐„๐‘๐Ÿ’๐ƒ ๐‡๐€๐‘๐ˆ ๐ˆ๐๐ˆ ๐Ÿ๐ŸŽ๐Ÿ๐Ÿ“ ๐Ÿ’ฐ
ย 
The Internet -By the Numbers, Sri Lanka Edition
ย 
Unit-3 cyber security network security of internet system
An introduction to the IFRS (ISSB) Stndards.pdf
Triggering QUIC, presented by Geoff Huston at IETF 123
ย 
cyber security Workshop awareness ppt.pptx
SAP Ariba Sourcing PPT for learning material
LABUAN4D EXCLUSIVE SERVER STAR GAMING ASIA NO.1
Internet___Basics___Styled_ presentation
Slides PPTX World Game (s) Eco Economic Epochs.pptx
Job_Card_System_Styled_lorem_ipsum_.pptx
Automated vs Manual WooCommerce to Shopify Migration_ Pros & Cons.pdf
Digital Literacy And Online Safety on internet
Decoding a Decade: 10 Years of Applied CTI Discipline
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
ย 
LABUAN4D EXCLUSIVE SERVER STAR GAMING ASIA NO.1
international classification of diseases ICD-10 review PPT.pptx
Vigrab.top โ€“ Online Tool for Downloading and Converting Social Media Videos a...

Kasten securing access to your kubernetes applications

  • 1. Securing Access to Your Kubernetes Applications Using Dex for Authentication & Role Based Access Control (RBAC) for Authorization
  • 3. Securing Access to Your K8 Application โ— You are the administrator of an IT department who wants to deploy an application in a Kubernetes cluster. โ— You want to avoid adopting a new authentication workflow. โ— Users in your organization are accustomed to using their existing Active Directory credentials for accessing apps. โ— Can you authenticate users against it when they access applications in Kubernetes? Dex can help you! โ— Youโ€™ve solved the authentication piece of the puzzle. โ— Do you have different types of users? โ—‹ Cluster administrators โ—‹ App administrators โ—‹ Read only users โ— How do you grant varying levels of access to these users Kubernetes has your RBAC!
  • 4. What is Dex ? โ— Dex is an identity service that uses OpenID Connect to drive authentication for other apps. โ— Dex acts as a portal to other identity providers through โ€œconnectors.โ€
  • 5. What is a connector? Implements the logic for authenticating against an upstream IDP โ— LDAP โ— Openshift OAuth โ— GitHub โ— Google
  • 6. Install Dex Using Helm โ— helm repo add dex https://charts.dexidp.io โ— helm install dex dex/dex -f dex-values.yaml NAME: dex LAST DEPLOYED: Wed Mar 17 21:06:49 2021 NAMESPACE: default STATUS: deployed REVISION: 1 TEST SUITE: None NOTES: 1. Get the application URL by running these commands: export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=dex,app.kubernetes.io/instance=dex" -o jsonpath="{.items[0].metadata.name}") export CONTAINER_PORT=$(kubectl get pod --namespace default $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") echo "Visit http://127.0.0.1:8080 to use your application" kubectl --namespace default port-forward $POD_NAME 8080:$CONTAINER_PORT
  • 8. Dex
  • 11. Port Forwarding kubectl --namespace dex port-forward $POD_NAME 8080:$CONTAINER_PORT Forwarding from 127.0.0.1:8080 -> 5556 Forwarding from [::1]:8080 -> 5556
  • 12. Install and Run the Example Application โ— git clone https://github.com/dexidp/dex.git โ— cd dex/examples/example-app โ— go build โ— ./example-app --issuer http://127.0.0.1:8080 2021/03/16 20:52:02 listening on http://127.0.0.1:5555
  • 13. demo
  • 14. Demo Claims: { "iss": "http://127.0.0.1:8080", "sub": "CgVvbmthchIEbGRhcA", "aud": "example-app", "exp": 1616037593, "iat": 1615951193, "at_hash": "S9b817ZpFhdA6Ezw-nEEdA", "email": "onkar", "email_verified": true, "groups": [ "K10admins" ], "name": "onkar", "preferred_username": "onkar" }
  • 15. What is Kubernetes RBAC? 1. Kubernetes defines RBAC as โ€œRole-based access control (RBAC) is a method of regulating access to computer or network resources based on the roles of individual users within your organization.โ€ 2. RBAC is a flexible and powerful method, where you define rules once and use them multiple times. 3. Allows access control over resources not just within a cluster but within the application as well. 4. Defines clearly โ€œwhoโ€ has access to โ€œwhatโ€. 5. Allows for dynamically calculating access as applications change and grow.
  • 16. Why do you need RBAC? โœ“ Multi-tenancy is an important concern, especially as clusters and applications mature after the initial hurdles of infrastructure and setup. โœ“ How to restrict users access to just their applications and components within their applications is a crucial administrative decision. โœ“ Users can have their own setup and be unaware of other users in the same cluster/system. โœ“ Allows separation and security between users and applications.
  • 17. Roles and ClusterRoles apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: namespace: default name: example-role Rules: # multiple rules can be added - apiGroups: [""] resources: ["pods"] verbs: ["get", "watch", "list"] - apiGroups: [""] resources: ["secrets"] verbs: ["get", "watch", "list"] apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: # "namespace" omitted since ClusterRoles are not namespaced name: example-clusterole rules: - apiGroups: [""] resources: ["secrets"] verbs: ["create", "get" , "watch", "list"]
  • 18. Rules and Resources apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: namespace: default name: example-role rules: - apiGroups: ["mygroup.example.com" ] resources: ["pods"] resourceNames: ["mypod"] verbs: ["get", "watch", "list"] apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: namespace: default name: example-role-all rules: - apiGroups: ["*"] resources: ["*"] verbs: ["*"]
  • 19. Subjects Users subjects: - kind: User name: "alice@example.com" Groups subjects: - kind: Group name: "frontend-admins" Service Account subjects: - kind: ServiceAccount name: default namespace: kube-system
  • 20. RoleBindings apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: read-pods namespace: default subjects: # You can specify more than one "subject" - kind: User name: jane # "name" is case sensitive apiGroup: rbac.authorization.k8s.io roleRef: # "roleRef" specifies the binding to a Role / ClusterRole kind: Role #this must be Role or ClusterRole name: pod-reader # this must match the name of the Role or ClusterRole you wish to bind to apiGroup: rbac.authorization.k8s.io
  • 21. ClusterRoleBindings apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: read-secrets-global subjects: - kind: Group name: manager # Name is case sensitive apiGroup: rbac.authorization.k8s.io - kind: ServiceAccount name: test-sa namespace: default apiGroup: rbac.authorization.k8s.io roleRef: kind: ClusterRole name: secret-reader apiGroup: rbac.authorization.k8s.io
  • 22. How, What, When? Role v/s ClusterRole? โ— Use Roles when rules are limited to a certain namespace โ— Use ClusterRoles when rules are to be be defined across multiple namespaces and span Resources/APIGroups not limited to a certain namespaces or if runtime namespace is not known in advance RoleBinding v/s ClusterRoleBinding? โ— Use RoleBindings to limit subjects to a particular namespace โ— Use ClusterRoleBindings to give cluster-wide access to subjects Users v/s Groups? โ— Use Users when specific user is known โ— Use Groups to give all users belonging to the same group the same access level
  • 23. How can I check what access a user has? Kubectl auth can-i โœ“ Kubectl tool to check user access โœ“ Checks roles and bindings across the cluster to verify access โœ“ Allows impersonation as user or group to verify access control across the list of subjects
  • 24. demo