无法在指定的命名空间上安装 kubernetes 图表

Unable to install kubernetes charts on specified namespace

我已经在 Google Kubernetes Engine 上安装了一个集群。

然后,我创建了命名空间 "staging"

$ kubectl get namespaces
default       Active    26m
kube-public   Active    26m
kube-system   Active    26m
staging       Active    20m

然后,我切换到暂存命名空间中操作

$ kubectl config use-context staging
$ kubectl config current-context
staging

然后,我在暂存命名空间上使用 helm 安装了 postgresql

helm install --name staging stable/postgresql

但我得到了:

Error: release staging failed: namespaces "staging" is forbidden: User "system:serviceaccount:kube-system:default" cannot get namespaces in the namespace "staging": Unknown user "system:serviceaccount:kube-system:default"

这是什么意思..??如何让它工作..??

谢谢你..

由于您的集群启用了 RBAC,因此您的 tiller Pod 似乎没有足够的权限。

您使用的 default ServiceAccount 缺少足够的 RBAC 权限,tiller 需要。

创建 ClusterRole、ClusterRoleBinding 和 ServiceAccount 所需的一切。通过它们,您可以为您的 Pod 提供必要的权限。

按照以下步骤操作

_1。创建 ClusterRole tiller

kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
  name: tiller
rules:
- apiGroups: ["*"]
  resources: ["*"]
  verbs: ["*"]

Note: I have used full permission here.

_2。在 kube-system 命名空间

中创建服务帐户 tiller
$ kubectl create sa tiller -n kube-system

_3。创建 ClusterRoleBinding tiller

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

现在您需要在您的 tiller 部署中使用此 ServiceAccount。

因为您已有一个,请编辑它

$ kubectl edit deployment -n kube-system tiller-deploy

在 PodSpec

下将 serviceAccountName 设置为 tiller

阅读更多关于 RBAC

尝试:

helm init --upgrade --service-account tiller

正如 Scott S 在 评论中所建议的那样。