apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
name: example-vm
namespace: example-namespace
spec:
dataVolumeTemplates:
- apiVersion: cdi.kubevirt.io/v1beta1
kind: DataVolume
metadata:
name: example-vm-disk
spec:
sourceRef:
kind: DataSource
name: rhel9
namespace: openshift-virtualization-os-images
storage:
resources:
requests:
storage: 30Gi
running: false
template:
metadata:
labels:
kubevirt.io/domain: example-vm
spec:
domain:
cpu:
cores: 1
sockets: 2
threads: 1
devices:
disks:
- disk:
bus: virtio
name: rootdisk
- disk:
bus: virtio
name: cloudinitdisk
interfaces:
- masquerade: {}
name: default
rng: {}
features:
smm:
enabled: true
firmware:
bootloader:
efi: {}
resources:
requests:
memory: 8Gi
evictionStrategy: LiveMigrate
networks:
- name: default
pod: {}
volumes:
- dataVolume:
name: example-volume
name: example-vm-disk
- cloudInitConfigDrive: (1)
userData: |-
#cloud-config
user: cloud-user
password: <password>
chpasswd: { expire: False }
runcmd:
- [ setsebool, -P, virt_qemu_ga_manage_ssh, on ]
name: cloudinitdisk
accessCredentials:
- sshPublicKey:
propagationMethod:
qemuGuestAgent:
users: ["user1","user2","fedora"] (2)
source:
secret:
secretName: authorized-keys (3)
---
apiVersion: v1
kind: secret
metadata:
name: authorized-keys
data:
key: |
MIIEpQIBAAKCAQEAulqb/Y... (4)