helm安装(kubeadm)

网上很多教程,都写的挺好的。但是我看了下,有个什么tiller 什么的可以不用安装什么的。反正有很多不同的版本,安装方式也不一样,我的k8s是用kubeadm方式安装的。总之安装tiller的时候也很多坑,其中flannel那个问题坑了我一整天,最后不得已换成了calico,有使用flannel并且成功的朋友麻烦透露下方法,不胜感激!

 

具体步骤:

一、下载helm tar包

我刚开始用的是shell安装脚本的方式,但是阿里云服务器不知道为什么下载不了,就是一直卡死在tar包下载这里。

curl https://raw.githubusercontent.com/helm/helm/master/scripts/get |bash

然后我用wget方式下载的:

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

实在不行,办公室的电脑手动下载然后上传上去的。

 

二、解压tar包

tar zxvf helm-v2.16.1-linux-amd64.tar.gz

linux-amd64/

linux-amd64/helm

linux-amd64/LICENSE

linux-amd64/tiller

linux-amd64/README.md

 

解压完成发现在当前目录下有几个文件,我们移动helm文件到bin里

mv linux-amd64/helm /usr/local/bin/

 

三、初始化tiller

查看 版本

helm version

Client: &version.Version{SemVer:"v2.16.1", GitCommit:"bbdfe5e7803a12bbdf97e94cd847859890cf4050", GitTreeState:"clean"}

Error: could not find tiller

发现没有tiller

 

然后初始化

helm init

Creating /root/.helm

Creating /root/.helm/repository

Creating /root/.helm/repository/cache

Creating /root/.helm/repository/local

Creating /root/.helm/plugins

Creating /root/.helm/starters

Creating /root/.helm/cache/archive

Creating /root/.helm/repository/repositories.yaml

Adding stable repo with URL: https://kubernetes-charts.storage.googleapis.com

Adding local repo with URL: http://127.0.0.1:8879/charts

$HELM_HOME has been configured at /root/.helm.


Tiller (the Helm server-side component) has been installed into your Kubernetes Cluster.


Please note: by default, Tiller is deployed with an insecure 'allow unauthenticated users' policy.

To prevent this, run `helm init` with the --tiller-tls-verify flag.

For more information on securing your installation see: https://docs.helm.sh/using_helm/#securing-your-helm-installation

 

提示是什么 不安全,先不理会

 

查看tiller 的服务

kubectl get svc -n kube-system

已经好了:

[root@localhost sea]# kubectl get svc -n kube-system
NAME            TYPE        CLUSTER-IP    EXTERNAL-IP   PORT(S)                  AGE
kube-dns        ClusterIP   10.96.0.10    <none>        53/UDP,53/TCP,9153/TCP   2d20h
tiller-deploy   ClusterIP   10.96.220.3   <none>        44134/TCP                36m

再次执行 版本查看

helm version
Client: &version.Version{SemVer:"v2.16.1", GitCommit:"bbdfe5e7803a12bbdf97e94cd847859890cf4050", GitTreeState:"clean"}
Error: could not find tiller

 

依然提示没有tiller

 

然后去看tiller的pod

kubectl get pod -n kube-system
NAME                                              READY   STATUS             RESTARTS   AGE
etcd-iz8vb28ugr0yzlmfw0yxd8z                      1/1     Running            7          4d18h
kube-scheduler-iz8vb28ugr0yzlmfw0yxd8z            1/1     Running            8          4d18h
tiller-deploy-b747845f-2jzcp                      0/1     ImagePullBackOff   0          2m27s

 

STATUS竟然是backoff的,应该是 镜像又被墙了

 

然后去查看

kubectl describe pod tiller-deploy-b747845f-2jzcp -n kube-system

 

显示镜像拉取失败

 

这时候最方便的就是去打tag绕过qiang了。。。

 

docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/tiller:v2.16.1

docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/tiller:v2.16.1 gcr.io/kubernetes-helm/tiller:v2.16.1

 

稍等10秒,再次查看版本

[root@localhost sea]# helm version
Client: &version.Version{SemVer:"v2.16.1", GitCommit:"bbdfe5e7803a12bbdf97e94cd847859890cf4050", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.16.1", GitCommit:"bbdfe5e7803a12bbdf97e94cd847859890cf4050", GitTreeState:"clean"}

可以了。

然后去创建一个应用试试

helm install stable/tomcat

一直卡着,最后报错:Error: no available release name found

 

这个错误是因为权限不够

kubectl create serviceaccount --namespace kube-system tiller

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

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

命令执行后提示 deployment.extensions "tiller-deploy" patched 即可。

注意:到这一步,如果是kubeadm,并且网络组件是flannel,可能还是会报Error: no available release name found这个错误,这个时候,可以更换为calico网络组件,我是这样做的。

 

然后再继续安装应用测试

helm install stable/tomcat

应该是已经可以了。

如果还是不行,欢迎微我 marinechat,谢谢。

posted @ 2022-04-08 18:01  oceanyang  阅读(253)  评论(0编辑  收藏  举报