在Kubernetes上進行容器化部署並不是易事,docker、環境變量、存儲、網絡等方面都會涉及到,這些複雜的操做能夠被Helm應用包管理工具實現,避免了全手工操做的,Helm官網:https://helm.shnode
ssh登陸到能夠執行kubectl操做的服務器:linux
tar -zxvf helm-v2.16.1-linux-amd64.tar.gz
mv linux-amd64/helm /usr/local/bin/
[root@node1 ~]# helm version Client: &version.Version{SemVer:"v2.16.1", GitCommit:"bbdfe5e7803a12bbdf97e94cd847859890cf4050", GitTreeState:"clean"} Error: could not find tiller
客戶端部署完畢,接下來要把ServiceAccount和角色綁定建好git
kubectl create serviceaccount --namespace kube-system tiller
kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
helm init --upgrade -i registry.cn-hangzhou.aliyuncs.com/google_containers/tiller:v2.16.1 --stable-repo-url https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts --service-account tiller
[root@node1 ~]# helm version Client: &version.Version{SemVer:"v2.16.1", GitCommit:"bbdfe5e7803a12bbdf97e94cd847859890cf4050", GitTreeState:"clean"} Server: &version.Version{SemVer:"v2.16.1", GitCommit:"bbdfe5e7803a12bbdf97e94cd847859890cf4050", GitTreeState:"clean"}
如今helm已裝好,接下來部署個應用試試程序員
yum install nfs-utils -y
apiVersion: v1 kind: PersistentVolume metadata: name: pv-tomcat namespace: default spec: capacity: storage: 10Gi accessModes: - ReadWriteOnce persistentVolumeReclaimPolicy: Recycle nfs: path: /usr/local/work/test/001 server: 192.168.133.142
kubectl create -f pv-tomcat.yaml
PV已經準備好,能夠經過Helm部署應用了github
helm repo add bitnami https://charts.bitnami.com/bitnami
[root@node1 ~]# helm search tomcat NAME CHART VERSION APP VERSION DESCRIPTION bitnami/tomcat 6.0.6 9.0.29 Chart for Apache Tomcat
helm install \ --name my-tomcat \ bitnami/tomcat
[root@node1 ~]# helm list NAME REVISION UPDATED STATUS CHART APP VERSION NAMESPACE my-tomcat 1 Sun Nov 24 20:29:16 2019 DEPLOYED tomcat-6.0.6 9.0.29 default
[root@node1 local]# kubectl get services NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.233.0.1 <none> 443/TCP 3h36m my-tomcat LoadBalancer 10.233.16.166 <pending> 80:31229/TCP 100s
至此,實戰結束,在您安裝和使用Helm的時候,但願本文能給您一些參考;docker