Skip to main content

Virtualization

Overview

Users requiring virtualization services are speaking to the Virtualization API (Based on the KubeVirt project) which in turn is speaking to the Kubernetes cluster to schedule requested Virtual Machine Instances (VMIs). Scheduling, networking, and storage are all delegated to Kubernetes, while KubeVirt/KVM provides the virtualization functionality.

Deploy a sample VM

The following will simulate a basic ubuntu 22.04 LTS base image deployment.

Download:

curl -O https://cloud-images.ubuntu.com/daily/server/jammy/current/jammy-server-cloudimg-amd64.img

Upload to the internal KOSMOS registry:

curl -v --user atheaadmin:atheaadmin --upload-file jammy-server-cloudimg-amd64.img https://gitea.kosmos.wip/api/packages/athea/generic/ubuntu/22.04/jammy-server-cloudimg-amd64.img

Create a namespace for your VMs:

kubectl apply -f - <<EOF
apiVersion: v1
kind: Namespace
metadata:
labels:
pod-security.kubernetes.io/enforce: "privileged"
name: mytenant-vm
EOF

Create the VM:

kubectl apply -f - <<EOF
apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
labels:
kubevirt.io/vm: ubuntu
name: ubuntu
namespace: mytenant-vm
spec:
runStrategy: Always
template:
metadata:
labels:
kubevirt.io/vm: ubuntu
spec:
domain:
devices:
disks:
- disk:
bus: virtio
name: datavolumedisk1
resources:
requests:
memory: 2048M
cpu: 2
volumes:
- dataVolume:
name: ubuntu-dv
name: datavolumedisk1
- cloudInitNoCloud:
userData: |-
#cloud-config
chpasswd:
expire: false
password: kosmos
user: kosmos
name: cloudinitdisk
dataVolumeTemplates:
- metadata:
name: ubuntu-dv
spec:
storage:
volumeMode: Block
resources:
requests:
storage: 3Gi
source:
http:
url: http://gitea-http.kosmos-dev-restricted:3000/api/packages/athea/generic/ubuntu/22.04/jammy-server-cloudimg-amd64.img
EOF