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

## 前提条件：

1、已安装git 2、已注册github账户 3、安装helm（推荐helm3，下载地址：\[[https://github.com/helm/helm/releases/(https://github.com/helm/helm/releases/)](https://links.jianshu.com/go?to=https%3A%2F%2Fgithub.com%2Fhelm%2Fhelm%2Freleases%2F\(https%3A%2F%2Fgithub.com%2Fhelm%2Fhelm%2Freleases%2F\))）

## 操作步骤：

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

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

```python
[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目录

```bash
[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 链接

```bash
[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

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

### 6、设置github上helm-chart仓库的GitHub Pages（在仓库的settings里设置）

![](/files/cEcFzjtwbG0AcKYGxJd7)

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

```bash
[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
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://close.gitbook.io/yun-wei-bi-ji/kubernetes/helm/ru-he-shi-yong-github-zuo-wei-helm-de-chart-cang-ku.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
