RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian - - PowerPoint PPT Presentation

running virtual machines on kubernetes
SMART_READER_LITE
LIVE PREVIEW

RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian - - PowerPoint PPT Presentation

RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1 FABIAN DEUTSCH ROMAN MOHR Fedora user and former oVirt and KubeVirt Contributor package maintainer Working at Red Hat oVirt and KubeVirt


slide-1
SLIDE 1

RUNNING VIRTUAL MACHINES ON KUBERNETES

Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017

1

slide-2
SLIDE 2

FABIAN DEUTSCH

Fedora user and former package maintainer

  • Virt and KubeVirt Contributor

Working at Red Hat

ROMAN MOHR

  • Virt and KubeVirt Contributor

Working at Red Hat fabiand@redhat.com @dummdida fabiand https://dummdida.tumblr.com rmohr@redhat.com @rfenkhuber rmohr

2

slide-3
SLIDE 3

VIRTUALIZATION IS

  • OMNIPRESENT. TODAY.

(drome, CC BY-NC 2.0) 3

slide-4
SLIDE 4

CONTAINERS AS WELL.

(davehamster, CC BY 2.0) 4

slide-5
SLIDE 5

CONTAINERS LOOK, TASTE, AND SMELL THE SAME - JUST BETTER

"Versatile, scalable, hyped, community driven, devops, …" Take this with a grain of salt.

(colinwarren, CC BY-NC 2.0) 5

slide-6
SLIDE 6

"HOW DO WE GET THERE?" "HOW CAN I REPLACE MY VMS WITH CONTAINERS? HOW!?"

6 . 1

slide-7
SLIDE 7

ARE THEY REALLY SUBSTITUTES? IS THE ONE LIKE THE OTHER?

Technology? Features? Feeling? Tools? Requirements?

6 . 2

slide-8
SLIDE 8

⇝ ⇝ IT DEPENDS

6 . 3

slide-9
SLIDE 9

NOT YET? "NEVER"?

Yes No

COOL

Replace?

7 . 1

slide-10
SLIDE 10

MIGRATION

If workloads can be moved to containers, then it's a migration

CONVERGENCE

If not, then we still want convergence

7 . 2

slide-11
SLIDE 11

Yes No Replace?

XX% YY% BOTH.

8

slide-12
SLIDE 12

Yes

MIGRATION PATH?

Replace?

DOUBLED INFRASTRUCTURE?

No

9 . 1

slide-13
SLIDE 13

Management Plane Storage Network … Virtual Machines Management Plane Storage Network … Containers

2X INFRASTRUCTURE?

9 . 2

slide-14
SLIDE 14

Virtualization and containers

( ) giphy 10

slide-15
SLIDE 15

KUBEVIRT

11

slide-16
SLIDE 16

CONTAINERS & VIRTUAL MACHINES

  • n the same infrastructure.

12 . 1

slide-17
SLIDE 17

Management Plane Storage Network … Virtual Machines Containers

KEEP YOUR VMS …

12 . 2

slide-18
SLIDE 18

Management Plane Storage Network … Virtual Machines Containers

… TRANSITION WHAT YOU NEED …

12 . 3

slide-19
SLIDE 19

Management Plane Storage Network … Virtual Machines Containers

… AND STICK TO VMS AS NEEDED.

12 . 4

slide-20
SLIDE 20

WOOT?

Tell me more.

( ) giphy 13

slide-21
SLIDE 21

Kubernetes Storage Network … Virtual Machines Containers

14

slide-22
SLIDE 22

Kubernetes Storage Network … Virtual Machines Containers + KubeVirt

15

slide-23
SLIDE 23

HOW DOES KUBEVIRT INTEGRATE WITH KUBERNETES?

The Details.

16

slide-24
SLIDE 24

kind: Pod metadata: name: nginx labels: name: nginx spec: containers:

  • name: nginx

image: nginx:latest ports:

  • containerPort: 80

nodeSelector: cpu: fast status: phase: Running

KUBERNETES API

“A pod (as in a pod of whales or pea pod) is a group of one or more containers (such as Docker containers), with shared storage/network, and a specification for how to run the containers.” *

* https://kubernetes.io/docs/concepts/workloads/pods/pod/#what-is-a-pod

17

slide-25
SLIDE 25

HOW ABOUT TREATING A POD AS A VM?

Add device details as annotations. Modify the container runtime on every node. Deal with the fact that there are two Pods when you do migrations. Implement as much functionality as possible from the Kubelet, since there is not way to distinguish from

  • utside what your VM Pod supports, compared to a

normal Pod. Are we talking about a VM Pod or a Pod?

18

slide-26
SLIDE 26

HOW ABOUT ADDING AN EXPLICIT VIRT API?

Allows a proper Virtual Machine Specification We can ship KubeVirt as a pue add-on. No Node modifications are necessary. No matter, how much Pods are necessary to perform a migration, we have one single entrypoint to the Virtual Machine. Reuse all of the kubelet and Pod Spec functionality, by running a Virtual Machine inside the Pod Talk about VMs when they are VMs, talk about Pods when they are Pods.

19

slide-27
SLIDE 27

kind: VirtualMachine metadata: name: testvm spec: domain: devices: type: PersistentVolumeClaim device: disk source: name: myVolumeClaim nodeSelector: cpu: fast status: phase: Running

KUBEVIRT API

We have the typical Pod like structure: Metadata section Specification section Typical Pod features like nodeSelector affinity Status section Behind the scene a Pod is created, scheduled and we make sure that the VM starts correctly inside.

20

slide-28
SLIDE 28

kind: VirtualMachine metadata: name: testvm spec: domain: devices: graphics:

  • type: spice

consoles:

  • type: pty

Typical Pod commands: kubectl create -f mypodspec.yaml kubectl delete mypod kubectl exec mypod -it /bin/bash Typical VirtualMachine commands: kubectl create -f myvmspec.yaml kubectl delete testvm kubectl plugin virt console testvm kubectl plugin virt spice testvm

TYPICAL KUBECTL FEELING

21

slide-29
SLIDE 29

Documentation

22

slide-30
SLIDE 30

kind: Migration metadata: generateName: my-migration spec: nodeSelector: kubevirt.io/hostname: node1 selector: name: testvm status: phase: Succeeded

MIGRATIONS

Backed by a controller: On object create, schedules a new Pod On successful Pod start, it triggers the migration At the end of the migration the object is moved to a final state Always one VirtualMachine object you reference The objects Migration with VirtualMachine provide a consistent entry point to anything VirtualMachine related, like the Pod does for Kubernetes.

23

slide-31
SLIDE 31

API CHALLENGES

Feature wise comparable to domxml Certain features are node specific - they need to be abstracted Needs to be married with Kubernetes concepts (pv, networks) Needs additional data for cluster-only features like scheduling

24

slide-32
SLIDE 32

INTEGRATION CHALLENGES

Properly integrate the VirtualMachine lifecycle in a Pod lifecycle. Disks Networking qemu with libvirt in a Pod cgroups and Namespaces Migrations on top of Kubernetes

25

slide-33
SLIDE 33

ADDITIONAL FEATURES

VirtualMachineReplicaSet Cloud Provider Nested Kubernetes Nodes Cloud Init Console/Spice access More to come ...

26

slide-34
SLIDE 34

PILLARS AND EFFECTS.

libvirt, … everything in pods New resource type for VMs to manage VMs VMs live inside pods Operator pattern Native Kubernetes add-on with VM functionality Declarative, like everything else Kubernetes' infrastructure is leveraged API server ⇝ ⇝ ⇝ ⇝

(tabor-roeder, CC BY 2.0) 27

slide-35
SLIDE 35

$ minikube start --vm-driver kvm --network-plugin cni $ git clone https://github.com/kubevirt/demo.git $ cd demo $ bash run-demo.sh

TRY (WITH

) MINIKUBE

28 . 1

slide-36
SLIDE 36

$ bash run-mini-demo.sh # Deploying KubeVirt ... vm "testvm" created Waiting for KubeVirt to be ready ... Waiting for KubeVirt to be ready ... Waiting for KubeVirt to be ready ... # KubeVirt is now ready. Try: # $ kubectl get vms $ kubectl get vms NAME KIND testvm VM.v1alpha1.kubevirt.io $ kubectl get pods NAME READY STATUS RESTARTS AGE haproxy-723816479-wcblm 1/1 Running 1 49s iscsi-demo-target-tgtd-1270025779-nckbh 1/1 Running 0 48s libvirt-8zj1k 2/2 Running 0 48s spice-proxy-3525077118-fswn9 1/1 Running 0 47s virt-api-1956313626-t9rhj 1/1 Running 0 46s virt-controller-2251532855-tfm9f 1/1 Running 0 45s virt-handler-s7g76 1/1 Running 0 43s virt-launcher-testvm-----q05vh 1/1 Running 0 38s virt-manifest-1665692876-cs8wp 2/2 Running 0 42s $ kubectl exec -it libvirt-8zj1k bash Defaulting container name to libvirtd. Use 'kubectl describe pod/libvirt-8zj1k' to see all of the containers in this pod. # virsh list Id Name State

  • 1 default_testvm running

# exit 28 . 2

slide-37
SLIDE 37

@kubevirt kubevirt Thank you. Learn and contribute at http://kubevirt.io

29