基于github搭建helm repository

创建仓库

通过 https://github.com/new 创建一个 repository; 比如:https://github.com/piaohua/helm-charts

创建 index.yaml 文件

1
2
3
git clone https://github.com/piaohua/helm-charts.git && cd helm-charts
echo 'apiVersion: v1' > index.yaml 
git add . && git commit -m "init index.yaml" . && git push origin master

修改 helm-charts 的github pages 设置

浏览器访问 chart 资源: https://piaohua.github.io/helm-charts/index.yaml

hello-chart

  1. 创建hello-chart
1
$ helm create hello-chart
  1. 修改hello-chart/Chart.yaml

  2. 修改hello-chart/values.yaml

  3. 校验Chart.yaml

1
$ helm lint
  1. 打包
1
$ helm package hello-chart --debug
  1. 更新index.yaml
1
$ helm repo index --url https://piaohua.github.io/helm-charts/ --merge index.yaml .
  1. 提交*.tgz & index.yaml
  2. 更新repo
1
2
$ helm repo update
$ helm search list
  1. 部署hello-chart
1
2
3
4
5
6
7
8
9
$ helm install piaohua/hello-chart --generate-name --namespace hello

$ export POD_NAME=$(kubectl get pods --namespace hello -l "app.kubernetes.io/name=hello-chart,app.kubernetes.io/instance=hello-chart-1595757801" -o jsonpath="{.items[0].metadata.name}")

$ kubectl --namespace hello port-forward $POD_NAME 8080:80

$ kubectl get deployment,rs,rc,pod -n hello

$ curl -X GET http://127.0.0.1:8080