My development cluster with libvirt and terraform
- libvirt with qemu
- terraform
- terraform-provider-libvirt
- alpine-make-vm-image
- k0sctl
alpine-make-vm-image needs root permissions. Currently doas
is used for this.
User should be in libvirt
group.
The libvirt network default
is used. It is assumed that the DNS server
for this is listening on 192.168.122.1.
The ssh key $HOME/.ssh/id_ed25519
is used for root logins. If this is
password protected you should add the key with:
eval $(ssh-add ~/.ssh/id_ed25519)
The file variables.tf
has some variables for the cluster:
variable | explanation |
---|---|
memory | amount of RAM (in megabytes) for ach virtual machine. |
vcpu | number of virtual CPUs for each virtual machine. |
controller_nodes | number of controllers in the kubernetes cluster |
worker_nodes | number of workers for the controller node |
Run make
. This will:
- build vm-image/alpine-cloud.img
- use
terraform apply
to spin up the virtual machines and feed them with a seed.iso image with cloud-init config (currently only hostname is set) - generate a
nodelist.txt
with the list of virtual machines hostnames - use
dig
to query the 192.168.122.1 DNS server for the ip address of the virtual machines. - generate a
k0sctl.yaml
config with the list of IP addresses. - execute
k0sctl
to spin up the cluster - generate a
kubeconfig
file forkubectl
or Lens.
To use the generated kubeconfig
run:
export KUBECONFIG=$PWD/kubeconfig
Now you can connect to the cluster with kubectl
:
kubectl get nodes