用户无法在 API 组中获取资源 "services" - Jenkins 管道 EKS 部署

User cannot get resource "services" in API group - Jenkins pipeline EKS deployment

我正在尝试使用 Jenkins 将我的 docker 映像部署到集群中。我的 Jenkins 应用程序在 EC2 ubuntu 服务器中 运行ning。最初,当我尝试时遇到此错误。

我提到了这个 并使用

将 Jenkins 用户 IAM arn 添加到 Kube 配置文件
kubectl edit configmap aws-auth -n kube-system

当我 运行 我的管道更新配置文件后,我收到这个新错误

我的问题是,

  1. 这个 Jenkins 用户是管理员用户,那为什么我会收到这个访问控制错误?

请帮我解决这个问题?

谢谢,@jakub。我能够通过创建集群绑定角色来解决错误。

kubectl create clusterrolebinding NAME --clusterrole=NAME [--user=username] [--group=groupname] [--serviceaccount=namespace:serviceaccountname] [--dry-run=server|client|none]

如评论所述

service account jenkins doesn't have privileges to list pods kube-system. You would have to create ClusterRoleBinding and ClusterRole 使其工作。

您可以像上面@Gowtham Babu 的回答那样使用 kubectl create 来做到这一点。

下面的教程中有一个例子

Also when rbac is set to true, following have to be done in order to allow jenkins pod access to “kube-system” namespace of the kubernetes cluster.

Create a clusterrolebinding with permissions “cluster-admin”,

kubectl create clusterrolebinding jenkinsrolebinding - -clusterrole=cluster-admin - - group=system:serviceaccounts:jenkins

其他资源:

我遇到了类似的问题:

$ kubectl logs demo
panic: certificatesigningrequests.certificates.k8s.io "csr-xx9l9" is forbidden: User "system:serviceaccount:default:default" cannot get resource "certificatesigningrequests" in API group "certificates.k8s.io" at the cluster scope

为了解决这个问题,我通过查看 Gowtham Babu posted 之前 post 的回答来解决这个问题:

$ kubectl create clusterrolebinding cesar3 \
  --clusterrole=cluster-admin \
  --user=system:serviceaccount:default:default \
  --group=certificates.k8s.io