Skip to content

isovalent/terraform-libvirt-k8s

Repository files navigation

Libvirt Kubernetes (k8s) Module

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.

Architecture

This module builds upon the infrastructure provisioned by the libvirt-infra module and performs the following actions:

  1. Provisions Kubernetes Nodes: Creates the specified number of master and worker node VMs using a base Ubuntu cloud image.
  2. Configures Nodes with Cloud-Init: Uses cloud-init to set up basic node configuration, including adding the public SSH key from the testbox for access.
  3. Installs Kubernetes using KubeKey:
    • Generates a kubekey configuration file (kubekey.yaml) based on the provided variables.
    • Copies the configuration and an installation script to the testbox VM.
    • Executes the script on the testbox to trigger the kubekey installation process across all newly created nodes.
  4. Retrieves Kubeconfig: After a successful installation, it retrieves the kubeconfig file from the testbox, modifies the API server address to point to the libvirt host (as configured by the libvirt-infra module's port forwarding), and saves it locally.

Usage

This module is intended to be used after the libvirt-infra module has been successfully applied.

terraform init
terraform apply

Upon successful completion, the kubeconfig file for your new cluster will be available in the output directory within this module's path.

Requirements

Name Version
terraform >=1.6.5
libvirt 0.7.6
remote 0.2.1

Providers

Name Version
libvirt 0.7.6
local 2.5.3
null 3.2.4
remote 0.2.1

Modules

No modules.

Resources

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

Inputs

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({
ipv4 = string
ipv6 = string
mac = string
hostname = string
}))
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({
public_ip = string
username = string
public_port = string
private_key = string
public_key = string
})
n/a yes
workers_info_list The list of worker nodes.
list(object({
ipv4 = string
ipv6 = string
mac = string
hostname = string
}))
n/a yes

Outputs

Name Description
k8s_api_server_ip n/a
path_to_kubeconfig_file n/a

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published