Skip to content

Latest commit

 

History

History
135 lines (97 loc) · 5.02 KB

vminstance.md

File metadata and controls

135 lines (97 loc) · 5.02 KB
page_title cozystack_vminstance Resource - cozystack
subcategory
description A Cozystack virtual machine instance, deployed inside a tenant namespace. The deprecated subnets list is not managed (use networks instead).

cozystack_vminstance (Resource)

A Cozystack virtual machine instance, deployed inside a tenant namespace. The deprecated subnets list is not managed (use networks instead).

Example Usage

resource "cozystack_vmdisk" "os" {
  name      = "vm-os"
  namespace = "tenant-root"
  storage   = "20Gi"
  source    = { image = { name = "ubuntu" } }
}

resource "cozystack_vminstance" "vm" {
  name      = "vm"
  namespace = "tenant-root"

  instance_type    = "u1.medium"
  instance_profile = "ubuntu"
  run_strategy     = "Always"

  disks = [
    { name = cozystack_vmdisk.os.name },
  ]

  external       = true
  external_ports = [22]
  ssh_keys       = ["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA user@example.com"]

  cloud_init = <<-EOT
    #cloud-config
    packages:
      - qemu-guest-agent
  EOT

  # Addresses appear only once the guest is up, so without waiting they are only
  # readable from the apply after the one that created the VM. A guest that exits
  # before its address is read keeps the apply waiting until wait_timeout.
  wait_for_ready = true
}

Schema

Required

  • name (String) VMInstance instance name (metadata.name). Immutable.
  • namespace (String) Tenant namespace the application is created in. Immutable.

Optional

  • cloud_init (String) Cloud-init user data.
  • cloud_init_seed (String) Seed string used to generate the SMBIOS UUID for the VM.
  • cpu_model (String) CPU model exposed inside the VM.
  • disks (Attributes List) Disks to attach. (see below for nested schema)
  • external (Boolean) Enable external access from outside the cluster.
  • external_allow_icmp (Boolean) Accept ICMP traffic to the VM in PortList mode (preserves ping and PMTU discovery).
  • external_method (String) Method to pass through traffic to the VM (PortList or WholeIP).
  • external_ports (List of Number) Ports to forward from outside the cluster.
  • gpus (Attributes List) GPUs to attach (NVIDIA driver requires at least 4 GiB RAM). (see below for nested schema)
  • instance_profile (String) Virtual machine preferences profile.
  • instance_type (String) Virtual machine instance type.
  • networks (Attributes List) Networks to attach the VM to. (see below for nested schema)
  • resources (Attributes) Explicit CPU, memory, and socket configuration. (see below for nested schema)
  • run_strategy (String) Requested running state of the VM instance. wait_for_ready waits for an address under the strategies that start a guest themselves (Always, RerunOnFailure, Once); a guest that exits before its address is read keeps the wait going until wait_timeout.
  • ssh_keys (List of String) SSH public keys for authentication.
  • wait_for_ready (Boolean) Block on create/update until the Ready condition is true and any server-generated outputs the resource exposes are readable.
  • wait_timeout (String) Maximum time to wait when wait_for_ready is set (Go duration, e.g. 10m). Readiness and outputs share this budget; outputs that never appear leave a warning and their attributes stay null until the next refresh.

Read-Only

  • chart_version (String) Deployed chart version (status.version).
  • id (String) Synthetic identifier in the form namespace/name.
  • ip_address (String) Primary IP address of the running guest (from the backing VirtualMachineInstance). Populated once the guest is up — set wait_for_ready = true to have it available sooner.
  • ip_addresses (List of String) All IP addresses reported on the guest's primary interface.
  • ready (Boolean) Whether the application's Ready condition is true.
  • uid (String) Server-assigned object UID (metadata.uid). Stable across updates; changes on recreate.

Nested Schema for disks

Required:

  • name (String) Disk name (references a cozystack_vmdisk).

Optional:

  • bus (String) Disk bus type (e.g. sata, virtio).

Nested Schema for gpus

Required:

  • name (String) GPU resource name.

Nested Schema for networks

Required:

  • name (String) Network attachment name.

Nested Schema for resources

Optional:

  • cpu (String) Number of CPU cores allocated.
  • memory (String) Amount of memory allocated.
  • sockets (String) Number of CPU sockets (vCPU topology).

Import

Import is supported using the following syntax:

The terraform import command can be used, for example:

# VMInstance instances are imported as "<namespace>/<name>".
terraform import cozystack_vminstance.vm tenant-root/vm