Skip to content

Terraform module for creating K3s clusters using Fedora CoreOS and Libvirt.

License

Notifications You must be signed in to change notification settings

krestomatio/terraform-libvirt-fcos-k3s-cluster

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terraform module for creating K3s clusters using Fedora CoreOS and Libvirt.

Dependencies

The following are the dependencies to create k3s cluster with this module:

Requirements

Name Version
terraform >= 1.2.0
ct 0.11.0
libvirt ~> 0.7

Providers

No providers.

Modules

Name Source Version
node_groups ./modules/node-group n/a

Resources

No resources.

Inputs

Name Description Type Default Required
additional_disks An array of one or more disks to attach to the domain. See docs
list(
object(
{
volume_id = optional(string)
url = optional(string)
file = optional(string)
block_device = optional(string)
scsi = optional(bool)
wwn = optional(string)
}
)
)
[] no
additional_rpms Additional rpms to install during boot using rpm-ostree, along with any pre or post command
object(
{
cmd_pre = optional(list(string), [])
list = optional(list(string), [])
cmd_post = optional(list(string), [])
}
)
null no
agent_token K3s token for agents to join the cluster string null no
arch The architecture for the VM (probably x86_64 or i686), you normally won't need to set this unless you are building a special VM string null no
autostart Autostart with libvirt host bool null no
backup_volume Create node backup volume bool null no
backup_volume_pool Node default backup volume pool string null no
backup_volume_size Node default backup volume size in bytes number null no
butane_snippets_additional Additional butane snippets list(string) [] no
cmdline Arguments to the kernel list(map(string)) [] no
cpu_mode Libvirt default cpu mode for VMs string null no
data_volume Create node data volume bool null no
data_volume_pool Node default data volume pool string null no
data_volume_size Node default data volume size in bytes number null no
do_not_countme Disable Fedora CoreOS infrastructure count me feature bool null no
emulator The path of the emulator to use string null no
etc_hosts /etc/host list
list(
object(
{
ip = string
hostname = string
fqdn = string
}
)
)
null no
etc_hosts_extra /etc/host extra block string null no
firmware The UEFI rom images for exercising UEFI secure boot in a qemu environment. string null no
generate_etc_hosts Whether /etc/hosts entries shjould be generated for all cluster nodes created. Default depends if etc_hosts set bool null no
ignition_pool Default ignition files pool string null no
interface_name Network interface name string null no
k3s_channel K3s installation channel string null no
keymap Keymap string null no
kubelet_config Contains the configuration for the Kubelet
object(
{
version = optional(string)
content = optional(string)
}
)
null no
libosinfo_id Id for libosinfo/os type. See https://gitlab.com/libosinfo/osinfo-db/-/tree/main string null no
log_volume Create node log volume bool null no
log_volume_pool Node default log volume pool string null no
log_volume_size Node default log volume size in bytes number null no
machine The machine type, you normally won't need to set this unless you are running on a platform that defaults to the wrong machine type for your template string null no
memory Node default memory in MiB number null no
nameservers List of nameservers for VMs list(string) null no
network_bridge Libvirt default network bridge name for VMs string null no
network_id Libvirt default network id for VMs string null no
network_name Libvirt default network name for VMs string null no
node_groups List of node groups
list(
object(
{
name = string
mode = string
# general
butane_snippets_additional = optional(list(string))
periodic_updates = optional(
object(
{
time_zone = optional(string, "")
windows = list(
object(
{
days = list(string)
start_time = string
length_minutes = string
}
)
)
}
)
)
k3s_channel = optional(string)
rollout_wariness = optional(string)
ssh_authorized_key = optional(string)
nameservers = optional(list(string))
grub_password_hash = optional(string)
timezone = optional(string)
keymap = optional(string)
interface_name = optional(string)
etc_hosts_extra = optional(string)
systemd_pager = optional(string)
sysctl = optional(map(string))
sync_time_with_host = optional(bool)
do_not_countme = optional(bool)
wait_for_lease = optional(bool)
qemu_agent = optional(bool)
do_not_countme = optional(bool)
additional_rpms = optional(
object(
{
cmd_pre = optional(list(string), [])
list = optional(list(string), [])
cmd_post = optional(list(string), [])
}
)
)
# k3s config for this node_group
k3s_config = optional(
object(
{
envvars = optional(list(string))
parameters = optional(list(string))
selinux = optional(bool)
data_dir = optional(string)
script_url = optional(string)
script_sha256sum = optional(string)
repo_baseurl = optional(string)
repo_gpgkey = optional(string)
testing_repo = optional(bool)
testing_repo_baseurl = optional(string)
testing_repo_gpgkey = optional(string)
}
)
)
k3s_fleetlock = optional(
object(
{
version = optional(string)
namespace = optional(string)
cluster_ip = optional(string)
group = optional(string)
node_selectors = optional(list(map(string)), [])
tolerations = optional(
list(
object(
{
key = string
operator = string
value = optional(string)
effect = string
}
)
), []
)
}
)
)
kubelet_config = optional(
object(
{
version = optional(string)
content = optional(string)
}
)
)
# general libvirt node
cpu_mode = optional(string)
vcpu = optional(number)
memory = optional(number)
libosinfo_id = optional(string)
xslt_snippet = optional(string)
arch = optional(string)
cmdline = optional(list(map(string)))
emulator = optional(string)
machine = optional(string)
firmware = optional(string)
nvram = optional(
object(
{
file = string
template = optional(string)

}
)
)
root_volume_pool = optional(string)
root_volume_size = optional(number)
root_base_volume_name = optional(string)
root_base_volume_pool = optional(string)
log_volume = optional(bool)
log_volume_size = optional(number)
log_volume_pool = optional(string)
data_volume = optional(bool)
data_volume_pool = optional(string)
data_volume_size = optional(number)
backup_volume = optional(bool)
backup_volume_pool = optional(string)
backup_volume_size = optional(number)
ignition_pool = optional(string)
autostart = optional(bool)
wait_for_lease = optional(bool)
network_id = optional(string)
network_bridge = optional(string)
network_name = optional(string)
additional_disks = optional(
list(
object(
{
volume_id = optional(string)
url = optional(string)
file = optional(string)
block_device = optional(string)
scsi = optional(bool)
wwn = optional(string)
}
)
)
)
nodes = list(
object(
{
# libvirt node
fqdn = string
cidr_ip_address = optional(string)
mac = optional(string)
# specific libvirt node
cpu_mode = optional(string)
vcpu = optional(number)
memory = optional(number)
libosinfo_id = optional(string)
xslt_snippet = optional(string)
arch = optional(string)
cmdline = optional(list(map(string)))
emulator = optional(string)
machine = optional(string)
firmware = optional(string)
nvram = optional(
object(
{
file = string
template = optional(string)

}
)
)
root_volume_pool = optional(string)
root_volume_size = optional(number)
root_base_volume_name = optional(string)
root_base_volume_pool = optional(string)
log_volume = optional(bool)
log_volume_size = optional(number)
log_volume_pool = optional(string)
data_volume = optional(bool)
data_volume_pool = optional(string)
data_volume_size = optional(number)
backup_volume = optional(bool)
backup_volume_pool = optional(string)
backup_volume_size = optional(number)
ignition_pool = optional(string)
autostart = optional(bool)
wait_for_lease = optional(bool)
network_id = optional(string)
network_bridge = optional(string)
network_name = optional(string)
additional_disks = optional(
list(
object(
{
volume_id = optional(string)
url = optional(string)
file = optional(string)
block_device = optional(string)
scsi = optional(bool)
wwn = optional(string)
}
)
)
)
}
)
)
}
)
)
n/a yes
nvram This block allows specifying the following attributes related to the nvram
object(
{
file = string
template = optional(string)

}
)
null no
origin_server Server host to connect nodes to (ex: https://example:6443) string "" no
periodic_updates Only reboot for updates during certain timeframes
{
time_zone = "localtime"
windows = [
{
days = ["Sat"],
start_time = "23:30",
length_minutes = "60"
},
{
days = ["Sun"],
start_time = "00:30",
length_minutes = "60"
}
]
}
object(
{
time_zone = optional(string, "")
windows = list(
object(
{
days = list(string)
start_time = string
length_minutes = string
}
)
)
}
)
null no
qemu_agent Install qemu guest agent bool null no
rollout_wariness Wariness to update, 1.0 (very cautious) to 0.0 (very eager) string null no
root_base_volume_name Node default base root volume name string null no
root_base_volume_pool Node default base root volume pool string null no
root_volume_pool Node default root volume pool string null no
root_volume_size Node default root volume size in bytes number null no
secret_encryption_key Set an specific secret encryption (inteneded only for bootstrap) string null no
ssh_authorized_key Authorized ssh key for core user string n/a yes
sync_time_with_host Sync guest time with the kvm host bool null no
sysctl Additional kernel tuning in sysctl.d map(string) null no
systemd_pager Systemd pager string null no
timezone Timezone for VMs as listed by timedatectl list-timezones string null no
token K3s token for servers to join the cluster, ang agents if agent_token is not set string null no
vcpu Node default vcpu count number null no
wait_for_lease Wait for network lease bool null no
xslt_snippet Snippet specifying XSLT to transform the generated XML definition before creating the domain. string null no

Outputs

No outputs.

Krestomatio is a managed service for Moodle™ e-learning platforms. It allows you to have open-source instances managed by a service optimized for Moodle™, complete with an additional plugin pack and customization options.

About

Terraform module for creating K3s clusters using Fedora CoreOS and Libvirt.

Topics

Resources

License

Stars

Watchers

Forks

Languages