helm 进阶操作

helm 进阶操作


1. 仓库管理

charts 仓库的增删改查

1.1 查看仓库列表 helm repo list:

[root@hw-apptest01-11-172 ~]# helm repo list
NAME      	URL                                                                      
local     	http://127.0.0.1:8879/charts                                             
incubator 	https://aliacs-app-catalog.oss-cn-hangzhou.aliyuncs.com/charts-incubator/
kiwigrid  	https://kiwigrid.github.io                                               
stable-ali	https://aliacs-app-catalog.oss-cn-hangzhou.aliyuncs.com/charts/          
elastic   	https://helm.elastic.co                                                  
stable    	https://burdenbear.github.io/kube-charts-mirror/ 

使用 helm repo list可以查看到仓库的url连接,设定的名称等。

1.2 删除某个仓库 helm repo remove 仓库名称移除某个仓库:

[root@hw-apptest01-11-172 efk]# helm repo list
NAME            URL
stable          https://aliacs-app-catalog.oss-cn-hangzhou.aliyuncs.com/charts/
local           http://127.0.0.1:8879/charts
incubator       https://aliacs-app-catalog.oss-cn-hangzhou.aliyuncs.com/charts-incubator/
kiwigrid        https://kiwigrid.github.io

[root@hw-apptest01-11-172 efk]# helm repo remove stable
"stable" has been removed from your repositories

1.3 新增仓库缓存 helm repo add

helm repo add stable https://burdenbear.github.io/kube-charts-mirror/ 
"incubator" has been added to your repositories

# helm 仓库并发单纯的tgz charts包,还需要用index.yaml 文件
[root@hw-apptest01-11-172 efk]#  helm repo add gstabe https://github.com/helm/charts/
Error: Looks like "https://github.com/helm/charts/" is not a valid chart repository or cannot be reached: Failed to fetch https://github.com/helm/charts/index.yaml : 404 Not Found

1.4 更新某个仓库地址 helm repo remove xxx && helm repo add

# 1.2 中我们删除了stable的阿里云仓库,现在我们修改为stable-ali
[root@hw-apptest01-11-172 efk]# helm repo add stable-ali https://aliacs-app-catalog.oss-cn-hangzhou.aliyuncs.com/charts/
"stable-ali" has been added to your repositories

[root@hw-apptest01-11-172 ~]# helm repo list
NAME      	URL                                                                      
local     	http://127.0.0.1:8879/charts                                             
incubator 	https://aliacs-app-catalog.oss-cn-hangzhou.aliyuncs.com/charts-incubator/
kiwigrid  	https://kiwigrid.github.io                                               
stable-ali	https://aliacs-app-catalog.oss-cn-hangzhou.aliyuncs.com/charts/          
elastic   	https://helm.elastic.co                                                  
stable    	https://burdenbear.github.io/kube-charts-mirror/ 

1.5 更新仓库缓存 helm repo update

helm 的charts仓库更新很频繁,有时候我们需要更新仓库缓存

[root@hw-apptest01-11-172 efk]#  helm repo update
Hang tight while we grab the latest from your chart repositories...
...Skip local chart repository
...Successfully got an update from the "stable" chart repository
...Successfully got an update from the "incubator" chart repository
...Successfully got an update from the "kiwigrid" chart repository
Update Complete. ⎈ Happy Helming!⎈

1.6 helm 搜索 charts 包 helm search

[root@hw-apptest01-11-172 ~]# helm search stable/elasticsearch
NAME                         	CHART VERSION	APP VERSION	DESCRIPTION                                                 
stable/elasticsearch         	1.29.0       	6.7.0      	Flexible and powerful open source, distributed real-time ...
stable/elasticsearch-curator 	1.5.0        	5.5.4      	A Helm chart for Elasticsearch Curator                      
stable/elasticsearch-exporter	1.4.1        	1.0.2      	Elasticsearch stats exporter for Prometheus 

# helm search xxx -l 查看各个版本
[root@hw-apptest01-11-172 ~]# helm search stable/elasticsearch -l
NAME                         	CHART VERSION	APP VERSION	DESCRIPTION                                                 
stable/elasticsearch         	1.29.0       	6.7.0      	Flexible and powerful open source, distributed real-time ...
stable/elasticsearch         	1.28.5       	6.7.0      	Flexible and powerful open source, distributed real-time ...
stable/elasticsearch         	1.28.4       	6.7.0      	Flexible and powerful open source, distributed real-time ...
stable/elasticsearch         	1.28.2       	6.7.0      	Flexible and powerful open source, distributed real-time ...
stable/elasticsearch         	1.28.1       	6.7.0      	Flexible and powerful open source, distributed real-time ...
stable/elasticsearch         	1.28.0       	6.7.0      	Flexible and powerful open source, distributed real-time ...
stable/elasticsearch         	1.27.3       	6.7.0      	Flexible and powerful open source, distributed real-time ...
stable/elasticsearch         	1.27.2       	6.7.0      	Flexible and powerful open source, distributed real-time ...
stable/elasticsearch         	1.26.2       	6.7.0      	Flexible and powerful open source, distributed real-time ...
stable/elasticsearch         	1.26.1       	6.7.0      	Flexible and powerful open source, distributed real-time ...
stable/elasticsearch         	1.26.0       	6.7.0      	Flexible and powerful open source, distributed real-time ...
stable/elasticsearch         	1.25.0       	6.7.0      	Flexible and powerful open source, distributed real-time ...
stable/elasticsearch         	1.24.0       	6.7.0      	Flexible and powerful open source, distributed real-time ...

2. 可用仓库列表

仓库名称 url 备注
stable 镜像国内可访问 https://burdenbear.github.io/kube-charts-mirror/ 官方仓库的镜像
stable阿里云镜像 https://aliacs-app-catalog.oss-cn-hangzhou.aliyuncs.com/charts/ 阿里云stable镜像,已停止更新
incubator https://aliacs-app-catalog.oss-cn-hangzhou.aliyuncs.com/charts-incubator/ incubator 阿里云镜像
stable 官方镜像 https://hub.kubeapps.com/ 国内无法使用
stable 微软云镜像 http://mirror.azure.cn/kubernetes/charts/ 微软云镜像
incubator 微软云镜像 http://mirror.azure.cn/kubernetes/charts-incubator/ 微软云镜像

自己做hlem镜像仓库参考:https://github.com/taowujie/kube-charts-mirror

3. 本地仓库的使用

3.1 helm 安装后,默认会添加一个本地仓库local仓库

local 仓库本地默认情况下没有对外监听,没有运行本地仓库地址

[root@hw-apptest01-11-172 local]# helm repo list
NAME      	URL                                                                      
local     	http://127.0.0.1:8879/charts                                             
incubator 	https://aliacs-app-catalog.oss-cn-hangzhou.aliyuncs.com/charts-incubator/
kiwigrid  	https://kiwigrid.github.io                                               
stable-ali	https://aliacs-app-catalog.oss-cn-hangzhou.aliyuncs.com/charts/          
elastic   	https://helm.elastic.co                                                  
stable    	https://burdenbear.github.io/kube-charts-mirror/                         
[root@hw-apptest01-11-172 local]# netstat -tnlp |grep 8879
[root@hw-apptest01-11-172 local]# 

3.2 启动本地仓库服务 helm serve

3.2.1 运行 helm serve 启动helm 仓库

[root@hw-apptest01-11-172 local]# helm serve
Regenerating index. This may take a moment.
Now serving you on 127.0.0.1:8879


# 默认情况下监听127.0.0.1的8879端口,路径~/.helm/repository/local/
## ctrl +c 进程将停止
### 新开窗口查看进程端口
[root@hw-apptest01-11-172 ~]# netstat -tnlp |grep 8879
tcp        0      0 127.0.0.1:8879          0.0.0.0:*               LISTEN      855/helm 
[root@hw-apptest01-11-172 ~]# ps -ef |grep helm
root        855 119876  0 14:15 pts/0    00:00:00 helm serve
root       1376    965  0 14:15 pts/1    00:00:00 grep --color=auto helm

# 查看仓库包
[root@hw-apptest01-11-172 ~]# curl http://127.0.0.1:8879

<html>
<head>
	<title>Helm Repository</title>
</head>
<h1>Helm Charts Repository</h1>
<ul>

</ul>
<body>
<p>Last Generated: 2019-07-04 14:15:04.794745966 &#43;0800 CST</p>
</body>
</html>
## 默认情况下没有可以用的包

3.1.2 helm 仓库启动命令参数:

helm serve --address 0.0.0.0:8879 --repo-path /data/helm/data

--address 指定IP地址 端口
--repo-path /xxx  指定启动charts仓库地址
# 可以使用 nohup参数进行最小化
nohup helm serve --address 0.0.0.0:8879 --repo-path /data/helm/data &> /data/helm/helm-server.log &

3.2 添加charts包到本地仓库中

charts仓库里面的包都是tgz格式的,我们模拟自己制作charts包上传的本地仓库

[root@hw-apptest01-11-172 stable]# tar -czf kibana.tgz kibana
[root@hw-apptest01-11-172 stable]# mv kibana.tgz ~/.helm/repository/local/
[root@hw-apptest01-11-172 ~]# nohup helm serve &

3.3 测试本地仓库

[root@hw-apptest01-11-172 ~]# helm search local/kibana
NAME        	CHART VERSION	APP VERSION	DESCRIPTION                                                 
local/kibana	3.2.0        	6.7.0      	Kibana is an open source data visualization plugin for El...

# web界面测试
[root@hw-apptest01-11-172 ~]# curl 127.0.0.1:8879
<html>
<head>
        <title>Helm Repository</title>
</head>
<h1>Helm Charts Repository</h1>
<ul>

  <li>kibana<ul>
    <li><a href="http://127.0.0.1:8879/kibana.tgz">kibana-3.2.0</a></li>
  </ul>
  </li>

</ul>
<body>
<p>Last Generated: 2019-06-23 18:18:26.147302181 &#43;0800 CST</p>
</body>
</html>

3.2.4 github中的文件转换为charts包,上传本地charts仓库

本地charts包的获取方式,手动制作charts包,其他机器拷贝charts包,github上获取charts包。
stable仓库的默认地址是国内无法访问,但k8s github官方项目的有一个charts项目上面存在stable的仓库文件。

地址:https://github.com/helm/charts.git,里面保存着官方的charts清单文件
使用 helm package elasticsearch自动打包上传到本地仓库

# git clone https://github.com/helm/charts.git
[root@hw-apptest01-11-172 Git]# cd charts/
[root@hw-apptest01-11-172 charts]# ls
code-of-conduct.md  CONTRIBUTING.md  incubator  LICENSE  OWNERS  PROCESSES.md  README.md  REVIEW_GUIDELINES.md  stable  test
[root@hw-apptest01-11-172 charts]# cd stable/
[root@hw-apptest01-11-172 stable]# helm package elasticsearch
Successfully packaged chart and saved it to: /data/Git/charts/stable/elasticsearch-1.29.0.tgz

[root@hw-apptest01-11-172 stable]# helm repo update
Update Complete. ⎈ Happy Helming!⎈ 
[root@hw-apptest01-11-172 stable]# curl 127.0.0.1:8879

<html>
<head>
	<title>Helm Repository</title>
</head>
<h1>Helm Charts Repository</h1>
<ul>

  <li>elasticsearch<ul>
    <li><a href="http://127.0.0.1:8879/charts/elasticsearch-1.29.0.tgz">elasticsearch-1.29.0</a></li>
  </ul>
  </li>

  <li>kibana<ul>
    <li><a href="http://127.0.0.1:8879/kibana.tgz">kibana-3.2.0</a></li>
  </ul>
  </li>

</ul>
<body>
<p>Last Generated: 2019-07-04 16:22:48.141108297 &#43;0800 CST</p>
</body>
</html>
[root@hw-apptest01-11-172 stable]# helm search local/elasticsearch -l
NAME               	CHART VERSION	APP VERSION	DESCRIPTION                                                 
local/elasticsearch	1.29.0       	6.7.0      	Flexible and powerful open source, distributed real-time ...

参考:https://blog.csdn.net/u011659193/article/details/87893911

3.2.5 更新 index.yaml 文件 helm repo index

helm 仓库会加载index.yaml 在检索不通版本的charts包,当我们手动生产tag包,上传到local目录后需要刷新index.yaml

[root@hw-apptest01-11-172 stable]# cd ~/.helm/repository/local/
[root@hw-apptest01-11-172 local]# ls
elasticsearch-1.29.0.tgz  index.yaml  kibana.tgz
[root@hw-apptest01-11-172 local]# helm repo index .
[root@hw-apptest01-11-172 local]# ls
elasticsearch-1.29.0.tgz  index.yaml  kibana.tgz

3.3 github开源项目,制作helm镜像仓库

地址:https://github.com/taowujie/kube-charts-mirror

4. helm 安装release 的几种方式

4.1 正常的镜像

helm fetch 应用名
helm install --name=xx --namespace=xx -f xx/value.yml 仓库/应用名

4.2 加版本号

helm install --name=xx --namespace=xx -f xx/value.yml xxx --version=xxxx

[root@hw-apptest01-11-172 elasticsearch]# helm install --name=elstest --namespace=efk -f values.yaml stable/elasticsearch --version=1.28.5
NAME:   elstest
LAST DEPLOYED: Wed Jun 26 21:53:35 2019
NAMESPACE: efk
STATUS: DEPLOYED

......

4.3 指定charts包文件

helm install --name=xx --namespace=xx -f xx/value.yml xxx.tgz

[root@hw-apptest01-11-172 elasticsearch]# helm install --name=elstest --namespace=efk -f values.yaml ../elasticsearch-1.28.5.tgz 
NAME:   elstest
LAST DEPLOYED: Wed Jun 26 21:53:35 2019
NAMESPACE: efk
STATUS: DEPLOYED

......

4.4 指定chart包目录(解压目录)

helm install --name=xx --namespace=xx -f xx/value.yml xxx

[root@hw-apptest01-11-172 elasticsearch]# helm install --name=elstest --namespace=efk -f values.yaml .
NAME:   elstest
LAST DEPLOYED: Wed Jun 26 21:53:35 2019
NAMESPACE: efk
STATUS: DEPLOYED

......

5. helm常见操作

查找 helm search CHARTNAME
检查 helm inspect CHARTNAME
安装 helm install --name mem1 stable/memcached
获取状态信息 helm status mem1
列出 helm list [-a]
删除 helm delete [--purge] mem1
下载 helm fetch stable/redis
创建 helm create CHARTNAME
语法检测 helm lint CHARTNAME
打包 helm package CHARTNAME
显示release状态 helm status NAME
启动本地仓库 helm serve

猜你喜欢

转载自blog.csdn.net/weixin_43423965/article/details/105215970
今日推荐