helm的一些简单使用
说明
在 k8s 的体系中,是以 清单
的方式去 定义资源的,因此,使用 k8s 的重点就是 创建、使用、维护 清单
,原始的 k8s 资源清单就是用
官方文档
https://v3.helm.sh/zh/docs/helm/helm/
helm repo 操作
添加 repo
1
helm repo add xxx https://xxx.xx.xx/xx --username xxx --password xxx
查看现有 repo
1
helm repo ls
更新 repo ( 把远端charts元信息拉到本地缓存 )
1
helm repo update
在 helm 官方仓库搜索 charts
1
helm search hub xxx
在 repo 内搜索charts
1
2
3
4
5
6
7helm search repo xxreponame | grep xxx
# 或者
helm search repo xxx
# 或者
helm search repo xxx |grep xxreponame
helm 安装插件
查看已安装插件
1
helm plugin list
安装插件
1
helm plugin install https://xxx.xxx.xxx
推送私仓插件
1
2
3
4
5# 安装
helm plugin install https://github.com/chartmuseum/helm-push
# 使用
helm cm-push xxx https://xxx.xx.xx/xx/xxx
使用 helm 部署 charts
拉取 charts 包
1
helm pull xxrepo/xxname --untar
查看渲染出来的清单
1
helm template xx
模拟运行一下
1
helm install xxname --dry-run --namespace xxx xxrepo/xxname
部署
1
helm install xxname --namespace xxx --verify --set xx.xx=xx.xx --set xx.xx1=xx.xx1 -f xxvalues.yaml -f xx1values.yaml xxrepo/xxname
查看已部署的
1
helm list
卸载部署
1
helm uninstall xxname
helm 制作 charts
创建模板
1
helm create xxname
检查 charts 格式
1
helm lint xxname
下载依赖
1
helm dependency update
charts 组织方式
- Chart.yaml
- 用来描述 当前 charts
- 版本管理
- requirements.yaml
- 当前 chart 依赖的 charts
- charts
- 依赖的 charts 的 zip 包
- templates
- 渲染清单的模板
- values.yaml
- 用于渲染的可修改的值
charts template 语法
整体来说,是 golang template 的语法
有一些独特的方法,可以参考 https://helm.sh/zh/docs/chart_template_guide/getting_started/
一些好用的技巧
- helper 的使用
The most effective way to do it, is to do it.
— Amelia Earhart
本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!