外包精通--使用helm3快速部署应用

helm3 instruction

个人笔记网站http://note.27ops.com

版本对比

helm3 与helm2对比,官方文档。

代码语言:txt
复制
https://helm.sh/docs/topics/v2_v3_migration/

官方

官方网站 https://helm.sh/

代码语言:txt
复制
https://helm.sh/

github https://github.com/helm/helm/releases

代码语言:txt
复制
https://github.com/helm/helm/releases

部署

官网部署文档 https://helm.sh/docs/intro/install/

代码语言:txt
复制
https://helm.sh/docs/intro/install/

解压

代码语言:txt
复制
[root@master01 ~]# tar xf helm-v3.6.3-linux-386.tar.gz

拷贝

代码语言:txt
复制
[root@master01 ~]# cd linux-386/
[root@master01 linux-386]# ls
helm  LICENSE  README.md
[root@master01 linux-386]#
[root@master01 linux-386]# cp helm /usr/bin/

更新

既然下载了,可以不进行更新

代码语言:txt
复制
[root@master01 ~]# curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
[root@master01 linux-386]# ls
get_helm.sh  helm  LICENSE  README.md
[root@master01 linux-386]# chmod 700 get_helm.sh 
[root@master01 linux-386]#
[root@master01 linux-386]# ./get_helm.sh 
Downloading https://get.helm.sh/helm-v3.6.3-linux-amd64.tar.gz
Verifying checksum... Done.
Preparing to install helm into /usr/local/bin
helm installed into /usr/local/bin/helm
[root@master01 linux-386]# 

helm 常用命令

helm version

代码语言:txt
复制
[root@master01 ~]# helm version
version.BuildInfo{Version:"v3.6.3", GitCommit:"d506314abfb5d21419df8c7e7e68012379db2354", GitTreeState:"clean", GoVersion:"go1.16.5"}
[root@master01 ~]# 

helm env

代码语言:txt
复制
[root@master01 ~]# helm env
HELM_BIN="helm"
HELM_CACHE_HOME="/root/.cache/helm"
HELM_CONFIG_HOME="/root/.config/helm"
HELM_DATA_HOME="/root/.local/share/helm"
HELM_DEBUG="false"
HELM_KUBEAPISERVER=""
HELM_KUBEASGROUPS=""
HELM_KUBEASUSER=""
HELM_KUBECAFILE=""
HELM_KUBECONTEXT=""
HELM_KUBETOKEN=""
HELM_MAX_HISTORY="10"
HELM_NAMESPACE="default"
HELM_PLUGINS="/root/.local/share/helm/plugins"
HELM_REGISTRY_CONFIG="/root/.config/helm/registry.json"
HELM_REPOSITORY_CACHE="/root/.cache/helm/repository"
HELM_REPOSITORY_CONFIG="/root/.config/helm/repositories.yaml"
[root@master01 ~]# 

添加仓库

undefined

代码语言:txt
复制
[root@master01 ~]# helm repo add bitnami https://charts.bitnami.com/bitnami
"bitnami" has been added to your repositories
[root@master01 ~]# 

查看仓库列表

代码语言:txt
复制
[root@master01 ~]# helm repo list
NAME   	URL                               
bitnami	https://charts.bitnami.com/bitnami
[root@master01 ~]#

更新仓库

代码语言:txt
复制
[root@master01 ~]# helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "bitnami" chart repository
Update Complete. ⎈Happy Helming!⎈
[root@master01 ~]# 
代码语言:txt
复制
[root@master01 ~]# helm search repo bitnami
NAME                                        	CHART VERSION	APP VERSION  	DESCRIPTION                                       
bitnami/bitnami-common                      	0.0.9        	0.0.9        	DEPRECATED Chart with custom templates used in ...
bitnami/airflow                             	10.2.7       	2.1.2        	Apache Airflow is a platform to programmaticall...
bitnami/apache                              	8.5.10       	2.4.48       	Chart for Apache HTTP Server                      
bitnami/argo-cd                             	1.0.0        	2.0.5        	Declarative, GitOps continuous delivery tool fo...
#... and many more

部署应用

代码语言:txt
复制
[root@master01 ~]# helm install bitnami/zookeeper --generate-name
NAME: zookeeper-1628066005
LAST DEPLOYED: Wed Aug  4 16:33:28 2021
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
** Please be patient while the chart is being deployed **

ZooKeeper can be accessed via port 2181 on the following DNS name from within your cluster:

zookeeper-1628066005.default.svc.cluster.local

To connect to your ZooKeeper server run the following commands:

export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=zookeeper,app.kubernetes.io/instance=zookeeper-1628066005,app.kubernetes.io/component=zookeeper" -o jsonpath="{.items[0].metadata.name}")
kubectl exec -it $POD_NAME -- zkCli.sh

To connect to your ZooKeeper server from outside the cluster execute the following commands:

kubectl port-forward --namespace default svc/zookeeper-1628066005 2181:2181 &
zkCli.sh 127.0.0.1:2181

[root@master01 ~]#

查看应用列表

代码语言:txt
复制
[root@master01 ~]# helm list
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
zookeeper-1628066005 default 1 2021-08-04 16:33:28.144386149 +0800 CST deployed zookeeper-7.1.1 3.7.0
[root@master01 ~]#

查看SVC

代码语言:txt
复制
[root@master01 ~]# ks
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 5d <none>
nginx ClusterIP 10.101.229.167 <none> 443/TCP 4d16h io.kompose.service=nginx
registry ClusterIP 10.100.47.25 <none> 5000/TCP 4d16h io.kompose.service=registry
zookeeper-1628066005 ClusterIP 10.103.108.218 <none> 2181/TCP,2888/TCP,3888/TCP 61s app.kubernetes.io/component=zookeeper,app.kubernetes.io/instance=zookeeper-1628066005,app.kubernetes.io/name=zookeeper
zookeeper-1628066005-headless ClusterIP None <none> 2181/TCP,2888/TCP,3888/TCP 61s app.kubernetes.io/component=zookeeper,app.kubernetes.io/instance=zookeeper-1628066005,app.kubernetes.io/name=zookeeper
[root@master01 ~]#

查看应用状态

代码语言:txt
复制
[root@master01 ~]# helm status zookeeper-1628066253
NAME: zookeeper-1628066253
LAST DEPLOYED: Wed Aug 4 16:37:36 2021
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
** Please be patient while the chart is being deployed **

ZooKeeper can be accessed via port 2181 on the following DNS name from within your cluster:

zookeeper-1628066253.default.svc.cluster.local

To connect to your ZooKeeper server run the following commands:

export POD_NAME=$(kubectl get pods --namespace default -l &#34;app.kubernetes.io/name=zookeeper,app.kubernetes.io/instance=zookeeper-1628066253,app.kubernetes.io/component=zookeeper&#34; -o jsonpath=&#34;{.items[0].metadata.name}&#34;)
kubectl exec -it $POD_NAME -- zkCli.sh

To connect to your ZooKeeper server from outside the cluster execute the following commands:

kubectl port-forward --namespace default svc/zookeeper-1628066253 2181:2181 &amp;
zkCli.sh 127.0.0.1:2181

[root@master01 ~]#

卸载应用

代码语言:txt
复制
[root@master01 ~]# helm uninstall zookeeper-1628066005
release "zookeeper-1628066005" uninstalled
[root@master01 ~]#