安装
local-path
kubectl apply -f https://raw.githubusercontent.com/rancher/local-path-provisioner/v0.0.32/deploy/local-path-storage.yaml
kubevirt operator
VERSION=v1.6.2
kubectl create -f "https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/kubevirt-operator.yaml"
kubevirt
VERSION=v1.6.2
kubectl create -f "https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/kubevirt-cr.yaml"
kubectl -n kubevirt patch kubevirt kubevirt --type=merge --patch '{"spec":{"configuration":{"developerConfiguration":{"useEmulation":true}}}}'
virtctl
VERSION=v1.6.2
ARCH=amd64
curl -L -o virtctl https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/virtctl-${VERSION}-${ARCH}
chmod +x virtctl
cp virtctl /usr/bin/virtctl
cdi operator
export VERSION=v1.63.1
kubectl create -f https://github.com/kubevirt/containerized-data-importer/releases/download/$VERSION/cdi-operator.yaml
cdi
export VERSION=v1.63.1
kubectl create -f https://github.com/kubevirt/containerized-data-importer/releases/download/$VERSION/cdi-cr.yaml
demo
datavolume
apiVersion: cdi.kubevirt.io/v1beta1
kind: DataVolume
metadata:
name: ubuntu
annotations:
cdi.kubevirt.io/storage.bind.immediate.requested: "true"
spec:
source:
http:
url: "https://cloud-images.ubuntu.com/jammy/20251017/jammy-server-cloudimg-amd64.img"
pvc:
storageClassName: local-path
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
virtualmachine
apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
name: testvm
spec:
runStrategy: Halted
template:
spec:
domain:
devices:
disks:
- name: rootdisk
disk:
bus: virtio
- disk:
bus: virtio
name: cloudinitdisk
interfaces:
- name: default
masquerade: {}
resources:
requests:
memory: 4000M
networks:
- name: default
pod: {}
volumes:
- name: rootdisk
dataVolume:
name: ubuntu
- name: cloudinitdisk
cloudInitNoCloud:
userData: |
#cloud-config
bootcmd:
- cloud-init clean -c all
password: wwqtest
chpasswd:
expire: false
ssh_pwauth: true
操作
开机
virtctl start testvm
关机
virtctl stop testvm
console
virtctl console testvm
ssh(vmip替换为实际的ip,密码为上面的myvm)
ssh ubuntu@${vmip}
补充
ubuntu qcow2镜像下载地址
https://cloud-images.ubuntu.com/jammy/20251017/
系统qciw2镜像下载地址集合
https://docs.openstack.org/image-guide/obtain-images.html
cloud init
https://cloudinit.readthedocs.io/en/latest/index.html
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。