From d7f4fa74997460893d3c83a516ccb93416775f30 Mon Sep 17 00:00:00 2001 From: Thomas Hintz Date: Wed, 13 Aug 2025 07:20:26 -0700 Subject: [PATCH] Working block storage. --- flatcar/cl.yaml | 14 ++++++++++++++ main.tf | 16 ++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/flatcar/cl.yaml b/flatcar/cl.yaml index 88d28d2..2bc4291 100644 --- a/flatcar/cl.yaml +++ b/flatcar/cl.yaml @@ -7,6 +7,16 @@ passwd: - "" systemd: units: + - name: appstorage.mount + enabled: true + contents: | + [Mount] + What=/dev/disk/by-label/appstorage + Where=/appstorage + Type=ext4 + + [Install] + RequiredBy=local-fs.target - name: app.service enabled: true contents_local: app/app.service @@ -25,6 +35,10 @@ systemd: ExecStartPost=/usr/bin/sh -c "if ! cmp --silent /tmp/docker-compose /tmp/docker-compose-new; then touch /run/reboot-required; fi" storage: + filesystems: + - device: /dev/disk/by-label/appstorage + format: ext4 + wipe_filesystem: false files: - path: /var/lb/caddy/Caddyfile contents: diff --git a/main.tf b/main.tf index 225fb3c..7ef79a6 100644 --- a/main.tf +++ b/main.tf @@ -71,6 +71,16 @@ resource "digitalocean_reserved_ip" "machine" { region = digitalocean_droplet.machine[each.key].region } +resource "digitalocean_volume" "machine" { + for_each = toset(var.machines) + region = var.datacenter + name = "${var.cluster_name}-${each.key}" + size = 30 + initial_filesystem_type = "ext4" + initial_filesystem_label = "appstorage" + description = "persistent storage for docker apps" +} + resource "digitalocean_droplet" "machine" { for_each = toset(var.machines) name = "${var.cluster_name}-${each.key}" @@ -91,6 +101,12 @@ resource "digitalocean_reserved_ip_assignment" "machine" { droplet_id = digitalocean_droplet.machine[each.key].id } +resource "digitalocean_volume_attachment" "machine" { + for_each = toset(var.machines) + droplet_id = digitalocean_droplet.machine[each.key].id + volume_id = digitalocean_volume.machine[each.key].id +} + # data "ct_config" "machine-ignitions" { # for_each = toset(var.machines) # content = templatefile("${path.module}/cl/machine-${each.key}.yaml.tmpl", {