我正在尝试为我们的 CI/CD 服务器设置一个角色,该角色可以支持回滚失败的部署。当前权限用于更新部署和相关资源并监视它们的状态,但是当我尝试以 CI 用户身份运行例如“kubectl rollout undo deployment/admin”时,我收到错误:
错误:无法从部署管理员检索副本集:replisets.apps 被禁止:用户“ci-admin”无法在命名空间“acceptance”中的 API 组“apps”中列出资源“replicasets”
这是最初的角色配置:
# 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 文档根本没有帮助,因为似乎没有任何给定命令所需权限的完整列表。只有少数几个例子。
谁能告诉回滚需要什么权限?