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

Unable to deploy Kubevirt VM manifest #2688

Open
evilhamsterman opened this issue Feb 11, 2025 · 0 comments
Open

Unable to deploy Kubevirt VM manifest #2688

evilhamsterman opened this issue Feb 11, 2025 · 0 comments
Assignees
Labels

Comments

@evilhamsterman
Copy link

evilhamsterman commented Feb 11, 2025

Terraform Version, Provider Version and Kubernetes Version

Terraform version: 1.10.4
Kubernetes provider version: 2.35.1
Kubernetes version: v1.31.4+k3s1

Affected Resource(s)

kubernetes_manifest

Terraform Configuration Files

terraform {
  required_providers {
    kubernetes = {
      source = "hashicorp/kubernetes"
    }
  }
}

provider "kubernetes" {
  config_path = "~/.kube/config"

}

resource "kubernetes_manifest" "vm_root" {
  wait {
    fields = {
      "status.phase" = "Succeeded"
    }
  }

  manifest = {
    apiVersion = "cdi.kubevirt.io/v1beta1"
    kind       = "DataVolume"
    metadata = {
      name      = "vm-test-root"
      namespace = "engineering"
    }
    spec = {
      storage = {
        accessModes = [
          "ReadWriteMany",
        ]
        resources = {
          requests = {
            storage = "200Gi"
          }
        }
      }
      source = {
        pvc = {
          namespace = "engineering"
          name      = "ubuntu-cloud-noble"
        }
      }
    }
  }
}


resource "kubernetes_manifest" "vm" {
  computed_fields = [
    "metadata",
    "status",
    "spec",
  ]
  wait {
    fields = {
      "status.ready" = true
    }
  }
  manifest = {
    "apiVersion" = "kubevirt.io/v1"
    "kind"       = "VirtualMachine"
    "metadata" = {
      "name"      = "vm-test"
      "namespace" = "engineering"
    }
    "spec" = {
      "runStrategy" = "Always"
      "template" = {
        "metadata" = {
          "labels" = {
            "role" = "user"
          }
        }
        "spec" = {
          "architecture" = "amd64"
          "domain" = {
            "cpu" = {
              "cores" = 8
              "model" = "host-passthrough"
            }
            "devices" = {
              "disks" = [
                {
                  "disk" = {
                    "bus" = "virtio"
                  }
                  "name"   = "root"
                  "serial" = "root"
                  "tag"    = "root"
                },
              ]
              "interfaces" = [
                {
                  "masquerade" = {}
                  "name"       = "default"
                },
              ]
            }
            "firmware" = {
              "uuid" = "9e6db865-b37b-df13-67c0-55ce5cc564b1"
            }
            "machine" = {
              "type" = "q35"
            }
            "memory" = {
              "guest" = "16Gi"
            }
            "resources" = {
              "requests" = {
                "memory" = "17Gi"
              }
            }
          }
          "networks" = [
            {
              "name" = "default"
              "pod" = {
                "vmNetworkCIDR" = "172.16.0.0/14"
              }
            },
          ]
          "terminationGracePeriodSeconds" = 180
          "volumes" = [
            {
              "dataVolume" = {
                "name" = kubernetes_manifest.vm_root.manifest.metadata.name
              }
              "name" = "root"
            },
          ]
        }
      }
    }
  }
}

Debug Output

https://gist.github.com/evilhamsterman/adc5de1328dda90e9da31bfae7c0ac04

Panic Output

Steps to Reproduce

  1. Install Kubernetes and Kubevirt
  2. Create a terraform file with the kubernetes_manifest resource to try to create a Kubevirt VirtualMachine

Expected Behavior

It would apply successfully

Actual Behavior

Terraform successfully deploys everything including the VM, however it complains about inconsistent results for the VM and marks the run as failed

Important Factoids

I know about the computed_fields option, I've spent hours trying to different fields, even up to saying basically everything is computed but it still fails. It seems maybe something is not being read from the CRD correctly

References

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants