8.3. Creating VMs using the CLI


8.3.1. Creating virtual machines from the CLI

You can create virtual machines (VMs) from the command line by editing or creating a VirtualMachine manifest. You can simplify VM configuration by using an instance type in your VM manifest.

참고

8.3.1.1. Creating a VM from a VirtualMachine manifest

You can create a virtual machine (VM) from a VirtualMachine manifest. To simplify the creation of these manifests, you can use the virtctl command-line tool.

Prerequisites

  • You have installed the virtctl CLI.
  • You have installed the OpenShift CLI (oc).

Procedure

  1. Create a VirtualMachine manifest for your VM and save it as a YAML file. For example, to create a minimal Red Hat Enterprise Linux (RHEL) VM, run the following command:

    $ virtctl create vm --name rhel-9-minimal --volume-import type:ds,src:openshift-virtualization-os-images/rhel9
  2. Review the VirtualMachine manifest for your VM:

    참고

    This example manifest does not configure VM authentication.

    Example manifest for a RHEL VM

    apiVersion: kubevirt.io/v1
    kind: VirtualMachine
    metadata:
      name: rhel-9-minimal 
    1
    
    spec:
      dataVolumeTemplates:
      - metadata:
          name: imported-volume-mk4lj
        spec:
          sourceRef:
            kind: DataSource
            name: rhel9 
    2
    
            namespace: openshift-virtualization-os-images 
    3
    
          storage:
            resources: {}
      instancetype:
        inferFromVolume: imported-volume-mk4lj 
    4
    
        inferFromVolumeFailurePolicy: Ignore
      preference:
        inferFromVolume: imported-volume-mk4lj 
    5
    
        inferFromVolumeFailurePolicy: Ignore
      runStrategy: Always
      template:
        spec:
          domain:
            devices: {}
            memory:
              guest: 512Mi
            resources: {}
          terminationGracePeriodSeconds: 180
          volumes:
          - dataVolume:
              name: imported-volume-mk4lj
            name: imported-volume-mk4lj

    1
    The VM name.
    2
    The boot source for the guest operating system.
    3
    The namespace for the boot source. Golden images are stored in the openshift-virtualization-os-images namespace.
    4
    The instance type is inferred from the selected DataSource object.
    5
    The preference is inferred from the selected DataSource object.
  3. Create a virtual machine by using the manifest file:

    $ oc create -f <vm_manifest_file>.yaml
  4. Optional: Start the virtual machine:

    $ virtctl start <vm_name>
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 문서 정보

Legal Notice

Theme

© 2026 Red Hat
맨 위로 이동