helm3的安装使用

发布时间 2023-03-22 21:16:26作者: xiaoniaox

转载自:https://www.jianshu.com/p/6907fc806b75

=========

 

1.Helm3安装(二进制安装)

# 根据操作系统跟所需版本去获取最新二进制安装包
https://github.com/helm/helm/releases     
wget https://get.helm.sh/helm-v3.3.1-linux-amd64.tar.gz      
tar xf helm-v3.3.1-linux-amd64.tar.gz
cp linux-amd64/helm  /usr/local/bin/
  • helm其他安装可参考官方网站: https://helm.sh/docs/intro/install/
  • 注意: helm 客户端需要下载到安装了 kubectl 并且能执行能正常通过 kubectl 操作 kubernetes 的服务器上, 否则 helm 将不可用

2.配置repo

helm repo add  elastic    https://helm.elastic.co       
helm repo add  gitlab     https://charts.gitlab.io       
helm repo add  harbor     https://helm.goharbor.io       
helm repo add  bitnami    https://charts.bitnami.com/bitnami       
helm repo add  incubator  https://kubernetes-charts-incubator.storage.googleapis.com     

# 添加国内仓库
helm repo add stable http://mirror.azure.cn/kubernetes/charts       
helm repo add aliyun https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts       

#更新repo仓库资源
helm repo update     

#查看添加的repo仓库  
helm repo list      

3.helm3 命令使用汇总

#查看环境信息
helm env

#查看版本信息
helm version

#查找软件
helm search repo nginx 
helm search hub  nginx 

#查看已有仓库列表
helm repo list

#更新仓库资源
helm repo update

#删除一个仓库
helm repo remove bitnami

#创建仓库索引
helm repo index /root/helm/repo

#部署chart
helm install  centos-nginx bitnami/nginx

-------------------------------------------------------------
#chart状态查看
helm status centos-nginx

简介
该命令显示已命名发布的状态,状态包括:

最后部署时间
发布版本所在的k8s命名空间
发布状态(可以是: unknown, deployed, uninstalled, superseded, failed, uninstalling, pending-install, pending-upgrade 或 pending-rollback)
发布版本修订
发布版本描述(可以是完成信息或错误信息,需要用–show-desc启用)
列举版本包含的资源,按类型排序
最后一次测试套件运行的详细信息(如果使用)
chart提供的额外的注释
-----------------------------------------------------------

#卸载chart
helm uninstall centos-nginx 

#查看chart列表    -A 表所有namespace
helm list -A

#chart部署记录
helm history centos-nginx

#chart更新
helm upgrade --set image.tag=nginx.18 centos-nginx bitnami/nginx

#chart回滚
helm rollback centos-nginx 1

3.1 chart制作命令

此部分包括了chart下载,和制作chart包相关命令

#下载chart包
helm pull bitnami/nginx

#检查chart包语法
helm lint 

#渲染模式测试chart包
helm install --debug --dry-run testchart .

#创建chart包
helm create testchart

#上传chart包到私服
helm push nginx-9.4.1.tgz chartmuseum --debug

3.2 chart 信息命令

chart在helm里面是一种资源集合,也是一种格式,在安装使用之前我们可以查看 相关的信息

#查看chart包信息,显示chart包的版本,源码等信息
helm show chart bitnami/nginx

3.3 release信息命令

release在helm的概念是已经部署了的chart(不包括k8s是否部署成功),此类命令在部署后排错用,因为此类命令显示的信息 其他命令也有实现,所有使用不多

#查看release 注释
helm get notes centos-nginx

#查看release 修改的值 (如果是install之后没修改过,就是null)
helm get values centos-nginx

#查看release 钩子
helm get hooks center-nginx

#查看manifest 配置文件,这个manifest配置文件就是kubernetes中资源配置文件,名称一样
helm get manifest centos-nginx

#查看release 所有信息,就是上面4个命令的值的聚合
helm get all centos-nginx

3.4 插件命令

#安装插件
helm plugin install https://github.com/chartmuseum/helm-push.git

#插件列表
helm plugin list

#卸载插件
helm plugin uninstall pluginName

#更新插件
helm plugin update pluginName

4.案例练习 helm安装 nfs storageclasses

# 1.安装nfs   
yum install nfs-utils rpcbind -y
systemctl  enable  nfs-server  rpcbind
echo "/data 10.0.0.0/24(rw,sync,no_root_squash)" >  /etc/exports 
systemctl  start  nfs-server rpcbind 

# 2.安装nfs storageclasses
helm pull stable/nfs-client-provisioner --untar
cd nfs-client-provisioner
vim values.yaml 
...
nfs:  server: 10.0.0.5
        path: /data/nfs 
        mountOptions:
...
helm install nfs -f values.yaml .

5.请参考下表来确定哪个版本的Helm与您的集群兼容。

Helm 版本支持的 Kubernetes 版本
3.8.x 1.23.x - 1.20.x
3.7.x 1.22.x - 1.19.x
3.6.x 1.21.x - 1.18.x
3.5.x 1.20.x - 1.17.x
3.4.x 1.19.x - 1.16.x
3.3.x 1.18.x - 1.15.x
3.2.x 1.18.x - 1.15.x
3.1.x 1.17.x - 1.14.x
3.0.x 1.16.x - 1.13.x
2.16.x 1.16.x - 1.15.x
2.15.x 1.15.x - 1.14.x
2.14.x 1.14.x - 1.13.x
2.13.x 1.13.x - 1.12.x
2.12.x 1.12.x - 1.11.x
2.11.x 1.11.x - 1.10.x
2.10.x 1.10.x - 1.9.x
2.9.x 1.10.x - 1.9.x
2.8.x 1.9.x - 1.8.x
2.7.x 1.8.x - 1.7.x
2.6.x 1.7.x - 1.6.x
2.5.x 1.6.x - 1.5.x
2.4.x 1.6.x - 1.5.x
2.3.x 1.5.x - 1.4.x
2.2.x 1.5.x - 1.4.x
2.1.x 1.5.x - 1.4.x
2.0.x 1.4.x - 1.3.x