背景
お手軽kubernetesの最近の流行りは、kind (kubernetes in docker)だそうです。
ただし、かなり厳しいプロキシ環境で実行していたら、少しハマりました。 私の会社だけの状況かもしれないので、ニーズないかもしれませんが、今回は、その解説です。
環境
プロキシ環境下でのkindインストール手順
まず、kindをbrewでインストールしましょう。
brew install kind
次に、クラスタを構築します。ただ、その前に、プロキシの設定をしましょう。
公式ページのQuick startには、以下のように書かれています。
Note: If you set a proxy it would be used for all the connection requests. It's important that you define what addresses doesn't need to be proxied with the NO_PROXY variable, typically you should avoid to proxy your docker network range NO_PROXY=172.17.0.0/16
よって、まずはDockerにプロキシ情報とNO_PROXYを入れます。
NO_PROXYは、「Bypass proxy settings for these hosts & domains」の欄に、172.17.0.0/16と記載すればOKです。
HTTP_PROXYやHTTPS_PROXYは、その上の欄に記載しておきます。認証付きプロキシなら、http(s)://(ID):(PASS)@(URL):(PORT)です。設定したら、Docker desktopを再起動します。

これで行けるかと思い、kind create clusterとすると、「Starting control-plane」で数分止まり、その後以下のようなエラーが出るはずです。
153 round_trippers.go:443] GET https://kind-control-plane:6443/healthz?timeout=10s in 27 milliseconds
(このメッセージが多量に出たあと)
Unfortunately, an error has occurred:
I0710 14:02:51.404598 153 round_trippers.go:443] GET https://kind-control-plane:6443/healthz?timeout=10s in 27 milliseconds
time out waiting for the condition
This error is likely caused by:
- The kubelet is not running
- The kubelet is unhealthy due to a misconfiguration of the node in some way (required cgroups disabled)
(その後もエラーメッセージが続く)
kindでどこまでできるか分かっていませんが、1台の端末内でお試しの環境を構築したいだけなら、以下の付け焼き刃の方法で対応できます。
- bashのNO_PROXYに
kind-control-planeを追加 (export NO_PROXY=$NO_PROXY,kind-control-plane) /etc/hostsにkind-control-planeを追加 (echo "127.0.0.1 kind-control-plane" | sudo tee -a /etc/hosts)
すなわち、kind-control-planeにアクセスできないのは、kind-control-plane宛のパケットがプロキシを経由しているためです。
プロキシを経由しないよう、上記のように設定してやれば、kindでクラスタが構築できます。