k8s安装kubesphere失败原因和解决方法

提示信息:

fatal: [localhost]: FAILED! => {“changed”: true, “cmd”: “/usr/local/bin/helm upgrade –install ks-openldap /etc/kubesphere/openldap-ha -f /etc/kubesphere/custom-values-openldap.yaml –set fullnameOverride=openldap –namespace kubesphere-system ”, “delta”: “0:00:00.667982”, “end”: “2020-07-08 06:34:49.019851″, “msg”: “non-zero return code”, “rc”: 1, “start”: “2020-07-08 06:34:48.351869”, “stderr”: "Error: render error in “openldap-ha/templates/statefulset.yaml”: template: openldap-ha/templates/statefulset.yaml:25:9: executing “openldap-ha/templates/statefulset.yaml” at <(.Values.ldap.replication) and eq .Values.ldap.replication “true”>: can’t give argument to non-function .Values.ldap.replication", “stderr_lines”: ["Error: render error in “openldap-ha/templates/statefulset.yaml”: template: openldap-ha/templates/statefulset.yaml:25:9: executing “openldap-ha/templates/statefulset.yaml” at <(.Values.ldap.replication) and eq .Values.ldap.replication “true”>: can’t give argument to non-function .Values.ldap.replication"], “stdout”: "Release “ks-openldap” does not exist. Installing it now.", “stdout_lines”: ["Release “ks-openldap” does not exist. Installing it now."]}

原因:helm的版本不匹配导致的。我当前安装的版本是v2.17.0,我重新安装的版本是v2.16.6。

重新安装的步骤:

1.删除旧的helm,直接执行helm reset。

2.删除/usr/local/bin/helm,命令:rm -rf /usr/local/bin/helm

3.进入到/usr/local/bin/目录下,命令:cd /usr/local/bin/

4.获取安装包,命令:

wget https://get.helm.sh/helm-v2.16.6-linux-amd64.tar.gz

如果没有安装wget,执行安装命令:yum install wget,确认y。

5.解压安装包,命令:tar zxvf helm-v2.16.6-linux-amd64.tar.gz

6.将解压目录下的helm复制到/usr/local/bin/目录下,命令:cp /usr/local/bin/linux-amd64/helm /usr/local/bin/

7.给helm授予权限,命令:chmod 777 helm,运行ls命令能看到helm文件变了颜色。

8.执行初始化命令:

helm init --upgrade -i registry.cn-hangzhou.aliyuncs.com/google_containers/tiller:v2.16.6  --stable-repo-url https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts

哎呀,报错,讲安装过了helm,简单粗暴点,直接删除相关信息,命令:rm -rf /root/.helm。然后重新执行上面的命令,ok成功。

9.kubectl create serviceaccount --namespace kube-system tiller serviceaccount/tiller created

10.kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller clusterrolebinding.rbac.authorization.k8s.io/tiller-cluster-rule created

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

deployment.apps/tiller-deploy patched

12.kubectl get deploy -n kube-system tiller-deploy -o yaml | grep serviceAccount

f:serviceAccount: {}

f:serviceAccountName: {}

serviceAccount: tiller

serviceAccountName: tiller

13.helm version

Client: &version.Version{SemVer:"v2.16.6", GitCommit:"dd2e5695da88625b190e6b22e9542550ab503a47", GitTreeState:"clean"}

Server: &version.Version{SemVer:"v2.16.6", GitCommit:"dd2e5695da88625b190e6b22e9542550ab503a47", GitTreeState:"clean"}

14.kubectl apply -f kubesphere-minimal.yaml

安利下吧,kubesphere-minimal.yaml或者kubesphere-complete-setup.yaml从哪里下载来,肯定上github搜呀:

把项目clone下来就好了。

15.等着k8s构建完成吧。

完美结束了一天,安~~

经验分享 程序员 微信小程序 职场和发展