kindで複数ワーカーノードのKubernetesクラスター構築

 article  Comments Off on kindで複数ワーカーノードのKubernetesクラスター構築
Aug 172020
 

先の記事でPodman環境のkindでcreate clusterを実施しましたが、コントロールプレーンノードのみで構成されており、クラスターぽくありません。

設定ファイルを用意してワーカーノードのロールを指定することで、ワーカーノードもコンテナーとして起動することができます。

設定ファイルはkindのリポジトリーに例がありますので、そちらをダウンロードします。

# curl -RO https://raw.githubusercontent.com/kubernetes-sigs/kind/master/site/content/docs/user/kind-example-config.yaml

ダウンロードした設定ファイルはワーカーノードが3個指定されています。そのままの設定でクラスターを作成してみます。

# export KIND_EXPERIMENTAL_PROVIDER=podman
# kind create cluster --config kind-example-config.yaml
enabling experimental podman provider
Creating cluster "kind" …
✓ Ensuring node image (kindest/node:v1.18.8) 🖼
✓ Preparing nodes 📦 📦 📦 📦
✓ Writing configuration 📜
✓ Starting control-plane 🕹
✓ Installing CNI 🔌
✓ Installing StorageClass 💾
✓ Joining worker nodes 🚜
Set kubectl context to "kind-kind" You can now use your cluster with:

kubectl cluster-info --context kind-kind

Thanks for using kind! 😊
#

kubectlやpodmanコマンドで確認するとworkerノードが3つ起動していることが確認できます。

# kubectl get nodes
NAME                 STATUS   ROLES    AGE   VERSION
kind-control-plane   Ready    master   83m   v1.18.2
kind-worker          Ready    <none>   82m   v1.18.2
kind-worker2         Ready    <none>   82m   v1.18.2
kind-worker3         Ready    <none>   82m   v1.18.2
# podman ps
CONTAINER ID  IMAGE                                                                                           COMMAND  CREATED            STATUS                PORTS                      NAMES
05b58d328d89  docker.io/kindest/node@sha256:7b27a6d0f2517ff88ba444025beae41491b016bc6af573ba467b70c5e8e0d85f           About an hour ago  Up About an hour ago  127.0.0.1:35181->6443/tcp  kind-control-plane
391ad6c545fa  docker.io/kindest/node@sha256:7b27a6d0f2517ff88ba444025beae41491b016bc6af573ba467b70c5e8e0d85f           About an hour ago  Up About an hour ago                             kind-worker2
42b8cad2dd06  docker.io/kindest/node@sha256:7b27a6d0f2517ff88ba444025beae41491b016bc6af573ba467b70c5e8e0d85f           About an hour ago  Up About an hour ago                             kind-worker
c8035f2f3cb5  docker.io/kindest/node@sha256:7b27a6d0f2517ff88ba444025beae41491b016bc6af573ba467b70c5e8e0d85f           About an hour ago  Up About an hour ago                             kind-worker3
# 

kind with Podman

 article  Comments Off on kind with Podman
Aug 172020
 

KubernetesにはDockerコンテナーをノードにしてクラスター構成をテストするためのkind(Kubernetes IN Docker)というプロジェクトがあります。

私はDockerではなくPodmanを使っているのですが、「podmanコマンドはdockerコマンドと互換なんだからいけんじゃね?」と安易に考えてPodmanでkindを試すと以下のissueに引っかかります(kind v0.8.1)。

[podman] kind 0.8.1 fails to download node image because podman is incompatible with image:tag@sha256 #1700

ちなみにArch Linuxにはkindという名前でaurパッケージが提供されていますが、こちらはdockerパッケージに依存するため、リポジトリからリリース版をダウンロードする方式で試しています。

issueに出ているworkaroundのKIND_EXPERIMENTAL_PROVIDER=podmanを指定してみると今度は別のエラーが。こちらもissueが出ています。

Cannot start with podman backend due to AppArmor errors #1757

どうやら最新版には修正が入っているようですので、最新版をgit cloneしてビルド、実行してみると無事動かすことができました!

$ git clone https://github.com/kubernetes-sigs/kind.git
$ cd kind
$ make build
$ sudo env KIND_EXPERIMENTAL_PROVIDER=podman ./bin/kind create cluster
using podman due to KIND_EXPERIMENTAL_PROVIDER
enabling experimental podman provider
Creating cluster "kind" …
✓ Ensuring node image (kindest/node:v1.18.8) 🖼
✓ Preparing nodes 📦
✓ Writing configuration 📜
✓ Starting control-plane 🕹️
✓ Installing CNI 🔌
✓ Installing StorageClass 💾
Set kubectl context to "kind-kind"
You can now use your cluster with:
kubectl cluster-info --context kind-kind
Thanks for using kind! 😊
$ sudo kubectl cluster-info --context kind-kind
Kubernetes master is running at https://127.0.0.1:46483
KubeDNS is running at https://127.0.0.1:46483/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
$

これからいろいろKubernetesも試してみようと思います。