踩坑|Helm 安装 Rancher 过程中 403 的解决方案 | 因使用公网 IP 请求被 Cloudflare 拦截

问题描述 今天使用 Helm 安装 Rancher 过程中,突然报 failed to download

?nginx-ingress helm install rancher rancher-latest/rancher --logtostderr \ --namespace cattle-system \ --set hostname=rancher.local.wwj.icuError: failed to download "rancher-latest/rancher" (hint: running `helm repo update` may help)

helm 增加 --debug 参数,看到是因为访问 https://releases.rancher.com 403 了。
使用浏览器打开,发现被 Cloudflare 拦截了请求,需要验证。浏览器验证后,可以访问,但命令行没有办法进行验证。
?rancher helm install rancher rancher-latest/rancher \ --namespace cattle-system \ --set hostname=rancher.local.wwj.icuinstall.go:159: [debug] Original chart version: "" Error: failed to fetch https://releases.rancher.com/server-charts/latest/rancher-2.4.5.tgz : 403 Forbidden helm.go:84: [debug] failed to fetch https://releases.rancher.com/server-charts/latest/rancher-2.4.5.tgz : 403 Forbidden helm.sh/helm/v3/pkg/getter.(*HTTPGetter).get /home/circleci/helm.sh/helm/pkg/getter/httpgetter.go:73 helm.sh/helm/v3/pkg/getter.(*HTTPGetter).Get /home/circleci/helm.sh/helm/pkg/getter/httpgetter.go:41 helm.sh/helm/v3/pkg/downloader.(*ChartDownloader).DownloadTo /home/circleci/helm.sh/helm/pkg/downloader/chart_downloader.go:97 helm.sh/helm/v3/pkg/action.(*ChartPathOptions).LocateChart /home/circleci/helm.sh/helm/pkg/action/install.go:667 main.runInstall /home/circleci/helm.sh/helm/cmd/helm/install.go:171 main.newInstallCmd.func1 /home/circleci/helm.sh/helm/cmd/helm/install.go:117 github.com/spf13/cobra.(*Command).execute /go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:842 github.com/spf13/cobra.(*Command).ExecuteC /go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:950 github.com/spf13/cobra.(*Command).Execute /go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:887 main.main /home/circleci/helm.sh/helm/cmd/helm/helm.go:83 runtime.main /usr/local/go/src/runtime/proc.go:203 runtime.goexit /usr/local/go/src/runtime/asm_amd64.s:1357

由于机器目前无法切换网络,难道命令行只能这么被拦截了?
解决方案 以 rancher-latest v2.4.5 仓库为例,在浏览器手动下载以下文件:
  • https://releases.rancher.com/server-charts/latest/index.yaml
  • https://releases.rancher.com/server-charts/latest/rancher-2.4.5.tgz
以 http 的形式提供这两个文件,例如:
  • https://wuweijie.oss-cn-shenzhen.aliyuncs.com/kubernetes/rancher/index.yaml
  • https://wuweijie.oss-cn-shenzhen.aliyuncs.com/kubernetes/rancher/rancher-2.4.5.tgz
添加到 helm 仓库:
helm repo add rancher-latest-private https://wuweijie.oss-cn-shenzhen.aliyuncs.com/kubernetes/rancher

使用刚才添加的仓库安装:
helm install rancher rancher-latest-private/rancher \ --namespace cattle-system \ --set hostname=rancher.local.wwj.icu

踩坑|Helm 安装 Rancher 过程中 403 的解决方案 | 因使用公网 IP 请求被 Cloudflare 拦截
文章图片

【踩坑|Helm 安装 Rancher 过程中 403 的解决方案 | 因使用公网 IP 请求被 Cloudflare 拦截】问题解决!

    推荐阅读