helm 部署 使用 记录

时间:2022-06-20 07:11:29

0.概念:Helm作为一个包管理工具, 它把Kubernetes资源(比如deployments、services或 ingress等) 打包到一个chart中,方便我们将其chart保存到chart仓库用来存储和分享

1.服务端安装:

curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get > get_helm.sh

chmod 700 get_helm.sh
./get_helm.sh

2.客户端安装

wget https://storage.googleapis.com/kubernetes-helm/helm-v2.10.0-linux-amd64.tar.gz

 tar -zxf helm-v2.10.0-linux-amd64.tar.gz

 mv linux-amd64/helm /usr/local/bin/ 

3.使用记录

[root@pserver78 site2powerone]# helm list  #列出所有kubernetes部署

interested-chipmunk 1       Wed Dec 12 19:27:31 2018 DEPLOYED site2powerone-0.1.0 default 

 helm delete  interested-chipmunk  --purge # 删除部署

3.3 创建新的chart 

helm create  site3powerone 

3.4 cat values.yaml

[root@pserver78 site2powerone]# cat values.yaml |egrep -v '#|^$'
replicaCount: 1
image:
repository: harbor.abc.com/pub/poweronesite
tag: end
pullPolicy: IfNotPresent
service:
type: ClusterIP
port: 80
ingress:
enabled: false
annotations: {}
path: /
hosts:
- site2powerone.mz.abc.com
tls: []
resources: {}
nodeSelector: {}
tolerations: []
affinity: {}

3.部署公司OA:架构 --  client -- front(tomcat) -- backend(mysql)

[root@pserver78 oa]# tree -c
.
├── charts
│   └── oa-db
│   ├── Chart.yaml
│   ├── README.md
│   ├── templates
│   │   ├── deployment.yaml
│   │   ├── _helpers.tpl
│   │   ├── NOTES.txt
│   │   ├── pvc.yaml
│   │   └── svc.yaml
│   └── values.yaml
├── Chart.yaml
├── README.md
├── requirements.yaml
├── templates
│   ├── appsrv-ingress.yaml
│   ├── appsrv-svc.yaml
│   ├── appsrv.yaml
│   ├── _helpers.tpl
│   └── NOTES.txt
└── values.yaml

关键文件:

3.1 

[root@pserver78 oa]# cat /root/.helm/cache/archive/oa/Chart.yaml
apiVersion: v1
appVersion: "7"
description: Deploy a basic tomcat application server with sidecar as web archive
container
icon: http://tomcat.apache.org/res/images/tomcat.png
maintainers:
- email: chenxuan@onecloud.cn
name: chenxuan
name: oa
version: 0.1.3

[root@pserver78 oa]# cat requirements.yaml
dependencies:
- name: oa-db
version: 0.1.0
repository: https://charts.abc.com
condition: oa-db.enabled
tags:
- oa

[root@pserver78 charts]# cat /root/.helm/cache/archive/oa/charts/oa-db/Chart.yaml
appVersion: latest
description: Fast, reliable, scalable, and easy to use open-source relational database
system.
engine: gotpl
home: https://www.mysql.com/
icon: https://www.mysql.com/common/logos/logo-mysql-170x115.png
keywords:
- database
- oa
maintainers:
- email: o.with@sportradar.com
name: olemarkus
name: oa-db
version: 0.1.0