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