Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add a vm with docker #594

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 53 additions & 10 deletions tofu/harvester/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,22 @@ locals {
memory = "24Gi"
}
}

docker_vm = {
"docker-host" = {
mac_address = "00:16:3E:3C:0F:00" // 192.168.1.190
cpu = 4
memory = "16Gi"
}
}
}

resource "harvester_image" "ubuntu-focal" {
name = "ubuntu-focal"
display_name = "Ubuntu 20 Focal LTS"
source_type = "download"
namespace = "harvester-public"
url = "https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-arm64.img"
name = "ubuntu-focal"
display_name = "Ubuntu 20 Focal LTS"
source_type = "download"
namespace = "harvester-public"
url = "https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-arm64.img"
storage_class_name = harvester_storageclass.single-node-longhorn.name

lifecycle {
Expand All @@ -198,11 +206,11 @@ resource "harvester_image" "ubuntu-focal" {
}

resource "harvester_image" "ubuntu-jammy" {
name = "ubuntu-jammy"
display_name = "Ubuntu 22 Jammy LTS"
source_type = "download"
namespace = "harvester-public"
url = "https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-arm64.img"
name = "ubuntu-jammy"
display_name = "Ubuntu 22 Jammy LTS"
source_type = "download"
namespace = "harvester-public"
url = "https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-arm64.img"
storage_class_name = harvester_storageclass.single-node-longhorn.name

lifecycle {
Expand Down Expand Up @@ -392,3 +400,38 @@ users:
EOF
network_data = ""
}

resource "harvester_virtualmachine" "docker-host" {
for_each = local.docker_vm
name = each.key
cpu = each.value.cpu
memory = each.value.memory

efi = true
hostname = each.key
run_strategy = "Always"

disk {
name = "root"
type = "disk"
size = "100Gi"
bus = "virtio"
boot_order = 1
image = harvester_image.ubuntu-jammy.id
auto_delete = true
}

network_interface {
name = "bridge"
model = "virtio"
type = "bridge"
mac_address = each.value.mac_address
network_name = harvester_network.cluster_network.name
wait_for_lease = true
}

cloudinit {
user_data_secret_name = harvester_cloudinit_secret.ubuntu-docker.name
network_data_secret_name = harvester_cloudinit_secret.ubuntu-docker.name
}
}