基于 Github 和 Cloudflare Pages 搭建私人 Helm Chart 仓库


搭建 Helm 仓库

创建 Github 仓库

访问 https://github.com/new, 创建对应的 Github 仓库

初始化仓库

将仓库拉到本地

git clone https://github.com/<your user name>/helm-chart.git

创建一个 charts 文件夹,用于存放后续的 charts

mkdir charts

创建一个默认 chart 用于初始化整个 repo 的 index

如果你有已经写好的 charts,直接复制到此文件夹下即可

helm create charts/helloworld
.
└── charts
    └── helloworld
        ├── Chart.yaml
        ├── charts
        ├── templates
        │   ├── NOTES.txt
        │   ├── _helpers.tpl
        │   ├── deployment.yaml
        │   ├── ingress.yaml
        │   ├── service.yaml
        │   ├── serviceaccount.yaml
        │   └── tests
        │       └── test-connection.yaml
        └── values.yaml

5 directories, 9 files

检查一下整个配置

helm lint charts/*

打包发布应用

helm package charts/*

添加描述文件 index.yaml

如果你没有自定义域名,那么 GitHub Pages 的域名通常就是 <your username>.github.io

helm repo index --url https://<your github pages domain >/helm-chart
 .

提交并推送到仓库中

更新 Helm Repo Index

helm repo index --url  https://helm-chart.anubis.cafe . --merge ./index.yaml 

设置 Cloudflare Pages

部署成功后,尝试访问

<cloud flare pages domain>/index.yaml

在本地添加此仓库

helm repo add private https://<helm custom domain>/

发布到 Artifact Hub

进入 https://artifacthub.io/control-panel/repositories?page=1

创建一个新的存储库

拷贝此处的 repositories id

创建文件artifacthub-repo.yml

填入下列内容

# Artifact Hub repository metadata file
#
# Some settings like the verified publisher flag or the ignored packages won't
# be applied until the next time the repository is processed. Please keep in
# mind that the repository won't be processed if it has not changed since the
# last time it was processed. Depending on the repository kind, this is checked
# in a different way. For Helm http based repositories, we consider it has
# changed if the `index.yaml` file changes. For git based repositories, it does
# when the hash of the last commit in the branch you set up changes. This does
# NOT apply to ownership claim operations, which are processed immediately.
#
repositoryID: <上面生成的 ID>
owners: # (optional, used to claim repository ownership)
  - name: <Artifact Hub 用户名称>
    email: <Artifact Hub 账户邮箱>

发布更新后等待 Artifact Hub 自动同步即可

成功后如下图所示:


如果本文帮助到了你,帮我点个广告可以咩(o′┏▽┓`o)


评论
  目录