はじめに
IBM Cloud Kubernetes Service (IKS) の Web 端末で Helm CLI を使えるようにする方法です。
Web 端末には Helm CLI はインストールされていませんでした。
「IBM Cloud 資料 / IBM Cloud Kubernetes Service / Helm チャートを使用したサービスの追加 / パブリック・アクセスが可能なクラスターでの Helm のセットアップ 」に従ってセットアップを進めてみたところ、そのままだと Web 端末の環境ではうまくいかない部分がありましたので対応方法をこちらに残しておきます。
なお、IBM Cloud 資料で言うところの kubernetes グループに相当する stable リポジトリ (https://kubernetes-charts.storage.googleapis.com) を使えるようにはできませんでした。iks-charts と ibm-chart が使えれば OK という方向けです。
「ローカル・マシンに Helm CLI 外部リンク・アイコン をインストールします。」でのポイント
Helm のインストールガイドに従ってということですが、いくつか方法がありますね。
「From the Binary Releases」では問題なしでした。
「From the Binary Releases」は特に問題なかったです。こちらはそのまま展開するだけなので別に補足が必要なことはありません。Web 端末からも curl と sha256sum が使えますよ、とだけ申しておきましょう。
「From Script」はそのままではエラーになります。
「From Script」でもインストール出来ましたが、手直しが必要でした。単に面倒という理由でこちらはお勧めしません。
まず、そのまま実行してみるとこうなります。
$ curl -LO https://git.io/get_helm.sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0
100 7001 100 7001 0 0 2529 0 0:00:02 0:00:02 --:--:-- 4433
$ chmod 700 get_helm.sh
$ ./get_helm.sh
Downloading https://get.helm.sh/helm-v2.14.3-linux-amd64.tar.gz
./get_helm.sh: line 136: openssl: command not found
SHA sum of /tmp/helm-installer-MeBFgC/helm-v2.14.3-linux-amd64.tar.gz does not match. Aborting.
Failed to install helm
For support, go to https://github.com/helm/helm.
$
ははあ、openssl が無いそうです。
ヘルプを参照してみましょう。
$ ./get_helm.sh --help
Accepted cli arguments are:
[--help|-h ] ->> prints this help
[--version|-v <desired_version>] . When not defined it defaults to latest
e.g. --version v2.4.0 or -v latest
[--no-sudo] ->> install without sudo
$
役に立ちそうなのは --no-sudo があるということくらいでしょうか、これはスクリプトを覗かねばならないようです。
・・・、はい。中身を覗いてきました。
get_helm.sh で openssl を使ってチェックサムを計算しているところを sha256sum で置き換えます。(awk で拾うフィールドもずれていることに注意)
- local sum=$(openssl sha1 -sha256 ${HELM_TMP_FILE} | awk '{print $2}')
+ local sum=$(sha256sum ${HELM_TMP_FILE} | awk '{print $1}')
もう一点、デフォルトのインストール先は /usr/local/bin になるということ、シェル変数の 変数 HELM_INSTALL_DIR で設定できることもわかりました。
では、HELM_INSTALL_DIR は $HOME/bin にしちゃいましょう。get_helm.sh はご丁寧にもインストール前後にチェックしに行くのであらかじめ作って PATH にも追加してから実行します。
$ mkdir $HOME/bin
$ export PATH=$PATH:$HOME/bin
$ HELM_INSTALL_DIR=$HOME/bin ./get_helm.sh --no-sudo
Downloading https://get.helm.sh/helm-v2.14.3-linux-amd64.tar.gz
Preparing to install helm and tiller into ./bin
helm installed into ./bin/helm
tiller installed into ./bin/tiller
Run 'helm init' to configure helm.
$
以上で無事インストール出来ました。
「helm init」するときのポイント
ここもそのままではうまくいかないところです。
stable リポジトリとしてデフォルトで登録される https://kubernetes-charts.storage.googleapis.com へのアクセスしてるのかな?というところで止まっちゃいました。
次のいずれかのオプションを使うことで乗り切れます。
- 「--skip-refresh」をつける。
- 「--stable-repo-url」で iks-charts (https://icr.io/helm/iks-charts) あるいは ibm-charts (https://icr.io/helm/ibm-charts) の URL を指定して置き換える。
以下、物好きな人のための読み物。
そのまま helm init コマンドを実行すると、途中、次のようなメッセージで止まってしまいます。
指定されている URL へはアクセスできるのですが、原因はよくわかりませんでした。さらにその先の処理でアクセスする URL がブロックされているとかですかね・・・。
Adding stable repo with URL: https://kubernetes-charts.storage.googleapis.com
でも私が使いたいのは iks-charts, iks-charts なのだ。stable には用は無いので回避したい。
ヘルプを見てみましょう。
$ helm init --help
This command installs Tiller (the Helm server-side component) onto your
Kubernetes Cluster and sets up local configuration in $HELM_HOME (default ~/.helm/).
As with the rest of the Helm commands, 'helm init' discovers Kubernetes clusters
by reading $KUBECONFIG (default '~/.kube/config') and using the default context.
To set up just a local environment, use '--client-only'. That will configure
$HELM_HOME, but not attempt to connect to a Kubernetes cluster and install the Tiller
deployment.
When installing Tiller, 'helm init' will attempt to install the latest released
version. You can specify an alternative image with '--tiller-image'. For those
frequently working on the latest code, the flag '--canary-image' will install
the latest pre-release version of Tiller (e.g. the HEAD commit in the GitHub
repository on the master branch).
To dump a manifest containing the Tiller deployment YAML, combine the
'--dry-run' and '--debug' flags.
Usage:
helm init [flags]
Flags:
--automount-service-account-token auto-mount the given service account to tiller (default true)
--canary-image use the canary Tiller image
-c, --client-only if set does not install Tiller
--dry-run do not install local or remote
--force-upgrade force upgrade of Tiller to the current helm version
-h, --help help for init
--history-max int limit the maximum number of revisions saved per release. Use 0 for no limit.
--local-repo-url string URL for local repository (default "http://127.0.0.1:8879/charts")
--net-host install Tiller with net=host
--node-selectors string labels to specify the node on which Tiller is installed (app=tiller,helm=rocks)
-o, --output OutputFormat skip installation and output Tiller's manifest in specified format (json or yaml)
--override stringArray override values for the Tiller Deployment manifest (can specify multiple or separate values with commas: key1=val1,key2=val2)
--replicas int amount of tiller instances to run on the cluster (default 1)
--service-account string name of service account
--skip-refresh do not refresh (download) the local repository cache
--stable-repo-url string URL for stable repository (default "https://kubernetes-charts.storage.googleapis.com")
-i, --tiller-image string override Tiller image
--tiller-tls install Tiller with TLS enabled
--tiller-tls-cert string path to TLS certificate file to install with Tiller
--tiller-tls-hostname string the server name used to verify the hostname on the returned certificates from Tiller
--tiller-tls-key string path to TLS key file to install with Tiller
--tiller-tls-verify install Tiller with TLS enabled and to verify remote certificates
--tls-ca-cert string path to CA root certificate
--upgrade upgrade if Tiller is already installed
--wait block until Tiller is running and ready to receive requests
Global Flags:
--debug enable verbose output
--home string location of your Helm config. Overrides $HELM_HOME (default "/home/IBMid-310002TGYR/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
ふむふむ、--stable-repo-url を置き換えればよさそうですね。
でも代わりの URL 探すの面倒なので --skip-refresh でいってみましょう。
$ helm init --skip-refresh
Creating /home/IBMid-foo/.helm
Creating /home/IBMid-foo/.helm/repository
Creating /home/IBMid-foo/.helm/repository/cache
Creating /home/IBMid-foo/.helm/repository/local
Creating /home/IBMid-foo/.helm/plugins
Creating /home/IBMid-foo/.helm/starters
Creating /home/IBMid-foo/.helm/cache/archive
Creating /home/IBMid-foo/.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 /home/IBMid-foo/.helm.
Warning: Tiller is already installed in the cluster.
(Use --client-only to suppress this message, or --upgrade to upgrade Tiller to the current version.)
無事通過できました。
「helm repo update」するときのポイント
「--skip-refresh」で init を終わらせた人向けです。
やれやれ通過できたと安心していると、同じ理由だと思うのですが helm repo update するときにも止まっちゃいます。リポジトリのリストから stable を消してしまいましょう。
$ helm repo list
NAME URL
stable https://kubernetes-charts.storage.googleapis.com
local http://127.0.0.1:8879/charts
$ helm repo remove stable
"stable" has been removed from your repositories
$ helm repo list
NAME URL
local http://127.0.0.1:8879/charts
iks-charts と ibm-chart を追加した状態で試してみましょう。
$ helm repo add iks-charts https://icr.io/helm/iks-charts
"iks-charts" has been added to your repositories
$ helm repo add ibm-charts https://icr.io/helm/ibm-charts
"ibm-charts" has been added to your repositories
$ helm repo update
Hang tight while we grab the latest from your chart repositories...
...Skip local chart repository
...Successfully got an update from the "iks-charts" chart repository
...Successfully got an update from the "ibm-charts" chart repository
Update Complete.
$
update でも止まらなくなりました。
めでたしめでたし。
あとがき
IBM Cloud Kubernetes Service Diagnostics and Debug Tool を使用したテストの実行を試してみたくて作業していた際の副産物です。Web 端末からでも無事インストール出来ました。なお、環境は無料クラスター、ゾーンは mel01 です。