k8s 安装helm

Helm部署
Helm 客户端安装
Helm 的安装方式很多,这里采用二进制的方式安装。更多安装方法可以参考 Helm 的官方帮助文档。
使用官方提供的脚本一键安装

curl https://raw.githubusercontent.com/helm/helm/master/scripts/get > get_helm.sh
chmod 700 get_helm.sh
./get_helm.sh

手动下载安装
下载地址
从官网下载最新版本的二进制安装包到本地(推荐用迅雷下载后上传服务器)

curl -O https://get.helm.sh/helm-v2.14.1-linux-amd64.tar.gz
tar -zxf helm-v2.14.1-linux-amd64.tar.gz
cd linux-amd64/
cp helm /usr/local/bin/

验证
helm version

目前只能查看到客户端的版本,服务器还没有安装。
Helm 服务端安装Tiller
注意:先在 K8S 集群上每个节点安装 socat 软件

yum install -y socat

不然会报如下错误:


E0522 22:22:15.492436 24409 portforward.go:331] an error occurred forwarding 38398 -> 44134: error forwarding port 44134 to pod dc6da4ab99ad9c497c0cef1776b9dd18e0a612d507e2746ed63d36ef40f30174, uid : unable to do port forwarding: socat not found.
Error: cannot connect to Tiller

为了安装服务端tiller,还需要在这台机器上配置好kubectl工具和kubeconfig文件,确保kubectl工具可以在这台机器上访问apiserver且正常使用。 这里的node1节点已经配置好了kubectl。
因为Kubernetes APIServer开启了RBAC访问控制,所以需要创建tiller使用的ServiceAccount: tiller并分配合适的角色给它。 详细内容可以查看helm文档中的Role-based Access Control。 这里简单起见直接分配cluster-admin这个集群内置的ClusterRole给它。
创建tiller.yaml


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


# kubectl create -f tiller.yaml
serviceaccount/tiller created
clusterrolebinding.rbac.authorization.k8s.io/tiller created

初始化helm服务端

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

Tiller 是以 Deployment 方式部署在 Kubernetes 集群中的
由于 Helm 默认会去gcr.io拉取镜像,所以如果你当前执行的机器没有配置梯子的话可以实现下面的命令代替:helm init –service-account tiller --tiller-image <images-url> –skip-refresh
使用私有镜像仓库中的tiller镜像

helm init --service-account tiller --tiller-image yaokun/tiller:v2.15.2 --stable-repo-url https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts

tiller默认被部署在k8s集群中的 kube-system 这个 namespace 下

# kubectl get pod -n kube-system


最后在node1上修改helm chart仓库的地址为azure提供的镜像地址:


# helm repo add stable http://mirror.azure.cn/kubernetes/charts
# helm repo list


卸载 Helm 服务器端 Tiller
如果你需要在 Kubernetes 中卸载已部署的 Tiller,可使用以下命令完成卸载。


# helm reset 或
# helm reset --force

验证helm

# helm version

posted @ 2020-07-26 23:20  qinliang  阅读(1011)  评论(0编辑  收藏  举报