Helm 是个k8s 包管理工具
结为金丹客,方为我辈人。
概述
Helm 下载地址: https://github.com/helm/helm/releases
本文用的是:
https://get.helm.sh/helm-v2.16.0-linux-amd64.tar.gz
安装其客户端helm
[root@k8s-master2 ~]# wget https://get.helm.sh/helm-v2.16.0-linux-amd64.tar.gz
--2019-11-12 14:30:49-- https://get.helm.sh/helm-v2.16.0-linux-amd64.tar.gz
正在解析主机 get.helm.sh (get.helm.sh)... 152.199.39.108, 2606:2800:247:1cb7:261b:1f9c:2074:3c
正在连接 get.helm.sh (get.helm.sh)|152.199.39.108|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:25264218 (24M) [application/x-tar]
正在保存至: “helm-v2.16.0-linux-amd64.tar.gz”
100%[=================================================================================================================================>] 25,264,218 3.37MB/s 用时 7.3s
2019-11-12 14:31:00 (3.30 MB/s) - 已保存 “helm-v2.16.0-linux-amd64.tar.gz” [25264218/25264218])
[root@k8s-master2 ~]#
[root@k8s-master2 ~]#
[root@k8s-master2 ~]#
[root@k8s-master2 ~]# ls
anaconda-ks.cfg helm-v2.16.0-linux-amd64.tar.gz k8s
[root@k8s-master2 ~]#
[root@k8s-master2 ~]#
[root@k8s-master2 ~]#
[root@k8s-master2 ~]#
[root@k8s-master2 ~]# tar -zxvf helm-v2.16.0-linux-amd64.tar.gz
linux-amd64/
linux-amd64/README.md
linux-amd64/helm
linux-amd64/LICENSE
linux-amd64/tiller
[root@k8s-master2 ~]# ll
总用量 24680
-rw-------. 1 root root 952 10月 24 22:46 anaconda-ks.cfg
-rw-r--r-- 1 root root 25264218 11月 6 23:31 helm-v2.16.0-linux-amd64.tar.gz
drwxr-xr-x 6 root root 73 11月 5 01:26 k8s
drwxr-xr-x 2 root root 60 11月 6 23:30 linux-amd64
[root@k8s-master2 ~]# mv linux-amd64/helm /usr/local/bin/helm
[root@k8s-master2 ~]# helm
The Kubernetes package manager
安装服务端Tiller
- 此处遇到了2个问题
- 由于多次使用kubeadm 安装,导致了cni 网卡网段有问题;
Warning FailedCreatePodSandBox 4m28s (x736 over 49m) kubelet, k8s-node3 (combined from similar events): Failed create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "3544615de0447ef1b6f672dfb2334d82ce4fee8a96f90914b5f0e06632744ea2" network for pod "tiller-deploy-786bc89dd8-7tfjw": networkPlugin cni failed to set up pod "tiller-deploy-786bc89dd8-7tfjw_kube-system" network: failed to set bridge addr: "cni0" already has an IP address different from 10.244.1.1/24
ifconfig 查看cni 网卡
[root@k8s-node3 ~]# ifconfig
cni0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 10.244.5.1 netmask 255.255.255.0 broadcast 0.0.0.0
inet6 fe80::b404:edff:fea0:cb8f prefixlen 64 scopeid 0x20<link>
ether b6:04:ed:a0:cb:8f txqueuelen 1000 (Ethernet)
RX packets 31262 bytes 5357693 (5.1 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 33928 bytes 3804288 (3.6 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
重建之后(既删除cni0,k8s自动重建):
[root@k8s-node3 ~]# ip link delete cni0
[root@k8s-node3 ~]#
[root@k8s-node3 ~]#
[root@k8s-node3 ~]# ifconfig
cni0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1450
inet 10.244.1.1 netmask 255.255.255.0 broadcast 0.0.0.0
inet6 fe80::987c:2ff:fedb:41cb prefixlen 64 scopeid 0x20<link>
ether 9a:7c:02:db:41:cb txqueuelen 1000 (Ethernet)
RX packets 1 bytes 28 (28.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3 bytes 266 (266.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
cni 恢复正常。
- 镜像问题
直接helm init , 使用的是此镜像,gcr.io/kubernetes-helm/tiller:v2.16.0
这里使用阿里云源解决;
先配置个权限,在init :
[root@k8s-master2 ~]# kubectl create serviceaccount --namespace kube-system tiller
serviceaccount/tiller created
[root@k8s-master2 ~]# kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
clusterrolebinding.rbac.authorization.k8s.io/tiller-cluster-rule created
[root@k8s-master2 ~]#
[root@k8s-master2 ~]#
[root@k8s-master2 ~]# helm init --service-account tiller --upgrade -i registry.cn-hangzhou.aliyuncs.com/google_containers/tiller:v2.16.0 --stable-repo-url https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
- 查看是否安装成功
[root@k8s-master2 ~]# helm version
Client: &version.Version{SemVer:"v2.16.0", GitCommit:"e13bc94621d4ef666270cfbe734aaabf342a49bb", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.16.0", GitCommit:"e13bc94621d4ef666270cfbe734aaabf342a49bb", GitTreeState:"clean"}
- 卸载服务端
如果需要删除服务端,可以使用下面的命令
helm reset
helm reset -f
当要移除helm init创建的目录等数据时,执行helm reset --remove-helm-home
- 删除应用
helm delete --purge my-jenkins