本文介紹在k8s上部署和使用helm。Helm是Kubernetes的一個包管理工具,用來簡化Kubernetes應用的部署和管理。能夠把Helm比做CentOS的yum工具。 經過使用使用Helm能夠管理Kubernetes manifest files、管理Helm安裝包charts、基於chart的Kubernetes應用分發。linux
Chart: 是helm的應用打包格式。Chart由一系列文件組成,這些文件相似rpm包nginx
Chart目錄結構:
一、chart.yaml
Yaml文件,用來描述chart的摘要信息api二、readme.md
Markdown格式的readme文件,此文件爲可選ide三、LICENSE
文本文件,描述chart的許可信息,此文件爲可選工具四、requirements.yaml
Yaml文件,用來描述chart的的依賴關係,在安裝過程當中,依賴的chart也會被一塊兒安裝測試五、value.yaml
Yaml文件,chart支持在安裝的時候作對配置參數作定製化配置,value.yaml文件爲配置參數的默認值ui六、templates目錄
各種k8s資源的配置模板目錄google
# cd /usr/local/src/ # # wget https://storage.googleapis.com/kubernetes-helm/helm-v2.8.2-linux-amd64.tar.gz # tar -zxvpf helm-v2.8.2-linux-amd64.tar.gz # mv linux-amd64/helm /usr/local/sbin/helm # helm version Client: &version.Version{SemVer:"v2.8.2", GitCommit:"a80231648a1473929271764b920a8e346f6de844", GitTreeState:"clean"} rror: cannot connect to Tiller
# helm init --upgrade -i \ registry.cn-hangzhou.aliyuncs.com/google_containers/tiller:v2.8.2 \ --stable-repo-url https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts # helm version Client: &version.Version{SemVer:"v2.8.2", GitCommit:"a80231648a1473929271764b920a8e346f6de844", GitTreeState:"clean"} Server: &version.Version{SemVer:"v2.8.2", GitCommit:"a80231648a1473929271764b920a8e346f6de844", GitTreeState:"clean"} # kubectl get pod -n kube-system -o wide # kubectl get deployment tiller-deploy -n kube-system -o wide
# helm repo update # helm repo list # helm install stable/nginx-ingress
出現Error: no available release name found提示是由於未配置rbacurl
# kubectl create serviceaccount --namespace kube-system tiller # kubectl create clusterrolebinding tiller-cluster-rule \ --clusterrole=cluster-admin --serviceaccount=kube-system:tiller # kubectl patch deploy --namespace kube-system \ tiller-deploy -p \ '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}'
# helm install stable/nginx-ingress
# kubectl get pod # kubectl get deployment # kubectl get svc
# helm list # helm delete invisible-greyhound # kubectl get pod # kubectl get deployment # kubectl get svc