helm的安装和使用

发布时间 2023-11-07 16:16:43作者: 大司徒

一、helm概述

  Helm是Kubernetes的包管理器,类似于Python的pip、centos的yum,主要用来管理 Charts。

  Helm Chart是用来封装Kubernetes原生应用程序的一系列YAML文件。可以在你部署应用的时候自定义应用程序的一些Metadata,以便于应用程序的分发。对于应用发布者而言,可以通过Helm打包应用、管理应用依赖关系、管理应用版本并发布应用到软件仓库。

  官方文档:https://helm.sh/zh/

        https://docs.helm.sh/zh/docs/helm/helm_repo_index/

二、helm的安装及使用

安装

helm和k8s的版本依赖 https://helm.sh/zh/docs/topics/version_skew/

Helm 版本 支持的 Kubernetes 版本
3.12.x 1.27.x - 1.24.x
3.11.x 1.26.x - 1.23.x
3.10.x 1.25.x - 1.22.x
3.9.x 1.24.x - 1.21.x
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

从GitHub下载 https://github.com/helm/helm/releases

  从华为仓库下载 https://repo.huaweicloud.com/helm/

wget https://get.helm.sh/helm-v3.1.2-linux-amd64.tar.gz
tar -zxvf helm-v3.1.2-linux-amd64.tar.gz
cd linux-amd64
mv helm /usr/local/bin/
helm --help

安装nginx示例

#helm安装chats包仓库
helm repo add bitnami https://charts.bitnami.com/bitnami
#helm更新所有库
helm repo update  #有些版本可以指定更新那个库,例如:helm repo update bitnami
#搜索nginx,结果列表可以看到helm包版本对应的nginx的软件版本
helm search repo nginx --versions
#安装nginx
#               空间  实例名   仓库名/软件    版本号
helm install -n test nginx bitnami/nginx  --version 13.2.10

helm常用命令

helm create:   #在本地创建新的 chart;
helm dependency:  #管理 chart 依赖;
helm intall:#安装 chart;
helm lint:#检查 chart 配置是否有误;
helm list:#列出所有 release;
helm package:#打包本地 chart;
helm repo:#列出、增加、更新、删除 chart 仓库;
helm rollback:#回滚 release 到历史版本;
helm pull:#拉取远程 chart 到本地;
helm search:#使用关键词搜索 chart;
helm uninstall:#卸载 release;
helm upgrade:#升级 release;

helm常用的chats包仓库

traefik         https://helm.traefik.io/traefik
rancher-stable  https://releases.rancher.com/server-charts/stable
test            https://charts.kubesphere.io/test
elastic         https://helm.elastic.co
stable          http://mirror.azure.cn/kubernetes/charts
aliyun          https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
bitnami         https://charts.bitnami.com/bitnami
appstore        https://charts.grapps.cn