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: adds GPU support to packer plugin nutanix #187

Merged
merged 1 commit into from
May 3, 2024

Conversation

faiq
Copy link
Contributor

@faiq faiq commented May 2, 2024

What this PR does / why we need it:

Adds GPU support to the packer plugin.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):

Fixes #123

How Has This Been Tested?:

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration and test output

I tested this by adding this to my packer.pkl.hcl file

source "nutanix" "kib_image" {
  boot_type              = var.boot_type
  cluster_name           = trim(var.nutanix_cluster_name, "\r\n")
  cpu                    = var.cpus
  force_deregister       = var.force_deregister
  gpu {
    name = "Ampere 40"
  }
  image_delete           = local.image_delete
  image_description      = "kube image-builder packer"
  image_export           = var.image_export
  image_name             = local.image_name
  memory_mb              = var.memory
  nutanix_endpoint       = trim(var.nutanix_endpoint, "\r\n")
  nutanix_insecure       = trim(var.nutanix_insecure, "\r\n")
  nutanix_password       = trim(var.nutanix_password, "\r\n")
  nutanix_port           = trim(var.nutanix_port, "\r\n")
  nutanix_username       = trim(var.nutanix_username, "\r\n")
  os_type                = var.guest_os_type
  shutdown_command       = "echo '${var.ssh_password}' | sudo -S -E sh -c 'usermod -L ${var.ssh_username} && ${var.shutdown_command}'"
  ssh_handshake_attempts = "100"
  ssh_agent_auth         = var.ssh_agent_auth
  ssh_private_key_file   = local.ssh_private_key_file
  ssh_password           = var.ssh_password
  ssh_timeout            = "20m"
  ssh_username           = var.ssh_username
  user_data              = base64encode(local.cloud_init)
  vm_disks {
    disk_size_gb        = var.disk_size_gb
    image_type          = "DISK_IMAGE"
    source_image_delete = var.source_image_delete
    source_image_force  = var.source_image_force
    source_image_uri    = var.source_image_url
    source_image_name   = var.source_image_name
  }
  vm_force_delete        = var.vm_force_delete
  vm_name                = local.image_name
  vm_nics  {
    subnet_name = trim(var.nutanix_subnet_name,  "\r\n")
  }
}

This created the VM and when I observed in the console the GPU was attached

12:10 PM  faiqus @ archlinux  ~/go/src/github.com/nutanix-cloud-native/example   
$ packer build -debug -var-file=./rocky.pkrvars.hcl packer.pkr.hcl 
Debug mode enabled. Builds will not be parallelized.
nutanix.kib_image: output will be in this color.

==> nutanix.kib_image: Creating Packer Builder virtual machine...
    nutanix.kib_image: Virtual machine rocky-9.3-kube--20240502181338 created
    nutanix.kib_image: Found IP for virtual machine: 10.41.16.5
==> nutanix.kib_image: Using SSH communicator to connect: 10.41.16.5
==> nutanix.kib_image: Waiting for SSH to become available...
==> nutanix.kib_image: Connected to SSH!
==> nutanix.kib_image: Gracefully halting virtual machine...
==> nutanix.kib_image: Creating image(s) from virtual machine rocky-9.3-kube--20240502181338...
    nutanix.kib_image: Found disk to copy: SCSI:0
    nutanix.kib_image: Image successfully created: rocky-9.3-kube--20240502181338 (df466e42-8940-43a7-822a-60e216be3df1)
==> nutanix.kib_image: Deleting virtual machine...
    nutanix.kib_image: Virtual machine successfully deleted
==> nutanix.kib_image: Running post-processor: packer-manifest (type manifest)
Build 'nutanix.kib_image' finished after 1 minute 23 seconds.

==> Wait completed after 1 minute 23 seconds

==> Builds finished. The artifacts of successful builds are:
--> nutanix.kib_image: rocky-9.3-kube--20240502181338
--> nutanix.kib_image: rocky-9.3-kube--20240502181338

Special notes for your reviewer:

Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

Release note:

Adds GPU support to plugin

@faiq faiq force-pushed the faiq/adds-gpu-support branch from 043ef61 to eb801eb Compare May 2, 2024 18:24
Copy link
Contributor

@tuxtof tuxtof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@wolfganghuse wolfganghuse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, have done some tests including wrong GPU name, saturated resources, etc.

@tuxtof tuxtof merged commit 36d871d into nutanix-cloud-native:main May 3, 2024
9 of 10 checks passed
@tuxtof tuxtof added the enhancement New feature or request label May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add GPU support
3 participants