Skip to content

Update vm-instance to support additional persistent disks#3886

Closed
tpdownes wants to merge 3 commits into
GoogleCloudPlatform:developfrom
tpdownes:additional_pds_vm_instance
Closed

Update vm-instance to support additional persistent disks#3886
tpdownes wants to merge 3 commits into
GoogleCloudPlatform:developfrom
tpdownes:additional_pds_vm_instance

Conversation

@tpdownes

@tpdownes tpdownes commented Apr 4, 2025

Copy link
Copy Markdown
Contributor

Add a simple input variable that enables the specification of additional persistent disks, configuring their type and size. Future work to allow additional access modes for the disks themselves (multi-writer, etc) and additional modes for attaching them (read-only).

This PR can be evaluated using

---
blueprint_name: feat-request

vars:
  deployment_name: poc-feat
  project_id: $$PROJECT$$
  region: us-central1
  zone: us-central1-f

deployment_groups:
- group: primary
  modules:
  - id: network
    source: modules/network/vpc
  - id: vm
    source: modules/compute/vm-instance
    use:
    - network
    settings:
      machine_type: n1-standard-32
      additional_persistent_disks:
        count: 3
        type: pd-ssd
        size: 250
      startup_script: |
        #!/bin/bash
        parted --script /dev/disk/by-id/google-$(vars.deployment_name)-disk-0 mklabel gpt
        parted --script /dev/disk/by-id/google-$(vars.deployment_name)-disk-0 mkpart primary ext4 0% 100%
        parted --script /dev/disk/by-id/google-$(vars.deployment_name)-disk-1 mklabel gpt
        parted --script /dev/disk/by-id/google-$(vars.deployment_name)-disk-1 mkpart primary ext4 0% 100%
        parted --script /dev/disk/by-id/google-$(vars.deployment_name)-disk-2 mklabel gpt
        parted --script /dev/disk/by-id/google-$(vars.deployment_name)-disk-2 mkpart primary ext4 0% 100%
        mkfs.ext4 -m 0 /dev/disk/by-id/google-$(vars.deployment_name)-disk-0-part1
        mkfs.ext4 -m 0 /dev/disk/by-id/google-$(vars.deployment_name)-disk-1-part1
        mkfs.ext4 -m 0 /dev/disk/by-id/google-$(vars.deployment_name)-disk-2-part1
        mkdir -p /mnt/p0
        mkdir -p /mnt/p1
        mkdir -p /mnt/p2
        mount /dev/disk/by-id/google-$(vars.deployment_name)-disk-0-part1 /mnt/p0
        mount /dev/disk/by-id/google-$(vars.deployment_name)-disk-1-part1 /mnt/p1
        mount /dev/disk/by-id/google-$(vars.deployment_name)-disk-2-part1 /mnt/p2

SSH to the VM reveals the 3 disks ready for access.

[ext_tpdownes_google_com@poc-feat-0 ~]$                                                                                
* NOTICE **: The Cluster Toolkit startup scripts have finished running successfully.
                                                                               

[ext_tpdownes_google_com@poc-feat-0 ~]$ df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs         59G     0   59G   0% /dev
tmpfs            59G     0   59G   0% /dev/shm
tmpfs            59G   17M   59G   1% /run
tmpfs            59G     0   59G   0% /sys/fs/cgroup
/dev/sda2       200G  6.5G  194G   4% /
/dev/sda1       200M  5.8M  194M   3% /boot/efi
tmpfs            12G     0   12G   0% /run/user/0
tmpfs            12G     0   12G   0% /run/user/2715883726
/dev/sdb1       246G   28K  246G   1% /mnt/p0
/dev/sdc1       246G   28K  246G   1% /mnt/p1
/dev/sdd1       246G   28K  246G   1% /mnt/p2

Submission Checklist

NOTE: Community submissions can take up to 2 weeks to be reviewed.

Please take the following actions before submitting this pull request.

  • Fork your PR branch from the Toolkit "develop" branch (not main)
  • Test all changes with pre-commit in a local branch #
  • Confirm that "make tests" passes all tests
  • Add or modify unit tests to cover code changes
  • Ensure that unit test coverage remains above 80%
  • Update all applicable documentation
  • Follow Cluster Toolkit Contribution guidelines #

Add a simple input variable that enables the specification of additional
persistent disks, configuring their type and size. Future work to allow
additional access modes for the disks themselves (multi-writer, etc) and
additional modes for attaching them (read-only).
@tpdownes tpdownes force-pushed the additional_pds_vm_instance branch from 2a4d64e to e3fabe2 Compare April 4, 2025 23:07
Comment thread modules/compute/vm-instance/main.tf Outdated
@tpdownes tpdownes marked this pull request as ready for review April 13, 2025 19:26
@tpdownes tpdownes requested a review from a team as a code owner April 13, 2025 19:26
@tpdownes tpdownes closed this Apr 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants