Terraform cluster definition leveraging the Docker provider, using Docker containers as Kubernetes nodes.
This configuration can be used for having a convenient way to start a Kubernetes cluster in your local laptop, using regular Docker containers as nodes of your cluster.
The Docker daemon can be run in a Docker container in what is usually called
a DnD (Docker-in-Docker) configuration. This requires a special image/Dockerfile
that has been tweaked for starting systemd
as the the entrypoint. systemd
will them start
the Docker daemon as well as the kubelet
. Once all these elements are running, we can
run kubeadm
as in any other platform for starting a Kubernetes cluster.
-
Docker
You will need a functional Docker daemon running. Make sure the
${var.daemon}
is properly set, pointing to a daemon where you can launch containers. -
kubectl
A local kubectl executable.
By default all the machines will have the following users:
- All the instances have a
root
user withlinux
password.
The cluster will be made by these machines:
${var.master_count}
master nodes, withkubeadm
and thekubelet
pre-installed.${var.worker_count}
worker nodes, withkubeadm
and thekubelet
pre-installed.
You should be able to ssh
these machines, and all of them should be able to ping each other.
There is a bug in the Terraform Docker provider that
prevents containers from being stopped when using rm=true
,
so there are some problems when re-creating resources.