RBACSync是一个Kubernetes控制器,用于同步基于Kubernetes RBAC的RoleBindings和ClusterRoleBindings。它通过整合配置对象,从组成员来源(如直接声明或GSuite等上游服务)获取用户信息,自动创建并维护引用组成员的RBAC绑定对象。
RBACSyncConfig:命名空间作用域,用于创建RoleBindingsClusterRBACSyncConfig:集群作用域,用于创建ClusterRoleBindings自定义资源(CRDs)
RBACSync通过以下CRDs管理绑定配置:
| 自定义资源定义 | 作用域 | 描述 |
|---|---|---|
| RBACSyncConfig | 命名空间 | 映射组到用户,创建命名空间级RoleBindings |
| ClusterRBACSyncConfig | 集群 | 映射组到用户,创建集群级ClusterRoleBindings |
CRDs定义文件位于deploy/00-crds.yml,可通过kubectl apply -f deploy/00-crds.yml部署。
Bindings配置
bindings字段定义组到RBAC绑定的映射,示例:
yamlapiVersion: rbacsync.getcruise.com/v1alpha kind: ClusterRBACSyncConfig metadata: name: example-simple spec: bindings: - group: mygroup-admin@getcruise.com roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: cluster-admin
上述配置将为mygroup-admin@getcruise.com组创建ClusterRoleBinding,生成的绑定对象示例:
yamlapiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: annotations: rbacsync.getcruise.com/group: mygroup-admin@getcruise.com labels: owner: example-simple name: example-simple-mygroup-admin@getcruise.com-cluster-admin ownerReferences: # 由配置对象拥有 roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: cluster-admin subjects: # 来自上游或memberships的用户列表 - apiGroup: rbac.authorization.k8s.io kind: User name: a@getcruise.com - apiGroup: rbac.authorization.k8s.io kind: User name: b@getcruise.com
Memberships配置
memberships字段用于直接声明组成员,可与上游来源合并,示例:
yamlspec: memberships: - group: cluster-admin-group subjects: - kind: User name: a@getcruise.com apiGroup: rbac.authorization.k8s.io - kind: User name: b@getcruise.com apiGroup: rbac.authorization.k8s.io - group: someother-group subjects: - kind: User name: a@getcruise.com apiGroup: rbac.authorization.k8s.io
注意:使用GSuite时通常不需要此部分,但可用于补充成员(如服务账户)。
GSuite集成配置
准备GSuite服务账户:
https://www.googleapis.com/auth/admin.directory.group.readonlyhttps://www.googleapis.com/auth/admin.directory.group.member.readonly创建Kubernetes Secret:
bashkubectl create secret generic --from-file=token.json=<服务账户密钥路径> rbacsync-gsuite-credentials
修改部署配置:
yaml# 在deploy/20-deployment.yml中添加卷和参数 spec: volumes: - name: rbacsync-gsuite-credentials secret: secretName: rbacsync-gsuite-credentials containers: - name: rbacsync args: - "-logtostderr" - "-gsuite.enabled" - "-gsuite.credentials" - "/run/secrets/gsuite/token.json" - "-gsuite.delegator" - "my-rbacsync-robot@getcruise.com" volumeMounts: - mountPath: /run/secrets/gsuite name: rbacsync-gsuite-credentials
部署步骤
部署RBACSync:
bashkubectl apply -f deploy/
创建配置对象:
集群级配置示例(ClusterRBACSyncConfig):
yamlapiVersion: rbacsync.getcruise.com/v1alpha kind: ClusterRBACSyncConfig metadata: name: example-cluster-config spec: bindings: - group: cluster-admins@example.com roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: cluster-admin
命名空间级配置示例(RBACSyncConfig):
yamlapiVersion: rbacsync.getcruise.com/v1alpha kind: RBACSyncConfig metadata: name: example-namespace-config namespace: default spec: bindings: - group: namespace-admins@example.com roleRef: apiGroup: rbac.authorization.k8s.io kind: Role name: admin
验证部署:
bashkubectl get clusterrolebindings | grep example-cluster-config kubectl get rolebindings -n default | grep example-namespace-config
配置参数
rbacsync二进制支持以下主要参数:
| 参数 | 描述 | 默认值 |
|---|---|---|
-debug-addr | 调试和指标绑定地址 | :8080 |
-gsuite.enabled | 启用GSuite上游组同步 | false |
-gsuite.credentials | GSuite服务账户密钥路径 | - |
-gsuite.delegator | GSuite委托账户*** | - |
-gsuite.pattern | 匹配GSuite组的正则表达式 | - |
-gsuite.timeout | GSuite API请求超时 | 30s |
-upstream-poll-period | 上游组更新轮询周期 | 5m0s |
-kubeconfig | kubeconfig文件路径(本地开发用) | ~/.kube/config |
-v | 日志级别 | 0 |
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
无需登录使用专属域名
Kubernetes 集群配置 Containerd
K3s 轻量级 Kubernetes 镜像加速
VS Code Dev Containers 配置
Podman 容器引擎配置
HPC 科学计算容器配置
ghcr、Quay、nvcr 等镜像仓库
Harbor Proxy Repository 对接专属域名
Portainer Registries 加速拉取
Nexus3 Docker Proxy 内网缓存
需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单
docker search 限制
站内搜不到镜像
离线 save/load
插件要用 plugin install
WSL 拉取慢
安全与 digest
新手拉取配置
镜像合规机制
manifest unknown
no matching manifest(架构)
invalid tar header(解压)
TLS 证书失败
DNS 超时
域名连通性排查
410 Gone 排查
402 与流量用尽
401 认证失败
429 限流
D-Bus 凭证提示
413 与超大单层
来自真实用户的反馈,见证轩辕镜像的优质服务