您的位置:首页 > 游戏 > 游戏 > helm一键化部署pod

helm一键化部署pod

2024/9/24 21:26:26 来源:https://blog.csdn.net/Hai990218/article/details/142173207  浏览:    关键词:helm一键化部署pod

目录

概念

安装helm

helm的命令

自定义模版

回滚


概念

helm提供了一个模版,可以一键化的部署微服务。它通过打包的方式,把所有需要的yaml文件集合一起,然后一键部署,还可以支持回滚。

helm的本质:就是可以把k8s的部署可以配置,可以集成,可以动态的修改。

helm的三个概念:

Chart:用来部署安装k8s微服务的模版,类似于Linux里面的rpm包

Repository:仓库,用来保存Chart

Release:当我们使用Chart来部署微服务时,每部署一次就会有一个release。release可以理解为版本号。

安装helm

把metrics-server包拖入master主机上

tar -xf helm-v3.10.0-linux-amd64.tar.gz

cd linux-amd64/

mv helm /usr/local/bin/

vim /etc/profile

source /etc/profile

安装仓库和模版(仓库里面有模版chart)

helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo add stable http://mirror.azure.cn/kubernetes/charts
helm repo add aliyun https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
helm repo add incubator https://charts.helm.sh/incubator

helm的命令

helm repo list 查看仓库

helm repo update 更新当前所有仓库的chart

helm search repo aliyun   查看当前仓库里面有多少个chart

helm show chart aliyun/nginx-lego  查看chart详细信息

helm repo remove aliyun 删除仓库

helm install redis1 stable/redis -n default  从指定的仓库中部署redis的pod

helm uninstall redis1 删除redis的pod

helm upgrade nginx1 nginx1 更新配置文件

helm rollback nginx1 1 回滚

nginx1/
├── charts                                         依赖环境,一般为空
├── Chart.yaml                                  包含chart的元信息,比如chart的版本、名称等等
├── templates                                    包含了部署k8s的应用pod的模版文件
│   ├── deployment.yaml                   基于控制器部署
│   ├── _helpers.tpl
│   ├── hpa.yaml                                做hpa的监控,用于自动伸缩
│   ├── ingress.yaml                           对外访问
│   ├── NOTES.txt
│   ├── serviceaccount.yaml               创建服务账号
│   ├── service.yaml                            创建service的清单
│   └── tests
│       └── test-connection.yaml
└── values.yaml                             

values.yaml:我们的配置是在values里面完成,集合了yaml文件在这个配置里面,当配置完成之后,可以通过values配置把参数传给templates里面的模版文件,进行覆盖。

自定义模版

mkdir helm

cd /opt/helm/

helm create nginx1

yum- y install tree

tree nginx1/

cd nginx1/

vim values.yaml

cd /opt/helm/

修改service的配置文件:

vim nginx1/templates/service.yaml

如果设置nodeport需要添加,如下

helm lint nginx1/  检查语法有没有错误

failed 0 才表示没有错误

helm package nginx1/  打包

此时就会生成一个包:

helm部署命令:helm install nginx1 /opt/helm/nginx1-0.1.0.tgz 

如果修改了yaml文件,需要更新

helm upgrade nginx1 nginx1  更新

回滚

helm history nginx1  查看历史版本

helm rollback nginx1 1 回滚,把2版本回到1版本

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com