Kind is an app used for creating development and single command installation Kubernetes clusters, using a Docker container that allows us to quickly create a new Kubernetes cluster.
Kind has a simple CLI to create the cluster but sometimes we want to iterate to create a cluster or back fast to a configuration state.
For it is possible to use Terraform to manage Kind cluster with the provider Terraform provider - tehcyx/kind that is simple to create the Kind cluster, the simplest use of the provider:
|
|
Kind inside the lib uses Docker CLI to manage container Github - kubernetes-sigs/kind - provider.go and Docker CLI interact with Docker Daemon.
Then Terraform uses Kind lib that creates the cluster using Docker daemon inside the host that runs Terraform, but if I want to create a Kind cluster inside a remote host?
For it Docker CLI has the option to define an environment variable named DOCKER_HOST to determine the docker daemon target for CLI Docker CLI - options
With it, we can configure an SSH KEY with another host, an example of how to do this is Use Remote Docker Host With SSH.
With SSH configured is possible to define the DOCKER_HOST like that:
|
|
And configure the Terraform resource with parameters that will allow us to connect to Kubernetes from outside the host (The way that Kind expected by default):
|
|
Then after terraform apply (in a host with docker already installed), it is possible to change the kubeconfig generated in ~/.kube/config for the cluster, commenting certificate-authority-data and add insecure-skip-tls-verify to access the cluster.
|
|