使用 terraform+helm 设置 kubernetes+istio 的发布管道会出现禁止错误

Setting up release pipeline of kubernetes+istio with terraform+helm gives forbidden error

我已经尝试了很多次在 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 的错误。

我被困住了,感谢任何帮助我做不同的事情。

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

---
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

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