k8s sa role rolebinding secret

本文详细介绍了Kubernetes中的RBAC组件,包括Role、ClusterRole、RoleBinding、ClusterRoleBinding以及ServiceAccount和Secret的使用。ServiceAccount提供pod访问API的身份认证,创建时会默认创建一个加密的token。Opaque Secret用于处理敏感信息,如Docker镜像的下载认证。imagePullSecrets用于设置拉取镜像时的安全验证。
摘要由CSDN通过智能技术生成

一、在RBAC中的几个概念:
1、什么是RBAC
RBAC全称Role-Based Access Control,是Kubernetes集群基于角色的访问控制,实现授权决策,允许通过Kubernetes API动态配置策略。

2、什么是Role
Role是一组权限的集合,例如Role可以包含列出Pod权限及列出Deployment权限,Role用于给某个NameSpace中的资源进行鉴权。

3、什么是ClusterRole
ClusterRole是一组权限的集合,但与Role不同的是,ClusterRole可以在包括所有NameSpace和集群级别的资源或非资源类型进行鉴权。

4、什么是Subject
Subject:有三种Subjects,Service Account、User Account、Groups,参照官方文档主要区别是User Account针对人,Service Accounts针对运行在Pods中运行的进程。

5、什么是RoleBinding与ClusterRoleBinding
RoleBinding与ClusterRoleBindin:将Subject绑定到Role或ClusterRole。其区别在于:RoleBinding将使规则在命名空间内生效,而ClusterRoleBinding将使规则在所有命名空间中生效。

二、创建一个sa,并绑定ClusterRole(Role同ClusteRole):
1、创建ServiceAccount

apiVersion: v1
kind: ServiceAccount
metadata:
  name: user-privileged-serviceaccount
  namespace: example-namespace

2、创建clusterrole

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"rbac.authorization.k8s.io/v1","kind":"ClusterRole","metadata":{"annotations":{},"name":"aimaster-per-user-clusterrole"},"r
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值