helm官方建议使用tls,首先生成证书。
openssl genrsa -out ca.key.pem 4096 openssl req -key ca.key.pem -new -x509 -days 7300 -sha256 -out ca.cert.pem -extensions v3_ca -batch openssl genrsa -out tiller.key.pem 4096 openssl genrsa -out helm.key.pem 4096 openssl req -key tiller.key.pem -new -sha256 -out tiller.csr.pem -batch openssl req -key helm.key.pem -new -sha256 -out helm.csr.pem -batch openssl x509 -req -CA ca.cert.pem -CAkey ca.key.pem -CAcreateserial -in tiller.csr.pem -out tiller.cert.pem -days 7300 openssl x509 -req -CA ca.cert.pem -CAkey ca.key.pem -CAcreateserial -in helm.csr.pem -out helm.cert.pem -days 7300
这样一来,目录下将有八个文件:ca.cert.pem ca.key.pem ca.srl helm.cert.pem helm.csr.pem helm.key.pem tiller.cert.pem tiller.csr.pem tiller.key.pem
1、安装客户端
安装helm:
查看版本并下载:https://github.com/helm/helm/releases
curl -O https://storage.googleapis.com/kubernetes-helm/helm-v2.13.1-linux-amd64.tar.gz tar -zxvf helm-v2.13.1-linux-amd64.tar.gz mv linux-amd64/helm /usr/local/bin/helm ln -s /usr/local/bin/helm /usr/bin/helm
配置TLS
mkdir -p $(helm home) cp ca.cert.pem $(helm home)/ca.pem cp helm.cert.pem $(helm home)/cert.pem cp helm.key.pem $(helm home)/key.pem
验证
helm help
2、安装服务端
因为helm安装过程中会自动拉取gcr.io/kubernetes-helm/tiller镜像,国内可能无法访问,故可以使用下面的命令先查看所需的镜像版本,并在之后的命令行中设置镜像来源
helm init --dry-run --debug
设置授权
kubectl create serviceaccount --namespace kube-system tiller
kubectl create clusterrolebinding tiller --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
初始化helm,配置了阿里的源
helm init --override 'spec.template.spec.containers[0].command'='{/tiller,--storage=secret}' --tiller-image=registry.aliyuncs.com/google_containers/tiller:v2.13.1 --tiller-tls --tiller-tls-verify --tiller-tls-cert=./tiller.cert.pem --tiller-tls-key=./tiller.key.pem --tls-ca-cert=./ca.cert.pem --service-account=tiller --stable-repo-url=https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
验证
kubectl -n kube-system get pods|grep tiller kubectl -n kube-system get deployment helm ls --tls(无输出,运行完成即可)
3、集群中其他机器使用helm
先参考1、安装客户端,之后执行:
helm init --client-only --override 'spec.template.spec.containers[0].command'='{/tiller,--storage=secret}' --service-account=tiller --stable-repo-url=https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
4、卸载
helm reset --force --tls kubectl delete serviceaccount --namespace kube-system tiller kubectl delete clusterrolebinding tiller-cluster-rule rm -rf $(helm home) /usr/local/bin/helm /usr/bin/helm