k8s~helm的(de)安裝過程
上一(yi)講(jiang)說(shuo)(shuo)了(le)一(yi)些helm的基本概念,而今(jin)天主要說(shuo)(shuo)一(yi)下如何把helm部署(shu)到(dao)服(fu)務器上,在(zai)helm3之(zhi)前的版(ban)本里(li),它由客戶端(duan)helm和(he)服(fu)務端(duan)tiller組成,而helm3.0之(zhi)后它去(qu)掉了(le)tiller,而直接與k8s通訊(xun),可以說(shuo)(shuo)在(zai)部署(shu)上更簡單了(le),而今(jin)天我們主要還是部署(shu)2.x版(ban)本的helm.
下載安裝包
//get.helm.sh/helm-v2.16.5-linux-amd64.tar.gz
腳本文檔rbac-config.yml
apiVersion: v1
kind: ServiceAccount
metadata:
name: tiller
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: tiller
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: tiller
namespace: kube-system
構建rbac
kubectl create -f rbac-config.yaml
初始化tiller
helm init --service-account tiller --skip-refresh
對于 Kubernetes v1.16.0 以(yi)上(shang)的版(ban)本,有可(ke)能會碰到 Error: error installing: the server could not find the requested resource 的錯誤。這是(shi)由于 extensions/v1beta1 已經(jing)被 apps/v1 替代。相信在2.15 或者 3 版(ban)本發(fa)布之后, 應該(gai)就不會遇到這個問題了(le)。還是(shi)生態比較(jiao)慢的原(yuan)因。
重新初始化tiller
helm init -i registry.cn-hangzhou.aliyuncs.com/google_containers/tiller:v2.14.3 --stable-repo-url //mirror.azure.cn/kubernetes/charts/ --service-account tiller --override spec.selector.matchLabels.'name'='tiller',spec.selector.matchLabels.'app'='helm' --output yaml | sed 's@apiVersion: extensions/v1beta1@apiVersion: apps/v1@' | kubectl apply -f -
查看tiller的pod信息
kubectl get pods -n kube-system | grep tiller
tiller-deploy-7c7b67c9fd-kxh6p 1/1 Running 0 4m58s
到現在為止,我們(men)的helm就安(an)裝(zhuang)(zhuang)功(gong)能(neng)了,之后我們(men)裝(zhuang)(zhuang)運(yun)行helm來(lai)進(jin)行charts的安(an)裝(zhuang)(zhuang)