1. 简介

helm的作用就是把许多的定义比如svc,deployment,seucrt一次性全部定义好,放在源里统一管理,方便部署到其他集群上。

2. 安装helm

https://github.com/helm/helm/releases/tag/v3.2.1

tar zxf helm-v3.2.1-linux-amd64.tar.gz
mv linux-amd64/helm /usr/local/bin/

编辑/etc/profile
source <(helm completion bash)
保存退出
source /etc/profil

3. helm仓库

1
2
3
4
5
helm repo list

helm repo add azure http://mirror.azure.cn/kubernetes/charts/
helm repo add github https://burdenbear.github.io/kube-charts-mirror
helm repo add stable https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts

4. 实例

4.1 搜索镜像

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[root@node001 chap11-helm]# helm search repo mysql
NAME CHART VERSION APP VERSION DESCRIPTION
azure/mysql 1.6.9 5.7.30 DEPRECATED - Fast, reliable, scalable, and easy...
azure/mysqldump 2.6.2 2.4.1 DEPRECATED! - A Helm chart to help backup MySQL...
azure/prometheus-mysql-exporter 0.7.1 v0.11.0 DEPRECATED A Helm chart for prometheus mysql ex...
stable/mysql 0.3.5 Fast, reliable, scalable, and easy to use open-...
azure/percona 1.2.3 5.7.26 DEPRECATED - free, fully compatible, enhanced, ...
azure/percona-xtradb-cluster 1.0.8 5.7.19 DEPRECATED - free, fully compatible, enhanced, ...
azure/phpmyadmin 4.3.5 5.0.1 DEPRECATED phpMyAdmin is an mysql administratio...
stable/percona 0.3.0 free, fully compatible, enhanced, open source d...
stable/percona-xtradb-cluster 0.0.2 5.7.19 free, fully compatible, enhanced, open source d...
azure/gcloud-sqlproxy 0.6.1 1.11 DEPRECATED Google Cloud SQL Proxy
azure/mariadb 7.3.14 10.3.22 DEPRECATED Fast, reliable, scalable, and easy t...
stable/gcloud-sqlproxy 0.2.3 Google Cloud SQL Proxy
stable/mariadb 2.1.6 10.1.31 Fast, reliable, scalable, and easy to use open-...

4.2 下载镜像

1
helm pull azure/mysql --version 1.6.9

4.3 解压编辑

1
2
3
4
5
6
7
8
tar xf mysql-1.6.9.tgz

[root@node001 chap11-helm]# ll mysql
total 36
-rw-r--r-- 1 root root 406 Nov 14 2020 Chart.yaml
-rw-r--r-- 1 root root 23661 Nov 14 2020 README.md
drwxr-xr-x 3 root root 268 Sep 13 18:26 templates
-rw-r--r-- 1 root root 6171 Sep 13 18:24 values.yaml

4.4 安装

helm install 名字 chart目录

1
2
3
4
5
helm install mysql .

[root@node001 mysql]# helm ls
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
mysql chap11-helm 1 2022-09-13 18:27:27.3973064 +0800 CST deployed mysql-1.6.9 5.7.30

5. 私有源

5.1 打包chat

1
2
[root@node001 chap11-helm]# helm package mysql/
Successfully packaged chart and saved it to: /root/chap11-helm/mysql-1.6.9.tgz

5.2 创建nginx服务

创建仓库目录

1
mkdir mychat

启动服务

1
nerdctl run -d --name=c1 -p 8880:80 -v /mychart:/usr/share/nginx/html/mychart docker.io/nginx

5.3 创建chart索引文件

1
helm repo index . --url http://192.168.10.31:8880/mychart

移动paackage

1
cp index.yaml mysql-1.6.9.tgz /mychart/

5.4 添加私有仓库

1
helm repo add mychart http://192.168.10.31:8880/mychart

5.5 查看仓库

1
2
3
[root@node001 chap11-helm]# helm search repo mychart
NAME CHART VERSION APP VERSION DESCRIPTION
mychart/mysql 1.6.9 5.7.30 DEPRECATED - Fast, reliable, scalable, and easy...

6. prometheus

6.1 添加官方源

1
2
helm repo add stable https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts

6.2 下载chart

1
helm pull prometheus-community/kube-prometheus-stack

6.3 安装

编辑修改后安装

1
helm install prometheus kube-prometheus-stack

6.4 查看release

1
2
3
4
[root@node001 chap11-helm]# helm ls
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
mysql chap11-helm 1 2022-09-13 23:37:14.0590291 +0800 CST deployed mysql-1.6.9 5.7.30
prometheus chap11-helm 1 2022-09-14 00:04:46.9828275 +0800 CST deployed kube-prometheus-stack-20.0.1 0.52.0

6.5 修改svc

修改grafana的svc为LoadBalancer

1
2
3
[root@node001 chap11-helm]# kubectl get svc prometheus-grafana 
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
prometheus-grafana LoadBalancer 10.106.183.246 192.168.10.244 80:32592/TCP 9m23

6.6 获取密码

1
kubectl get secrets prometheus-grafana -o jsonpath='{.data.admin-password}'|base64 -d

7. 日志

ELK
Elasticsearch #是个开源分布式搜索引擎,存储日志及提供查询接口。
Logstash #是一个完全开源的工具,他可以对日志进行收集 发送给Elasticsearch.
Kibana #是一个开源和免费的,web界面的工具,可以让用户浏览Elasticsearch里的日志.
logstash性能低,消耗资源,且存在不支持消息队列缓存及存在数据丢失的问题
所以logstash一般可以用fluentd或者filebeat替代
EFK框架