在 GCP 上部署 Weaviate k8s 设置时无法在 API 组中列出资源 "configmaps"

Cannot list resource "configmaps" in API group when deploying Weaviate k8s setup on GCP

当 运行(在 GCP 上)时:

$ helm upgrade \
  --values ./values.yaml \
  --install \
  --namespace "weaviate" \
  "weaviate" \
  weaviate.tgz

它returns;

UPGRADE FAILED
Error: configmaps is forbidden: User "system:serviceaccount:kube-system:default" cannot list resource "configmaps" in API group "" in the namespace "ku
be-system"
Error: UPGRADE FAILED: configmaps is forbidden: User "system:serviceaccount:kube-system:default" cannot list resource "configmaps" in API group "" in t
he namespace "kube-system"

更新:基于解决方案

$ vim rbac-config.yaml

添加到文件:

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

运行:

$ kubectl create -f rbac-config.yaml
$ helm init --service-account tiller --upgrade

注:基于 Helm v2.

tl;dr:使用适合集群的授权设置设置 Helm,请参阅 https://v2.helm.sh/docs/using_helm/#role-based-access-control

长答案

您的体验并非特定于 Weaviate Helm 图表,而是 Helm 似乎未根据集群授权设置进行设置。其他 Helm 命令应该会失败并出现相同或类似的错误。

下面的错误

Error: configmaps is forbidden: User "system:serviceaccount:kube-system:default" cannot list resource "configmaps" in API group "" in the namespace "ku
be-system"

表示 kube-system 命名空间中的默认服务帐户缺少权限。我假设您已经在 kube-system 命名空间中安装了 Helm/Tiller,因为如果没有在 helm init 上指定其他参数,这是默认设置。由于您尚未为 Tiller 创建特定的服务帐户,因此默认使用 default 服务帐户。

既然您提到您在 GCP 上 运行,我认为这意味着您正在使用 GKE。 GKE 默认启用 RBAC Authorization。在 RBAC 设置中默认没有任何人拥有任何权限,所有权限都需要明确授予。

helm 文档列出了几个关于如何制作 Helm/Tiller work in an RBAC-enabled setting. If the cluster has the sole purpose of running Weaviate you can choose the simplest option: Service Account with cluster-admin role 的选项。那里描述的过程实质上是为 Tiller 创建一个专用服务帐户,并将所需的 ClusterRoleBinding 添加到现有的 cluster-admin ClusterRole。请注意,这实际上使 Helm/Tiller 成为整个集群的管理员。

如果您是 运行 多租户集群 and/or 希望将 Tillers 权限限制在特定命名空间,您需要选择其中一个备选方案。