Kubernetes 需要哪些角色权限来支持“;卷展栏撤消”;?
我正在尝试为我们的CI/CD服务器设置一个角色,该角色可以支持回滚失败的部署。当前权限用于更新部署和相关资源并监视其状态,但当我尝试以CI用户身份运行例如“kubectl Rollow undo deployment/admin”时,会出现以下错误:Kubernetes 需要哪些角色权限来支持“;卷展栏撤消”;?,kubernetes,kubernetes-rbac,Kubernetes,Kubernetes Rbac,我正在尝试为我们的CI/CD服务器设置一个角色,该角色可以支持回滚失败的部署。当前权限用于更新部署和相关资源并监视其状态,但当我尝试以CI用户身份运行例如“kubectl Rollow undo deployment/admin”时,会出现以下错误: - apiGroups: ["*"] resources: ["deployments", "replicasets"] verbs: ["get"
- apiGroups: ["*"]
resources: ["deployments", "replicasets"]
verbs: ["get", "list"]
错误:无法从部署管理员检索副本集:ReplicaSet.apps被禁止:用户“ci管理员”无法在命名空间“acceptance”中列出API组“apps”中的资源“ReplicaSet”
这是原始角色配置:
# Server role that allows CI to push application deployments to Kubernetes
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: deployment-role
namespace: acceptance
rules:
- apiGroups: ["*"]
resources: ["deployments"]
resourceNames: ["admin", "backend", "web"]
verbs: ["patch", "update", "watch"]
- apiGroups: ["*"]
resources: ["deployments"]
verbs: ["get", "list"]
- apiGroups: ["*"]
resources: ["configmaps"]
resourceNames: ["admin-fluent-bit-config", "backend-fluent-bit-config", "web-fluent-bit-config"]
verbs: ["patch", "update", "watch"]
- apiGroups: ["*"]
resources: ["configmaps"]
verbs: ["get", "list"]
- apiGroups: ["*"]
resources: ["horizontalpodautoscalers"]
resourceNames: ["backend"]
verbs: ["delete", "patch", "update"]
- apiGroups: ["*"]
resources: ["horizontalpodautoscalers"]
verbs: ["create", "get", "list"]
- apiGroups: ["*"]
resources: ["events", "pods", "pods/log"]
verbs: ["get", "list"]
我试图添加获取和列出复制集的权限以解决此错误:
- apiGroups: ["*"]
resources: ["deployments", "replicasets"]
verbs: ["get", "list"]
但我还是得到了和以前一样的错误
Kubernetes文档一点帮助都没有,因为似乎没有任何关于任何给定命令所需权限的全面列表。只有少数几个例子
有人能告诉我回滚需要什么权限吗?正如@ForgetfulFellow所提到的,您必须在
apiGroups
中添加扩展名,应用程序
此外,您还必须在resources
字段中添加replicasets
,因为如果没有它,您将收到以下错误:
error: failed to retrieve replica sets from deployment sample-deploy: replicasets.apps is forbidden: User "user" cannot list resource "replicasets" in API group "apps" in the namespace "acceptance"
今天早上我又试了一次,它就像最初写的一样,起了作用
我最好的猜测是,当时CI实际上运行在不同的集群上。我们的客户在9月份将验收环境迁移到了一个新的AWS帐户,但旧环境直到10月中旬才完全清理干净。当我在“开发”框中更改新群集中的角色时,CI服务器一定还在使用旧群集的上下文,我没有注意到,因为它们都有相同的名称:/
很抱歉出现错误警报。也许可以尝试使用“扩展”、“应用程序”apiGroups而不是“*”?