Install
-
下载安装包
chartmuseum
curl -LO https://s3.amazonaws.com/chartmuseum/release/latest/bin/linux/amd64/chartmuseum
将chartmuseum binary放到$PATH路径下即可
chmod +x ./chartmuseum
mv ./chartmuseum /usr/local/bin
- 使用本地存储,以systemd方式启动chartmuseum
chartmuseum.service文件
[root@tcz-dev-adam chartmuseum]# cat /etc/systemd/system/chartmuseum.service
[Unit]
Description=chartmuseum
Requires=network-online.target
After=network-online.target
[Service]
EnvironmentFile=/etc/chartmuseum/chartmuseum.config
User=root
Restart=allways
ExecStart=/usr/local/bin/chartmuseum $ARGS
ExecStop=/usr/local/bin/chartmuseum step-down
[Install]
WantedBy=multi-user.target
chartmuseum.config配置文件
[root@tcz-dev-adam chartmuseum]# cat /etc/chartmuseum/chartmuseum.config
ARGS=\
--port=8080 \
--storage="local" \
--storage-local-rootdir="/var/lib/chartmuseum/chartstorage" \
--log-json \
--basic-auth-user=admin \
--basic-auth-pass="xxxxxx"
--port: chartmuseum服务监听端口
--storage: local表示使用本地存储,使用其他存储参照点我
--storage-local-rootdir: 本地存储点路径,helm push chart的存储路径
--log-json: 日志显示为json格式
--basic-auth-user: 用户名(使用基本的认证方式,用户名+密码,使用证书方式参照点我)
--asic-auth-pass: 密码 (chartmuseum服务起来后,后续给helm添加repo时需要加上--username xxx --password ***)
启动chartmuseum
服务
[root@tcz-dev-adam chartmuseum]# systemctl start chartmuseum
[root@tcz-dev-adam chartmuseum]# systemctl status chartmuseum
● chartmuseum.service - chartmuseum
Loaded: loaded (/etc/systemd/system/chartmuseum.service; disabled; vendor preset: disabled)
Active: active (running) since 五 2019-05-17 18:20:45 CST; 19h ago
Process: 16144 ExecStop=/usr/local/bin/chartmuseum step-down (code=exited, status=1/FAILURE)
Main PID: 16156 (chartmuseum)
Tasks: 8
Memory: 9.2M
CGroup: /system.slice/chartmuseum.service
└─16156 /usr/local/bin/chartmuseum --port=8080 --storage=local --storage-local-rootdir=/var/lib/chartmuseum/chartstorage --log-json --basic-auth-user=admin --basic-a...
5月 17 18:20:45 tcz-dev-adam systemd[1]: Started chartmuseum.
5月 17 18:20:45 tcz-dev-adam systemd[1]: Starting chartmuseum...
5月 17 18:20:45 tcz-dev-adam chartmuseum[16156]: {"L":"INFO","T":"2019-05-17T18:20:45.568+0800","M":"Starting ChartMuseum","port":8080}
5月 17 18:25:19 tcz-dev-adam chartmuseum[16156]: {"L":"INFO","T":"2019-05-17T18:25:19.805+0800","M":"[1] Request served","path":"/index.yaml","comment":"","latency":"1.56...4daaad92a"}
5月 17 18:26:36 tcz-dev-adam chartmuseum[16156]: {"L":"ERROR","T":"2019-05-17T18:26:36.468+0800","M":"[2] Request served","path":"/api/charts","comment":"","latency":"3.7...42592f6f1"}
Hint: Some lines were ellipsized, use -l to show in full.
Apply
(1)安装helm push
插件
- 网络好的方式,简单方便
$ helm plugin install https://github.com/chartmuseum/helm-push
Downloading and installing helm-push v0.7.1 ...
https://github.com/chartmuseum/helm-push/releases/download/v0.7.1/helm-push_0.7.1_darwin_amd64.tar.gz
Installed plugin: push
- 网内不好的方式
a) 较慢的速度下载源码,git clone
或go get
均可
git clone https://github.com/chartmuseum/helm-push.git
或者,在$GOPATH路径下
go get github.com/chartmuseum/helm-push
b) 下载chartmuesum tar 包 点我
wget https://github.com/chartmuseum/helm-push/releases/download/v0.7.1/helm-push_0.7.1_linux_amd64.tar.gz
c) 解压tar包并放到指定目录下,./helm-push/download/
tar zxvf helm-push_0.7.1_linux_amd64.tar.gz
d) 修改helm-push/scripts/install_plugin.sh源码
#!/bin/sh -e
# Copied w/ love from the excellent hypnoglow/helm-s3
if [ -n "${HELM_PUSH_PLUGIN_NO_INSTALL_HOOK}" ]; then
echo "Development mode: not downloading versioned release."
exit 0
fi
version="$(cat plugin.yaml | grep "version" | cut -d '"' -f 2)"
#echo "Downloading and installing helm-push v${version} ..."
#url=""
#if [ "$(uname)" = "Darwin" ]; then
# url="https://github.com/chartmuseum/helm-push/releases/download/v${version}/helm-push_${version}_darwin_amd64.tar.gz"
#elif [ "$(uname)" = "Linux" ] ; then
# url="https://github.com/chartmuseum/helm-push/releases/download/v${version}/helm-push_${version}_linux_amd64.tar.gz"
#else
# url="https://github.com/chartmuseum/helm-push/releases/download/v${version}/helm-push_${version}_windows_amd64.tar.gz"
#fi
echo "Local installing helm-push v${version} ..."
url=""
if [ "$(uname)" = "Darwin" ]; then
url="https://github.com/chartmuseum/helm-push/releases/download/v${version}/helm-push_${version}_darwin_amd64.tar.gz"
elif [ "$(uname)" = "Linux" ] ; then
url="./helm-push/dl/helm-push_${version}_linux_amd64.tar.gz"
else
url="https://github.com/chartmuseum/helm-push/releases/download/v${version}/helm-push_${version}_windows_amd64.tar.gz"
fi
echo $url
mkdir -p "bin"
mkdir -p "releases/v${version}"
# Download with curl if possible.
#if [ -x "$(which curl 2>/dev/null)" ]; then
# curl -sSL "${url}" -o "releases/v${version}.tar.gz"
#else
# wget -q "${url}" -O "releases/v${version}.tar.gz"
#fi
cp download/helm-push_${version}_linux_amd64.tar.gz releases/v${version}.tar.gz
tar xzf "releases/v${version}.tar.gz" -C "releases/v${version}"
mv "releases/v${version}/bin/helmpush" "bin/helmpush" || \
mv "releases/v${version}/bin/helmpush.exe" "bin/helmpush"
e) 安装helm-push
插件,指定helm-push路径
$ helm plugin install https://github.com/chartmuseum/helm-push
Local installing helm-push v0.7.1 ...
./helm-push/dl/helm-push_v0.7.1_linux_amd64.tar.gz
Installed plugin: push
(2)添加chartmuseum
到 helm repo
[root@tcz-dev-adam scripts]# helm repo list
NAME URL
local http://127.0.0.1:8879/charts
telemetry http://dl.xxx.xxx.com/devops/kubernetes/charts
[root@tcz-dev-adam scripts]# helm repo add chartmuseum http://dl.xxx.xxx.com:8080 --username admin --password ******
"chartmuseum" has been added to your repositories
[root@tcz-dev-adam scripts]# helm repo list
NAME URL
local http://127.0.0.1:8879/charts
telemetry http://dl.xxx.xxx.com/devops/kubernetes/charts
chartmuseum http://dl.xxx.xxx.com:8080
(3) 使用 helm push
将开发好的chart push
到远端的 chartmuseum
[root@tcz-dev-adam charts-packages]# helm push kube-state-metrics-0.2.0.tgz chartmuseum
Pushing kube-state-metrics-0.2.0.tgz to chartmuseum...
Done.
查看chartmuseum
仓库中的chart
[root@tcz-dev-adam chartmuseum]# helm search chartmuseum/
NAME CHART VERSION APP VERSION DESCRIPTION
chartmuseum/kube-state-metrics 0.2.0 1.0 A Helm chart for Kubernetes
chartmuseum/metricbeat 1.0.1 1.0 A Helm Metricbeat chart for Kubernetes
chartmuseum/prometheus 0.2.0 1.0 A Helm Prometheus chart for Kubernetes
网友评论