NipGeihou's blog NipGeihou's blog
  • Java

    • 开发规范
    • 进阶笔记
    • 微服务
    • 快速开始
    • 设计模式
  • 其他

    • Golang
    • Python
    • Drat
  • Redis
  • MongoDB
  • 数据结构与算法
  • 计算机网络
  • 应用

    • Grafana
    • Prometheus
  • 容器与编排

    • KubeSphere
    • Kubernetes
    • Docker Compose
    • Docker
  • 组网

    • TailScale
    • WireGuard
  • 密码生成器
  • 英文单词生成器
🍳烹饪
🧑‍💻关于
  • 分类
  • 标签
  • 归档

NipGeihou

我见青山多妩媚,料青山见我应如是
  • Java

    • 开发规范
    • 进阶笔记
    • 微服务
    • 快速开始
    • 设计模式
  • 其他

    • Golang
    • Python
    • Drat
  • Redis
  • MongoDB
  • 数据结构与算法
  • 计算机网络
  • 应用

    • Grafana
    • Prometheus
  • 容器与编排

    • KubeSphere
    • Kubernetes
    • Docker Compose
    • Docker
  • 组网

    • TailScale
    • WireGuard
  • 密码生成器
  • 英文单词生成器
🍳烹饪
🧑‍💻关于
  • 分类
  • 标签
  • 归档
  • Linux

  • Docker

  • 云原生

  • Kubernetes

    • kubectl - 常用命令
    • 概念
    • 安装
    • 操作
    • 负载均衡
    • Service
    • Ingress(网关)
    • 存储抽象
    • 网络
    • 笔记

    • helm

      • 快速开始
        • 简介
        • 安装
          • Windows
        • 仓库(Repo)
          • 添加
          • 列表
          • 更新
          • 删除
        • chart包
          • 实例列表(list)
          • 搜索 - Artifact Hub
          • 搜索 - 仓库(search repo)
          • 详细信息(show)
          • 拉取(pull)
          • 安装(install、部署)
          • 安装方式
          • 重写参数
          • 升级(upgrade)
          • 更新方式
          • 更新脚本
          • 回滚(rollback)
          • 卸载(uninstall)
        • 参考
      • 最佳实践
      • 实践-jumpserver
    • 示例

  • KubeSphere

  • K3S

  • 笔记

  • PVE

  • 维修

  • DevOps

  • 云服务

  • 路由器

  • Hyper-V

  • Windows

  • macOS

  • 运维
  • Kubernetes
  • helm
NipGeihou
2023-10-09
目录

快速开始

# 简介

  • Kubernetes 包管理器,类似于 apt 、 yum
  • 和 kubectl 一样,它并不一定安装在 Kubernets 主机上,通过 k8s 证书访问 k8s 资源。

# 安装

# Windows

scoop install helm

# 仓库 (Repo)

# 添加

# 官方源,优先
helm repo add stable https://charts.helm.sh/stable

# 微软镜像源
helm repo add stable http://mirror.azure.cn/kubernetes/charts

# bitnami仓库
helm repo add bitnami https://charts.bitnami.com/bitnami

# 列表

helm repo list

# 更新

helm repo update

# 删除

helm repo remove [REPO1 [REPO2 ...]] [flags]

# 删除1个
helm repo remove bitnami

# 删除多个
helm repo remove bitnami douban

# chart 包

类似于 docker-compose.yaml

# 实例列表 (list)

helm list

# 搜索 - Artifact Hub

Artifact Hub (opens new window)

  • 在网站中搜索要安装的资源,如 mysql
  • 找到比较热门的,进入主页,如:https://artifacthub.io/packages/helm/bitnami/mysql (opens new window)
  • 安装:
    • 下方的 README 一般都会有 TL;DR 一键安装
    • 也可以点击右侧的 INSTALL 根据指引添加 Repo、再 install。
  • 右侧的 Default values 可查看 chart 的默认配置,根据需要覆盖

# 搜索 - 仓库 (search repo)

helm search repo 关键字

# 搜索tomcat chart包
$ helm search repo tomcat
NAME            CHART VERSION   APP VERSION     DESCRIPTION
stable/tomcat   0.4.3           7.0             DEPRECATED - Deploy a basic tomcat application ...
  • stable/tomcat 中的 stable 为添加的 repo 别名,说明在 stable 源中找到一个 tomcat 的 chart 包

# 详细信息 (show)

通过搜索功能,找到 chart 的完整名称(如 stable/tomcat )后,可通过下述操作查看详细信息。

# 查看chart基本信息(描述、主页地址、名称、版本等)
helm show chart stable/tomcat

# 查看values信息(value.yaml)
helm show values stable/tomcat

# 拉取 (pull)

# stable拉取最新版tomcat 并 解压(--untar);
# 当前目录得到tomcat文件夹
helm pull stable/tomcat --untar

# 安装 (install、部署)

Helm | Helm 安装 (opens new window)

helm install [NAME] [CHART] [flags]

# 安装方式

方式 1:在线安装 通过上面的搜索结果进行直接安装。

# helm install 别名 chart包名
helm install tomcat1 stable/tomcat

方式 2:压缩包

helm install tomcat2 tomcat-0.4.3.tgz

方式 3:解压的文件夹(未打包 chart 目录)

helm install tomcat3 ./tomcat

方式 4:文件 URL

helm install tomcat4 https://example.com/charts/tomcat-0.4.3.tgz

# 重写参数

上述的安装方式都是用的默认配置来运行 chart,实际场景还需要重写配置。

常用方式: -f 、 --values 文件重写

helm install -f myvalues.yaml myredis ./redis

# 重写参数可以多次使用,最右边优先级最高
helm install -f myvalues.yaml -f override.yaml myredis ./redis
Note

如 grafana 的 chart 默认就没有开启持久化,查阅文档可知通过设置 persistence.enabled 开启,只需创建一个 grafana.yaml 添加这属性,然后在 install 、 update 的时候携带 -f grafana.yaml 即可复写配置。

其他方式:

# --set
helm install --set name=prod myredis ./redis

# --set-string
helm install --set-string long_int=1234567890 myredis ./redis

# --set-file
helm install --set-file my_script=dothings.sh myredis ./redis

# --set-json
helm install --set-json 'master.sidecars=[{"name":"sidecar","image":"myImage","imagePullPolicy":"Always",ports":[{"name":"portname","containerPort":1234}]}]' myredis ./redis

# 升级 (upgrade)

更新有两个含义:

  1. 更新 chart 包
  2. 更新重写的配置
helm upgrade [RELEASE] [CHART] [flags]
Note

操作更新前记得先 helm repo update ,如果只是想更新 values.yaml 则不需要。

# 更新方式

方式 1:在线安装

helm upgrade -f tomcat.yaml happy-panda stable/tomcat

方式 2:本地安装

# 拉取最新的chart包到本地
helm pull stable/tomcat --untar

# 更新
helm upgrade -f tomcat.yaml tomcat1 ./tomcat

# 更新脚本

在配置目录中创建一个更新脚本,避免忘记参数。 helm_update.sh

#!/bin/bash
helm upgrade -f tomcat.yaml happy-panda stable/tomcat

# 回滚 (rollback)

更新后因种种原因需要回滚时使用

helm rollback <RELEASE> [REVISION] [flags]
# 查看历史版本
# helm history 实例名称
helm history dify

# 当前版本:REVISION字段为当前版本
helm list

# 回滚到某个版本
helm rollback 2

# 卸载 (uninstall)

helm uninstall RELEASE_NAME [...] [flags]

helm uninstall tomcat1

# 参考

  • Helm | Helm (opens new window)
上次更新: 2024/11/08, 02:29:38
cert-manager
最佳实践

← cert-manager 最佳实践→

最近更新
01
磁盘管理与文件系统
05-02
02
网络测试 - iperf3
05-02
03
Docker Swarm
04-18
更多文章>
Theme by Vdoing | Copyright © 2018-2025 NipGeihou | 友情链接
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式