Isolated-Network

Helm 離線使用

  • March 25, 2019

環境

[root@kubernetes-master-001 centos]# helm version
Client: &version.Version{SemVer:"v2.9.0", GitCommit:"f6025bb9ee7daf9fee0026541c90a6f557a3e0bc", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.9.0", GitCommit:"f6025bb9ee7daf9fee0026541c90a6f557a3e0bc", GitTreeState:"clean"}

[root@kubernetes-master-001 centos]# cat /etc/*-release | tail -n 1
CentOS Linux release 7.4.1708 (Core)

問題

我正在嘗試在離線環境中設置 helm,但我被卡住了。

我似乎成功通過了這init一步,但任何呼叫都install失敗了:

[root@kubernetes-master-001 centos]# export HELM_HOME=/root/.helm
[root@kubernetes-master-001 centos]# helm init --service-account tiller --wait -i $local_registry/kubernetes-helm/tiller:v2.9.0 --skip-refresh
Creating /root/.helm
Creating /root/.helm/repository
Creating /root/.helm/repository/cache
Creating /root/.helm/repository/local
Creating /root/.helm/plugins
Creating /root/.helm/starters
Creating /root/.helm/cache/archive
Creating /root/.helm/repository/repositories.yaml
Adding stable repo with URL: https://kubernetes-charts.storage.googleapis.com
Adding local repo with URL: http://127.0.0.1:8879/charts
$HELM_HOME has been configured at /root/.helm.
Tiller (the Helm server-side component) has been installed into your Kubernetes Cluster.
Please note: by default, Tiller is deployed with an insecure 'allow unauthenticated users' policy.
For more information on securing your installation see: https://docs.helm.sh/using_helm/#securing-your-helm-installation
Happy Helming!
[root@kubernetes-master-001 centos]# helm install $local_HTTP_server/nginx-ingress-869c634517dbeb94c4a759fcfb69c44da38007ed.tgz --debug --name my-nginx --set rbac.create=true
[debug] Created tunnel using local port: '34825'
[debug] SERVER: "127.0.0.1:34825"
[debug] Original chart version: ""
Error: no cached repo found. (try 'helm repo update'). open /root/.helm/repository/cache/stable-index.yaml: no such file or directory

這可以在以下位置找到$HELM_HOME

[root@kubernetes-master-001 centos]# find "$HELM_HOME" -type f
/root/.helm/repository/local/index.yaml
/root/.helm/repository/repositories.yaml

有沒有人看到這個解決方案?

因此,基於此 github 評論,我執行了一個(骯髒的)解決方法:

該程序$HELM_HOME/repository/local/index.yaml創建了一個文件。helm init

[root@kubernetes-master-001 centos]# cat "$HELM_HOME/repository/local/index.yaml"
apiVersion: v1
entries: {}
generated: 2018-06-25T11:48:14.734541008Z

我複制了它@ $HELM_HOME/repository/cache/stable-index.yaml

cp "$HELM_HOME/repository/local/index.yaml" "$HELM_HOME/repository/cache/stable-index.yaml"

之後效果很好:

[root@kubernetes-master-001 centos]# helm install $local_HTTP_server/nginx-ingress-869c634517dbeb94c4a759fcfb69c44da38007ed.tgz --debug --name my-nginx --set rbac.create=true
[debug] Created tunnel using local port: '42893'
[debug] SERVER: "127.0.0.1:42893"
[debug] Original chart version: ""
[debug] Fetched $local_HTTP_server/nginx-ingress-869c634517dbeb94c4a759fcfb69c44da38007ed.tgz to /root/.helm/cache/archive/nginx-ingress-869c634517dbeb94c4a759fcfb69c44da38007ed.tgz
[debug] CHART PATH: /root/.helm/cache/archive/nginx-ingress-869c634517dbeb94c4a759fcfb69c44da38007ed.tgz
NAME:   my-nginx
REVISION: 1
RELEASED: Mon Jun 25 11:49:27 2018
CHART: nginx-ingress-0.20.3
. . .
. . .
. . .
LAST DEPLOYED: Mon Jun 25 11:49:27 2018
NAMESPACE: default
STATUS: DEPLOYED
. . .
. . .
. . .

引用自:https://serverfault.com/questions/918061