在 Jenkins 中配置 kubernetes 插件

Configuring kubernetes plugin in Jenkins

我正在尝试在 Jenkins 中配置 kubernetes 插件。以下是我输入的详细信息:

现在,当我点击测试连接时,出现以下错误:

Error testing connection https://xx.xx.xx.xx:8001: Failure executing: GET at: https://xx.xx.xx.xx:8001/api/v1/namespaces/default/pods. Message: Unauthorized! Configured service account doesn't have access. Service account may have been revoked. Unauthorized.

在做了一些 google 之后,我意识到这可能是因为角色绑定,所以我为我的 default 服务帐户创建了一个角色绑定:

# kubectl describe rolebinding jenkins
Name:         jenkins
Labels:       <none>
Annotations:  <none>
Role:
  Kind:  ClusterRole
  Name:  pod-reader
Subjects:
  Kind            Name     Namespace
  ----            ----     ---------
  ServiceAccount  default  default

这是 pod-reader 角色:

# kubectl describe role pod-reader
Name:         pod-reader
Labels:       <none>
Annotations:  <none>
PolicyRule:
  Resources  Non-Resource URLs  Resource Names  Verbs
  ---------  -----------------  --------------  -----
  pods       []                 []              [get watch list]

但我仍然遇到同样的错误。这里还有什么需要做的吗? TIA.

我认为它不起作用,因为您没有提供证书。 This 对我有用。

弄清楚了,我使用的凭据是纯文本。我将其更改为 kubernetes secret,它起作用了。