如何使用github作为Helm的chart仓库

前提条件:

1、已安装git 2、已注册github账户 3、安装helm(推荐helm3,下载地址:[https://github.com/helm/helm/releases/(https://github.com/helm/helm/releases/)

操作步骤:

1、在github创建仓库,取名为helm-chart(略)

2、下载helm-chart仓库到本地

[root@kp tmp]# git clone https://github.com/helmchars/helm-charts.git
Cloning into 'helm-charts'...
remote: Enumerating objects: 108, done.
remote: Counting objects: 100% (108/108), done.
remote: Compressing objects: 100% (82/82), done.
remote: Total 108 (delta 33), reused 98 (delta 23), pack-reused 0
Receiving objects: 100% (108/108), 61.59 KiB | 0 bytes/s, done.
Resolving deltas: 100% (33/33), done.

3、创建chart目录

[root@kp tmp]# cd helm-charts/ && mkdir {nginx, test}
[root@kp helm-charts]# tree
.
.
├── index.yaml
├── nginx
   ├── nginx-dev
      ├── Chart.yaml
      ├── templates
         ├── deployment.yaml
         ├── _helpers.tpl
         ├── hpa.yaml
         ├── ingress.yaml
         ├── NOTES.txt
         ├── serviceaccount.yaml
         └── service.yaml
      └── values.yaml
└── test

4、打包chart包,生成仓库 url 链接

[root@kp nginx]# helm package nginx-dev
Successfully packaged chart and saved it to: /tmp/helm-charts/nginx/nginx-dev-0.1.0.tgz

[root@kp helm-charts]# helm repo index --url https://helmchars.github.io/helm-charts/ .
[root@kp helm-charts]# cat index.yaml 
apiVersion: v1
entries:
  nginx-dev:
  - apiVersion: v2
    appVersion: 1.16.0
    created: "2021-10-09T13:17:08.432357516+08:00"
    description: A Helm chart for Kubernetes
    digest: e423cab53f3ad6d5731787db81c72ba4eaafe56e08881e6ddf41cd1e29e5a734
    name: nginx-dev
    type: application
    urls:
    - https://helmchars.github.io/helm-charts/nginx/nginx-dev-0.1.0.tgz
    version: 0.1.0

5、push到github

git add .
git commit -m "创建test的chart包"
git push origin master

6、设置github上helm-chart仓库的GitHub Pages(在仓库的settings里设置)

7、本地添加自己的chart仓库

[root@kp ~]# helm repo list
Error: no repositories to show

[root@kp ~]# helm repo add myrepo https://helmchars.github.io/helm-charts
"myrepo" has been added to your repositories

[root@kp ~]# helm repo list
NAME    URL                                    
myrepo  https://helmchars.github.io/helm-charts

[root@kp ~]# helm search repo nginx
NAME                    CHART VERSION   APP VERSION     DESCRIPTION                
myrepo/nginx-dev        0.1.0           1.16.0          A Helm chart for Kubernetes

Last updated