This module deploys Kubernetes master and worker nodes as libvirt VMs. It then uses the testbox VM created by the libvirt-infra module to run kubekey and install a Kubernetes cluster on these nodes.
This module builds upon the infrastructure provisioned by the libvirt-infra module and performs the following actions:
- Provisions Kubernetes Nodes: Creates the specified number of master and worker node VMs using a base Ubuntu cloud image.
- Configures Nodes with Cloud-Init: Uses cloud-init to set up basic node configuration, including adding the public SSH key from the
testboxfor access. - Installs Kubernetes using KubeKey:
- Generates a
kubekeyconfiguration file (kubekey.yaml) based on the provided variables. - Copies the configuration and an installation script to the
testboxVM. - Executes the script on the
testboxto trigger thekubekeyinstallation process across all newly created nodes.
- Generates a
- Retrieves Kubeconfig: After a successful installation, it retrieves the
kubeconfigfile from thetestbox, modifies the API server address to point to the libvirt host (as configured by thelibvirt-inframodule's port forwarding), and saves it locally.
This module is intended to be used after the libvirt-infra module has been successfully applied.
terraform init
terraform applyUpon successful completion, the kubeconfig file for your new cluster will be available in the output directory within this module's path.
| Name | Version |
|---|---|
| terraform | >=1.6.5 |
| libvirt | 0.7.6 |
| remote | 0.2.1 |
| Name | Version |
|---|---|
| libvirt | 0.7.6 |
| local | 2.5.3 |
| null | 3.2.4 |
| remote | 0.2.1 |
No modules.
| Name | Type |
|---|---|
| libvirt_cloudinit_disk.masters | resource |
| libvirt_cloudinit_disk.workers | resource |
| libvirt_domain.masters | resource |
| libvirt_domain.workers | resource |
| libvirt_volume.masters | resource |
| libvirt_volume.masters_base | resource |
| libvirt_volume.workers | resource |
| libvirt_volume.workers_base | resource |
| local_file.k8s_install_script | resource |
| local_file.kubeconfig | resource |
| local_file.kubekey_config | resource |
| null_resource.testbox_install_k8s | resource |
| remote_file.kubeconfig | data source |
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| disable_kube_proxy | disable kubeproxy | string |
"true" |
no |
| image_download_base_url | the base url of the images | string |
n/a | yes |
| k8s_version | the version of the k8s | string |
n/a | yes |
| libvirt_host_ip | The IP address of the libvirt host. | string |
n/a | yes |
| libvirt_pool_name | The libvirt pool name. | string |
n/a | yes |
| libvirt_private_network_id | The libvirt private network id. | string |
n/a | yes |
| libvirt_root_private_key_path | The private key path of the libvirt host. | string |
n/a | yes |
| masters_info_list | The list of master nodes. | list(object({ |
n/a | yes |
| nodes_os_image_name | the name of the os image | string |
"ubuntu-22.04.3-kernel-5.15.0-92.iso" |
no |
| testbox_info | the testbox info | object({ |
n/a | yes |
| workers_info_list | The list of worker nodes. | list(object({ |
n/a | yes |
| Name | Description |
|---|---|
| k8s_api_server_ip | n/a |
| path_to_kubeconfig_file | n/a |