1.先決條件本地的kubectl 可以連接到遠(yuǎn)程的k8s
2.下載helm->參考
3.安裝helm
tar -zxvf helm-v2.11.0-linux-amd64.tar.gz
sudo mv linux-amd64/helm /usr/local/bin/helm
#helm help驗(yàn)證安裝成功
4. 添加tiller到 [k8s] service account
#vim serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: tiller
namespace: kube-system
#:wq保存
#kubectl apply -f serviceaccount.yaml
或
kubectl create serviceaccount --namespace kube-system tiller
# vim clusterrolebinding.yaml
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
#:wq保存
#kubectl apply -f clusterrolebinding.yaml
或
kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
5.用阿里云tiller鏡像及tiller賬戶初始化helm, 將tiller部署到[k8s] deployment下.
helm init --service-account tiller --upgrade --tiller-image=registry.cn-hangzhou.aliyuncs.com/google_containers/tiller:v2.11.0
#若您已經(jīng)在k8s部署了tiller則只需要執(zhí)行
helm init --client-only
#vim ~/.helm/repository/repositories.yaml
apiVersion: v1
generated: 2018-11-10T20:32:27.187074383+08:00
repositories:
- caFile: ""
cache: /root/.helm/repository/cache/stable-index.yaml
certFile: ""
keyFile: ""
name: stable
password: "password"
url: https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
username: "username"
- caFile: ""
cache: /root/.helm/repository/cache/local-index.yaml
certFile: ""
keyFile: ""
name: local
password: ""
url: http://127.0.0.1:8879/charts
username: ""
6.檢查tiller是否部署到[k8s]
kubectl get pod -n kube-system -l app=helm
7.用helm示例測試
#創(chuàng)建一個chart范例
helm create helm-chart
#檢查chart語法
helm lint ./helm-chart
#使用默認(rèn)chart部署到k8s
helm install --name example1 ./helm-chart --set service.type=NodePort
#kubectl get pod 查看是否部署成功