【问题标题】:Setting up release pipeline of kubernetes+istio with terraform+helm gives forbidden error使用 terraform+helm 设置 kubernetes+istio 的发布管道会出现禁止错误
【发布时间】:2019-08-24 17:15:01
【问题描述】:

我现在已经尝试了很多次在 Azure devops 中设置此管道,我想在其中部署 AKS 集群并将 istio 放在上面。

使用 Terraform 部署 AKS 效果很好。

在此之后我尝试使用 helm 安装 istio,但我使用的命令给出了禁止错误。

helm.exe install --namespace istio-system --name istio-init --wait C:\Istio\install\kubernetes\helm\istio

我使用本地路径,因为这是我能找到的唯一好方法,让 helm 找到我在构建代理上拥有的 istio 图表。

错误信息

Error: release istio-init failed: clusterroles.rbac.authorization.k8s.io "istio-galley-istio-system" is forbidden: attempt to grant extra privileges: [{[*] [admissionregistration.k8s.io] [validatingwebhookconfigurations] [] []} {[get] [config.istio.io] [*] [] []} {[list] [config.istio.io] [*] [] []} {[watch] [config.istio.io] [*] [] []} {[get] [*] [deployments] [istio-galley] []} {[get] [*] [endpoints] [istio-galley] []}] user=&{system:serviceaccount:kube-system:tillerserviceaccount 56632fa4-55e7-11e9-a4a1-9af49f3bf03a [system:serviceaccounts system:serviceaccounts:kube-system system:authenticated] map[]} ownerrules=[] ruleResolutionErrors=[[clusterroles.rbac.authorization.k8s.io "cluster-admin" not found, clusterroles.rbac.authorization.k8s.io "system:discovery" not found, clusterroles.rbac.authorization.k8s.io "cluster-admin" not found, clusterroles.rbac.authorization.k8s.io "system:discovery" not found, clusterroles.rbac.authorization.k8s.io "system:discovery" not found, clusterroles.rbac.authorization.k8s.io "cluster-admin" not found]]

我使用的服务帐户(系统:服务帐户:kube-system:tillerserviceaccount,如您在错误消息中看到的)是使用此 rbac 配置配置的:

apiVersion: v1
kind: ServiceAccount
metadata:
  name: tillerserviceaccount
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: tillerbinding
roleRef:
  apiGroup: ""
  kind: ClusterRole
  name: cluster-admin
subjects:
  - kind: ServiceAccount
    name: tillerserviceaccount
    namespace: kube-system

错误消息在 ruleResolutionErrors 中仍然显示它正在查找 cluster-admin 但未找到。

我什至尝试了极端,将所有服务帐户设置为集群管理员进行测试:

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

但即使在那之后,我也会遇到同样的错误,使用相同的 ruleResolutionErrors。

我被困住了,并感谢任何我可以做不同的帮助。

【问题讨论】:

  • 很确定你需要先运行 istio init,而不是只运行 istio 并称之为 istio init
  • 我对此很陌生。当我下载 istio 的安装包时,我得到了 istio 图表和 istio-remote 图表。没有初始化。或者你的意思是任何其他类型的初始化。我像 helm init 一样运行来设置服务帐户等。
  • 在 github 文档上阅读 istio 图表说:“在安装 istio 图表之前,必须运行 istio-init 图表完成。”所以我从那里下载初始化图表并先运行它。
  • 是的,它与 istio 在同一个文件夹中,但称为 istio-init:C:\Istio\install\kubernetes\helm\istio-init - 应该在这里。你应该使用 1.1+
  • 现在尝试了 istio-init,但仍然出现了 forbidder 错误。 “clusterroles.rbac.authorization.k8s.io “istio-init-istio-system” 被禁止...”如果需要,我可以用完整的错误更新问题。

标签: kubernetes kubernetes-helm istio azure-aks


【解决方案1】:

这是我们在开发集群中使用的角色绑定:

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: tillerbinding
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
  - kind: ServiceAccount
    name: tillerserviceaccount
    namespace: kube-system

编辑:在这种情况下,错误是由于 AKS 在没有 RBAC 的情况下创建的。

【讨论】:

  • 但是正如我在我的问题中所说的那样,我有相同的名称,我的绑定 tillerbinding 和我的服务帐户的另一个名称,不是吗? (我也尝试过使用那个 apiGroup ......但我猜那是在 init 运行之前。
  • 我也尝试将 apigroup 设置为您的示例.. htem 都不起作用..
  • 好的,我想你的集群没有启用 rbac。显示用于创建 aks 的 TF 配置
  • 我很确定我有......但是......嗯......如果我不感到尴尬......我会仔细检查......
  • 哇...毕竟这段时间我没有仔细检查它是否已启用...它不是.. smacks head..添加到您的答案中,我应该仔细检查我是否启用了 rbac 并接受它。
猜你喜欢
  • 2019-04-05
  • 2020-06-16
  • 2021-06-25
  • 2020-11-03
  • 2021-08-26
  • 2020-09-18
  • 1970-01-01
  • 1970-01-01
  • 2019-05-08
相关资源
最近更新 更多