Kubernetes问题梳理

记录遇到的问题和解决方法

Problem1: 用helm部署应用时遇到:User "system:serviceaccount:kube-system:default" cannot get namespaces in the namespace "default"

遇到问题的场景:

  • 启动了digitalocean托管的Kubernetes集群,如下安装helm后遇到的

# helm init

helm init还有不少参数?不知道是不是没设置参数导致的。

解决问题的参考:

问题分析:

究其原因,还是安装步骤不对导致的

If you use the official tiller installation instruction, you'll have to do so:

  • Create a serviceaccount for tiller

  • Bind a role for the ServiceAccout created above (cluster-admin role is needed)

  • Make a ClusterRoleBinding for ServiceAccout

  • Patch the deployment created when using helm init

解决方法1:

kubectl --namespace kube-system create serviceaccount tiller

kubectl create clusterrolebinding tiller-cluster-rule \
 --clusterrole=cluster-admin --serviceaccount=kube-system:tiller

kubectl --namespace kube-system patch deploy tiller-deploy \
 -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}' 

这是通过命令行的方式,验证过可以。

解决方法2:

通过yaml定义https://github.com/helm/helm/issues/3130#issuecomment-393744456

没验证过,我目前对Kubernetes的一些组件定义和机制还不理解。

这篇中文文档对这个问题做了比较好的解释。

Last updated

Was this helpful?