Page cover

Configuration file vm.yaml

The vm.yaml file is a file used to define a Virtual Machine that is responsible for configuring a Virtual Machine (VM) running in Kubernetes, such as through KubeVirt. It contains information related to VM specifications, such as CPU, memory, and the type of operating system used. This ensures that the VM is treated as one of the Kubernetes objects that can be controlled and managed like a Pod. In the terminal/command prompt that you use, run the syntax according to the operating system that your computer is using.

  1. Windows

If you are using a Windows operating system, you can use Notepad++ or the text editor your computer uses.

  1. Linux

If you are using the Linux operating system, use the following command.

vim svc.yaml

With GPU

If you want use GPU in your VM you can add source code for the vm.yaml file.

apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
  name: database-prod-vm
  namespace: default
spec:
  running: true
  template:
    spec:
      domain:
        resources:
          limits:                       
            memory: "64Gi"
            cpu: "8"
          requests:     
            memory: "64Gi"
            cpu: "8"
        devices:
          gpus:
          - deviceName: nvidia.com/NVIDIA_L40S-24Q
            name: gpu1
          disks:
          - name: containerdisk
            disk:
              bus: virtio
          - disk:
              bus: virtio
            name: cloudinitdisk
          interfaces:
          - masquerade: {}
            name: defaultnetwork
      networks:
      - name: defaultnetwork
        pod: {}     
      volumes:
      - name: containerdisk
        dataVolume:
          name: mta-dv        
      - name: cloudinitdisk
        cloudInitNoCloud:
          userData: |-
            #cloud-config
            #password: fedora
            #chpasswd: { expire: False }
            #cloud-config
            chpasswd:
              list: |
                ubuntu:QQ4j8fpusvqVgTu
                root:toor
              expire: False

Without GPU

If you don't want add GPU in your VM, you can add this source code for the vm.yaml file.

apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
  name: database-prod-vm
  namespace: default
spec:
  running: true
  template:
    spec:
      domain:
        resources:
          limits:                       
            memory: "64Gi"
            cpu: "8"
          requests:     
            memory: "64Gi"
            cpu: "8"
        devices:
          disks:
          - name: containerdisk
            disk:
              bus: virtio
          - disk:
              bus: virtio
            name: cloudinitdisk
          interfaces:
          - masquerade: {}
            name: defaultnetwork
      networks:
      - name: defaultnetwork
        pod: {}     
      volumes:
      - name: containerdisk
        dataVolume:
          name: mta-dv            
      - name: cloudinitdisk
        cloudInitNoCloud:
          userData: |-
            #cloud-config
            #password: fedora
            #chpasswd: { expire: False }
            #cloud-config
            chpasswd:
              list: |
                ubuntu:QQ4j8fpusvqVgTu
                root:toor
              expire: False

The following is an explanation of the source code that will be used, so that it adapts to your needs.

Metadata

In the source code section in the metadata section there is a name and namespace. In the name and namespace are the identities used to label the machine to be used. Adjust the name with the name of the machine used, while in the namespace section adjust it with the namespace in the vcluster used in the Deka GPU Portal Service.

Metadata

Specs

In the source code section in the specs section of the vm.yaml file is used to define the specifications of the VM to be used. So there are some source codes that must be adjusted.

Specs

In the spec section there are domains and devices. In the domain section there are resources that regulate the minimum and maximum that can be used by the VM, while in the device section if you are using a GPU you need to add the source code below.

          gpus:
          - deviceName: nvidia.com/NVIDIA_L40S-24Q
            name: gpu1

Here is a comparison of source code using GPU and without GPU.

In the Volumes section there is a configuration for containerdisk and cloudinitdisk. For the name in the containerdisk in the dataVolumes section, use the name entered in the name in the metadata section in the dv.yaml file. For the name in the cloudinitdisk in the password section, adjust the password that will be used to access the VM. In this line to update the password that will be used, you simply change the sentence after "root:". Because "root" is the username that you will use to log in to the VM.

Specs - Volumes

Use this command syntax to save the changes made to the vm.yaml file.

kubectl apply -f vm.yaml

Last updated