4、kubernetes實踐:rancher-ha-安裝配置Helm

參考
https://www.cnrancher.com/docs/rancher/v2.x/cn/installation/ha-install/linux

注意
helm使用須要kubectl,點擊瞭解安裝和配置kubectlgit

Helm是Kubernetes首選的包管理工具。Helmcharts爲Kubernetes YAML清單文檔提供模板語法。使用Helm,咱們能夠建立可配置的部署,而不單單是使用靜態文件。有關建立本身的charts的更多信息,請查看https://helm.sh/文檔。Helm有兩個部分:Helm客戶端(helm)和Helm服務端(Tiller)。github

1. 配置Helm客戶端訪問權限

Helm在集羣上安裝tiller服務以管理charts. 因爲RKE默認啓用RBAC, 所以咱們須要使用kubectl來建立一個serviceaccountclusterrolebinding才能讓tiller具備部署到集羣的權限。shell

  • kube-system命名空間中建立ServiceAccount
  • 建立ClusterRoleBinding以授予tiller賬戶對集羣的訪問權限
  • helm初始化tiller服務
kubectl -n kube-system create serviceaccount tiller

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

2. 安裝Helm客戶端

採用二進制安裝
能夠在helm官網上下載Helm,若是速度不理想能夠使用rancher自帶加速下載Helmapi

wget https://www.cnrancher.com/download/helm/helm-v2.14.1-linux-amd64.tar.gz
tar xf helm-v2.14.1-linux-amd64.tar.gz

helm在解壓後的目錄中找到二進制文件,並將其移動到所需的位置服務器

sudo mv linux-amd64/helm /usr/local/bin/helm && chmod +x /usr/local/bin/helm

3. 安裝Helm Server(Tiller)

Helm的服務器端部分Tiller,一般運行在Kubernetes集羣內部。可是對於開發,它也能夠在本地運行,並配置爲與遠程Kubernetes集羣通訊。ide

安裝tiller到集羣中最簡單的方法就是運行helm init。這將驗證helm本地環境設置是否正確(並在必要時進行設置)。而後它會鏈接到kubectl默認鏈接的K8S集羣(kubectl config view)。一旦鏈接,它將安裝tillerkube-system命名空間中。工具

helm init自定義參數:this

  • --canary-image 參數安裝金絲雀版本;
  • --tiller-image 安裝特定的鏡像(版本);
  • --kube-context 使用安裝到特定集羣;
  • --tiller-namespace 用一個特定的命名空間(namespace)安裝;
注意:
一、RKE默認啓用RBAC,因此在安裝tiller時須要指定ServiceAccount。
二、helm init在缺省配置下,會去谷歌鏡像倉庫拉取gcr.io/kubernetes-helm/tiller鏡像,在Kubernetes集羣上安裝配置Tiller;因爲在國內可能沒法訪問gcr.io、storage.googleapis.com等域名,能夠經過--tiller-image指定私有鏡像倉庫鏡像。 
三、helm init在缺省配置下,會利用https://kubernetes-charts.storage.googleapis.com做爲缺省的stable repository地址,並去更新相關索引文件。在國內可能沒法訪問storage.googleapis.com地址, 能夠經過--stable-repo-url指定chart國內加速鏡像地址。 
四、若是您是離線安裝Tiller, 假如沒有內部的chart倉庫, 可經過添加--skip-refresh參數禁止Tiller更新索引。

在rancher中安裝Tillergoogle

wangpeng@test-kube-master-01:~$ helm init --service-account tiller --skip-refresh \
> --tiller-image registry.cn-shanghai.aliyuncs.com/rancher/tiller:v2.14.1
Creating /home/wangpeng/.helm 
Creating /home/wangpeng/.helm/repository 
Creating /home/wangpeng/.helm/repository/cache 
Creating /home/wangpeng/.helm/repository/local 
Creating /home/wangpeng/.helm/plugins 
Creating /home/wangpeng/.helm/starters 
Creating /home/wangpeng/.helm/cache/archive 
Creating /home/wangpeng/.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 /home/wangpeng/.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

查看helm狀況

wangpeng@test-kube-master-01:~$ helm version
Client: &version.Version{SemVer:"v2.14.1", GitCommit:"5270352a09c7e8b6e8c9593002a73535276507c0", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.14.1", GitCommit:"5270352a09c7e8b6e8c9593002a73535276507c0", GitTreeState:"clean"}
相關文章
相關標籤/搜索