How to deploy a KinD cluster in a docker swarm

290 Views Asked by At

I have deployed a docker swarm to Azure following the instructions in the quickstart guide. I also set up an ssh tunnel using the command from the quickstart:

ssh -L 2375:swarm-master-0:2375 -N [email protected] -p 2200

This works fine when I run docker commands:

$ DOCKER_HOST=:2375 docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

But when I do the same to create a kind cluster, it seems to fail when attempting to start the control plane because of the way docker swarm handles "dns" of its running containers:

$ DOCKER_HOST=:2375 kind create cluster
Creating cluster "kind" ...
 ✓ Ensuring node image (kindest/node:v1.21.1) 
 ✓ Preparing nodes 
 ✓ Writing configuration 
 ✗ Starting control-plane ️
ERROR: failed to create cluster: failed to init node with kubeadm: command "docker exec --privileged swarm-node-2/kind-control-plane kubeadm init --skip-phases=preflight --config=/kind/kubeadm.conf --skip-token-print --v=6" failed with error: exit status 1
Command Output: I0405 13:46:31.064697     211 initconfiguration.go:246] loading configuration from "/kind/kubeadm.conf"
[config] WARNING: Ignored YAML document with GroupVersionKind kubeadm.k8s.io/v1beta2, Kind=JoinConfiguration
hostport swarm-node-2/kind-control-plane:6443: host 'swarm-node-2/kind-control-plane' must be a valid IP address or a valid RFC-1123 DNS subdomain

Am I missing something to be able to deploy a plain old kind cluster to a docker swarm? I'd like to use a swarm because the plan is to have many of these clusters running at a time and would like to scale it up or down seamlessly.

0

There are 0 best solutions below