Github Host Helm Chart

🏠 首页 / Git / 使用 GitHub 托管 helm-chart 仓库

使用 GitHub 托管 helm-chart 仓库 #

helm 官方文档:

  1. 创建 GitHub 仓库,例如:helm-charts,克隆到本地。
git clone [email protected]:[gh_id]/helm-charts.git
cd helm-charts
  1. 创建干净的 gh-pages 分支。
git checkout --orphan gh-pages
git rm -rf .
vim README.md
# helm-charts

## Usage

[Helm](https://helm.sh) must be installed to use the charts.  Please refer to
Helm's [documentation](https://helm.sh/docs) to get started.

Once Helm has been set up correctly, add the repo as follows:

```bash
helm repo add mycharts https://[gh_id].github.io/helm-charts
```

If you had already added this repo earlier, run `helm repo update` to retrieve
the latest versions of the packages.  You can then run`helm search repo
mycharts` to see the charts.

To install the mycharts chart:

```bash
helm install myapp mycharts/myapp
```

To uninstall the chart:

```bash
helm uninstall myapp
```
git add .
git commit -am "add README.md"
git push -u origin gh-pages
  1. 仓库启用 GitHub Pages 功能,选择 gh-pages 分支。

  2. charts 开发。

git checkout master
mkdir charts
cd charts
helm create myapp
cd ..
  1. 使用 GitHub Action 搭配 chart-releaser 功能,为我们自动发布 charts 版本。
mkdir -p .github/workflows
vim .github/workflows/release-chart.yaml
name: Release Charts

on:
  push:
    branches:
      - main

jobs:
  release:
    # depending on default permission settings for your org (contents being read-only or read-write for workloads), you will have to add permissions
    # see: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
    permissions:
      contents: write
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Configure Git
        run: |
          git config user.name "$GITHUB_ACTOR"
          git config user.email "$GITHUB_ACTOR@users.noreply.github.com"

      - name: Install Helm
        uses: azure/setup-helm@v3

      - name: Run chart-releaser
        uses: helm/[email protected]
        env:
          CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

需要提前将 GitHub Token 生成出来,并配置到仓库的 Secrets 中。

  1. 提交代码即可第一次发版。

  2. 之后对 charts 改动后,修改 Chart.yaml 中的 version 字段,helm-releaser 会检测版本改动,并自动发版。

参考 #


« Github Action 使用最佳实践

» GitHub 托管 helm-chart 仓库