Skip to content

Files

Latest commit

0396761 · Nov 27, 2024

History

History

tf_libvirt

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Aug 30, 2022
Nov 13, 2024
Nov 13, 2024
Aug 30, 2022
Nov 10, 2024
Nov 27, 2024
Nov 27, 2024
Nov 13, 2024
Aug 30, 2022
Aug 30, 2022

Deploy the Ubuntu 24.04 LTS virtual machines to libvirt/QEMU using Terraform

Creating a Terraform repository to deploy a Kubernetes cluster for educational purposes.

It creates three (3) QEMU/KVM virtual machines running Ubuntu 24.04 LTS, provisioned through Libvirt.

Step 0: Configure Variables

You need to edit Variables.tf

  • timezone
  • ssh port
  • hostname
  • vcpu
  • vmem
  • vol_size

and especially the Variable

  • github user

... allowing you to access these VMs via SSH.

Step 1: Initialize Terraform

terraform init

Step 2: Preview the Infrastructure Changes

terraform plan

Step 3: Apply the Terraform Configuration

using a bash shell script to automate creation

./start.sh

Console Output

Apply complete! Resources: 16 added, 0 changed, 0 destroyed.

Outputs:

VMs = [
  "192.168.122.223 k8scpnode1",
  "192.168.122.50  k8swrknode1",
  "192.168.122.10  k8swrknode2",
]

Verify

$ ssh -l ubuntu 192.168.122.223 hostname
k8scpnode1

$ ssh 192.168.122.223 -l ubuntu 'grep ^VERSION= /etc/os-release'
VERSION="24.10 (Oracular Oriole)"

Destroy Everything

run destroy bash shell script

./destroy.sh

Root Password

If you need to set a root password for the Ubuntu 24.04 LTS virtual machine during its creation via Terraform

$ sudo virsh console k8scpnode1

userame:  root
password: ping