Kubernetes包管理工具helm安装和使用
官网地址
https://helm.sh/zh/
帮助文档地址
https://helm.sh/zh/docs/
Github地址
https://github.com/helm/
公共库地址
https://artifacthub.io/
- 环境查看
系统环境
# cat /etc/redhat-release
Rocky Linux release 9.3 (Blue Onyx)
# uname -a
Linux Rocky9K8SMaster003021 5.14.0-362.18.1.el9_3.0.1.x86_64 #1 SMP PREEMPT_DYNAMIC Sun Feb 11 13:49:23 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
软件环境
# kubectl version
Client Version: v1.30.2
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.25.16
WARNING: version difference between client (1.30) and server (1.25) exceeds the supported minor version skew of +/-1
# helm version
version.BuildInfo{Version:"v3.10.3", GitCommit:"835b7334cfe2e5e27870ab3ed4135f136eecc704", GitTreeState:"clean", GoVersion:"go1.18.9"}
# docker version
Client: Docker Engine - Community
Version: 25.0.3
API version: 1.44
Go version: go1.21.6
Git commit: 4debf41
Built: Tue Feb 6 21:14:42 2024
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 25.0.3
API version: 1.44 (minimum version 1.24)
Go version: go1.21.6
Git commit: f417435
Built: Tue Feb 6 21:13:06 2024
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.28
GitCommit: ae07eda36dd25f8a1b98dfbf587313b99c0190bb
runc:
Version: 1.1.12
GitCommit: v1.1.12-0-g51d5e94
docker-init:
Version: 0.19.0
GitCommit: de40ad0
- 前提条件
- 一个 Kubernetes 集群
- 确定你安装版本的安全配置
- 安装Helm
参考官网有多种安装方式
本次使用二进制版本安装
安装前确认Kubernetes集群版本选择对应的Helm版本下载
版本对应参考
https://helm.sh/zh/docs/topics/version_skew/
下载地址
https://github.com/helm/helm/releases
本次Kubernetes集群版本的1.25下载Helm3.10.3版本
# tar -xf helm-v3.10.3-linux-amd64.tar.gz
# cp linux-amd64/helm /usr/local/bin/
- 使用Helm
查找Chart
Helm 自带一个强大的搜索命令,可以用来从两种来源中进行搜索
helm search hub 从 Artifact Hub 中查找并列出 helm charts。 Artifact Hub中存放了大量不同的仓库。
helm search repo 从你添加(使用 helm repo add)到本地 helm 客户端中的仓库中进行查找。该命令基于本地数据进行搜索,无需连接互联网。
你可以通过运行 helm search hub 命令找到公开可用的charts:
查找wordpress可以使用的charts
# helm search hub wordpress -o yaml
加-o yaml参数获取输出详细信息
记录以下url
添加repo
# helm repo add bitnami https://charts.bitnami.com/bitnami
解析
# 添加repo
# helm repo add
# 自定义repo名称
# bitnami
# 上一步查询到的url地址
# https://charts.bitnami.com/bitnami
查看repo
# helm repo list
NAME URL
brigade https://brigadecore.github.io/charts
wordpresshttps://noor-muradi.github.io/Wordpress/
zentao https://hub.zentao.net/chartrepo/stable
bitnami https://charts.bitnami.com/bitnami
搜索chart查找wordpress
# helm search repo bitnami |grep wordpress
bitnami/wordpress 24.1.7 6.7.1 WordPress is the world's most popular blogging ...
bitnami/wordpress-intel 2.1.31 6.1.1 DEPRECATED WordPress for Intel is the most popu..
解析
# 搜索repo
# helm search repo
# 需要搜索的repo名如果不定义则搜索所有添加的repo
# bitnami
使用helm安装wordpress
# helm install wordpress bitnami/wordpress
解析
# 安装
# helm install
# 自定义名,即安装后的deployment名
# wordpress
# 需要安装的应用前面 前面是repo名后面是需要安装的应用wordpress
# bitnami/wordpress
查看Pod
# kubectl get pod|grep wordpress
wordpress-845794f964-wlwvd 0/1 Init:ImagePullBackOff 0 2m1s
wordpress-mariadb-0 0/1 Init:0/1 0 2m1s
查看创建的pvc
# kubectl get pvc data-wordpress-mariadb-0
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
data-wordpress-mariadb-0 Bound pvc-e9b0f991-b1fe-435b-8905-9d02ede278c1 8Gi RWO managed-nfs-storage 3m17s
排错:如果pod和pvc一直处于Pending状态则可能是没有获取到storageclass创建pvc
解决方法:设置默认storageclass
本次已经创建了storageclass为managed-nfs-storage
# kubectl patch storageclass managed-nfs-storage -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
查看storageclass已经设置为默认
查看安装状态
# helm status wordpress
其他常用命令
查看repo
# helm repo list
删除repo
# helm repo remove xxx
查看已经安装的应用
# helm list
卸载已经安装的应用
# helm uninstall xxx
- 实践操作
本次实践安装一个禅道
# 添加repo
# helm repo add https://hub.zentao.net/chartrepo/stable
# 搜索repo
# helm search repo zentao
# 安装
# helm install zentao zentao/zentao
查看svc端口
使用NodePort端口访问正常代表安装正常
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
2022-01-22 CentOS使用yum安装MySQL5.7报检索密钥错误解决方法
2019-01-22 jenkins编辑报错Exception when publishing, exception message的解决办法
2018-01-22 Python IDE软件PyCharm通用激活方法