《使用 chartmuseum 管理 Helm Chart》最先發布在:blog.ihypo.net/15686051021…html
chartmuseum 是一個開源的 Helm Chart Repository,支持多種後端存儲,包括 GCS,S3 等。node
chartmuseum 提供若干 API 以實現 Helm Chart Repository 的能力。linux
helm repo add chartmuseum http://localhost:8080/
時獲取 helm chart 列表helm install chartmuseum/mychart
時下載對應的 charthelm install with the --verify flag
得到 provenance 文件進行驗證gofish install chartmuseum
==> Installing chartmuseum...
🐠 chartmuseum 0.9.0: installed in 95.431145ms
複製代碼
# on Linux
curl -LO https://s3.amazonaws.com/chartmuseum/release/latest/bin/linux/amd64/chartmuseum
# on macOS
curl -LO https://s3.amazonaws.com/chartmuseum/release/latest/bin/darwin/amd64/chartmuseum
# on Windows
curl -LO https://s3.amazonaws.com/chartmuseum/release/latest/bin/windows/amd64/chartmuseum
chmod +x ./chartmuseum
mv ./chartmuseum /usr/local/bin
複製代碼
建立 systemd 文件:nginx
cat /etc/systemd/system/chartmuseum.service
[Unit]
Description=chartmuseum
Documentation=Helm Chart Repository
After=network.target
[Service]
EnvironmentFile=/etc/chartmuseum/config
ExecStart=/usr/local/bin/chartmuseum $OPTIONS
[Install]
WantedBy=multi-user.target
複製代碼
添加配置git
# cat /etc/chartmuseum/config
OPTIONS=--debug --port=9091 --storage="local" --storage-local-rootdir="/data/chartstorage"
複製代碼
啓動github
# systemctl daemon-reload
# systemctl restart chartmuseum.service
# systemctl status chartmuseum.service
* chartmuseum.service - chartmuseum
Loaded: loaded (/etc/systemd/system/chartmuseum.service; disabled; vendor preset: enabled)
Active: active (running) since Mon 2019-09-16 13:59:01 CST; 6s ago
Main PID: 26524 (chartmuseum)
Tasks: 7
Memory: 4.0M
CPU: 23ms
CGroup: /system.slice/chartmuseum.service
`-26524 /usr/local/bin/chartmuseum --debug --port=9091 --storage=local --storage-local-rootdir=/data/chartstorage
Sep 16 13:59:01 node-1 systemd[1]: Stopped chartmuseum.
Sep 16 13:59:01 node-1 systemd[1]: Started chartmuseum.
Sep 16 13:59:01 node-1 chartmuseum[26524]: 2019-09-16T13:59:01.875+0800 DEBUG Fetching chart list from storage {"repo": ""}
Sep 16 13:59:01 node-1 chartmuseum[26524]: 2019-09-16T13:59:01.875+0800 DEBUG No change detected between cache and storage {"repo": ""}
Sep 16 13:59:01 node-1 chartmuseum[26524]: 2019-09-16T13:59:01.875+0800 INFO Starting ChartMuseum {"port": 9091}
複製代碼
docker run --rm -it \
-p 8080:8080 \
-e DEBUG=1 \
-e STORAGE=local \
-e STORAGE_LOCAL_ROOTDIR=/charts \
-v $(pwd)/charts:/charts \
chartmuseum/chartmuseum:latest
複製代碼
helm repo add chartmuseum http://172.16.106.1:9091
複製代碼
經過請求 chartmuseum 的 api 上傳 chart:docker
# curl --data-binary "@confluence-6.15.9.tgz" http://172.16.106.1:9091/api/charts
{"saved":true}
複製代碼
更新本地緩存而後能夠查看已有的 charts:windows
# helm repo update
Hang tight while we grab the latest from your chart repositories...
...Skip local chart repository
...Successfully got an update from the "chartmuseum" chart repository
...Successfully got an update from the "stable" chart repository
Update Complete.
# helm search chartmuseum/
NAME CHART VERSION APP VERSION DESCRIPTION
chartmuseum/confluence 6.15.9 1.16.0 A Helm chart for Kubernetes
chartmuseum/jira 8.3.3 1.16.0 A Helm chart for Kubernetes
複製代碼
# helm install chartmuseum/confluence
NAME: bold-lambkin
LAST DEPLOYED: Mon Sep 16 14:49:34 2019
NAMESPACE: default
STATUS: DEPLOYED
RESOURCES:
==> v1/Pod(related)
NAME READY STATUS RESTARTS AGE
bold-lambkin-75d85978d9-spt6r 0/1 Pending 0 1s
==> v1/Service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
bold-lambkin NodePort 10.105.153.159 <none> 8090:30905/TCP 1s
==> v1beta2/Deployment
NAME READY UP-TO-DATE AVAILABLE AGE
bold-lambkin 0/1 0 0 1s
NOTES:
1. Get the application URL by running these commands:
複製代碼
chartmuseum 支持使用 --depth
定義 chart url 的層級深度,所以能夠利用這個深度來實現多租戶。後端
在啓動時能夠指定 --depth=2
,來定義一個 組織/倉庫 的二層結構:api
chartmuseum --debug --depth=2 --storage="local" --storage-local-rootdir=./charts
複製代碼
chart 的層級結構:
charts
├── org1
│ ├── repoa
│ │ └── nginx-ingress-0.9.3.tgz
├── org2
│ ├── repob
│ │ └── chartmuseum-0.4.0.tgz
複製代碼
上傳 Chart 的區別:
curl -F "chart=@mychart-0.1.0.tgz" http://localhost:8080/api/org1/repoa/charts
複製代碼