37
RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1

RUNNING VIRTUAL MACHINES ON KUBERNETES · RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1

  • Upload
    vonga

  • View
    247

  • Download
    7

Embed Size (px)

Citation preview

Page 1: RUNNING VIRTUAL MACHINES ON KUBERNETES · RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1

RUNNING VIRTUAL MACHINES ONKUBERNETESRoman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017

1

Page 2: RUNNING VIRTUAL MACHINES ON KUBERNETES · RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1

FABIAN DEUTSCH

Fedora user and formerpackage maintainer

oVirt and KubeVirt Contributor

Working at Red Hat

ROMAN MOHR

oVirt and KubeVirt Contributor

Working at Red Hat

[email protected]

@dummdida

fabiand

https://dummdida.tumblr.com

[email protected]

@rfenkhuber

rmohr

2

Page 3: RUNNING VIRTUAL MACHINES ON KUBERNETES · RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1

VIRTUALIZATION ISOMNIPRESENT. TODAY.

(drome, CC BY-NC 2.0)3

Page 5: RUNNING VIRTUAL MACHINES ON KUBERNETES · RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1

CONTAINERS LOOK, TASTE, ANDSMELL THE SAME - JUST BETTER

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

(colinwarren, CC BY-NC 2.0)5

Page 6: RUNNING VIRTUAL MACHINES ON KUBERNETES · RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1

"HOW DO WE GET THERE?"

"HOW CAN I REPLACE MY VMSWITH CONTAINERS? HOW!?"

6 . 1

Page 7: RUNNING VIRTUAL MACHINES ON KUBERNETES · RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1

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

Technology? Features? Feeling? Tools?Requirements?

6 . 2

Page 8: RUNNING VIRTUAL MACHINES ON KUBERNETES · RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1

⇝⇝ IT DEPENDS

6 . 3

Page 9: RUNNING VIRTUAL MACHINES ON KUBERNETES · RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1

NOT YET?"NEVER"?

Yes No

COOL

Replace?

7 . 1

Page 10: RUNNING VIRTUAL MACHINES ON KUBERNETES · RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1

MIGRATION

If workloads can be moved tocontainers, then it's amigration

CONVERGENCE

If not, then we still wantconvergence

7 . 2

Page 11: RUNNING VIRTUAL MACHINES ON KUBERNETES · RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1

Yes No

Replace?

XX% YY%

BOTH.8

Page 12: RUNNING VIRTUAL MACHINES ON KUBERNETES · RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1

Yes

MIGRATION PATH?

Replace?

DOUBLEDINFRASTRUCTURE?

No

9 . 1

Page 13: RUNNING VIRTUAL MACHINES ON KUBERNETES · RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1

Management Plane

Storage Network …

Virtual Machines

Management Plane

Storage Network …

Containers

2X INFRASTRUCTURE?9 . 2

Page 14: RUNNING VIRTUAL MACHINES ON KUBERNETES · RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1

Virtualization and containers

( )giphy10

Page 15: RUNNING VIRTUAL MACHINES ON KUBERNETES · RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1

KUBEVIRT

11

Page 16: RUNNING VIRTUAL MACHINES ON KUBERNETES · RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1

CONTAINERS&

VIRTUAL MACHINESon the same infrastructure.

12 . 1

Page 17: RUNNING VIRTUAL MACHINES ON KUBERNETES · RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1

Management Plane

Storage Network …

Virtual Machines

Containers

KEEP YOUR VMS …12 . 2

Page 18: RUNNING VIRTUAL MACHINES ON KUBERNETES · RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1

Management Plane

Storage Network …

Virtual Machines

Containers

… TRANSITION WHAT YOU NEED …12 . 3

Page 19: RUNNING VIRTUAL MACHINES ON KUBERNETES · RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1

Management Plane

Storage Network …

Virtual Machines

Containers

… AND STICK TO VMS AS NEEDED.12 . 4

Page 21: RUNNING VIRTUAL MACHINES ON KUBERNETES · RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1

Kubernetes

Storage Network …

Virtual Machines

Containers

14

Page 22: RUNNING VIRTUAL MACHINES ON KUBERNETES · RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1

Kubernetes

Storage Network …

Virtual Machines

Containers

+ KubeVirt

15

Page 23: RUNNING VIRTUAL MACHINES ON KUBERNETES · RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1

HOW DOES KUBEVIRTINTEGRATE WITH KUBERNETES?

The Details.

16

Page 24: RUNNING VIRTUAL MACHINES ON KUBERNETES · RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1

kind: Podmetadata: name: nginx labels: name: nginxspec: containers: - name: nginx image: nginx:latest ports: - containerPort: 80 nodeSelector: cpu: faststatus: phase: Running

KUBERNETES API

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

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

Page 25: RUNNING VIRTUAL MACHINES ON KUBERNETES · RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1

HOW ABOUT TREATINGA 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 domigrations.Implement as much functionality as possible from theKubelet, since there is not way to distinguish fromoutside what your VM Pod supports, compared to anormal Pod.Are we talking about a VM Pod or a Pod?

18

Page 26: RUNNING VIRTUAL MACHINES ON KUBERNETES · RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1

HOW ABOUT ADDINGAN EXPLICIT VIRT API?

Allows a proper Virtual Machine SpecificationWe can ship KubeVirt as a pue add-on. No Nodemodifications are necessary.No matter, how much Pods are necessary to perform amigration, we have one single entrypoint to the VirtualMachine.Reuse all of the kubelet and Pod Spec functionality, byrunning a Virtual Machine inside the PodTalk about VMs when they are VMs, talk about Podswhen they are Pods.

19

Page 27: RUNNING VIRTUAL MACHINES ON KUBERNETES · RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1

kind: VirtualMachinemetadata: name: testvmspec: domain: devices: type: PersistentVolumeClaim device: disk source: name: myVolumeClaim nodeSelector: cpu: faststatus: 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 theVM starts correctly inside.

20

Page 28: RUNNING VIRTUAL MACHINES ON KUBERNETES · RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1

kind: VirtualMachinemetadata: name: testvmspec: 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

Page 30: RUNNING VIRTUAL MACHINES ON KUBERNETES · RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1

kind: Migrationmetadata: generateName: my-migrationspec: nodeSelector: kubevirt.io/hostname: node1 selector: name: testvmstatus: phase: Succeeded

MIGRATIONS

Backed by a controller:

On object create, schedules a new Pod

On successful Pod start, it triggers themigration

At the end of the migration the object ismoved to a final state

Always one VirtualMachine object youreference

The objects Migration with VirtualMachineprovide a consistent entry point to anythingVirtualMachine related, like the Pod does forKubernetes. 23

Page 31: RUNNING VIRTUAL MACHINES ON KUBERNETES · RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1

API CHALLENGESFeature wise comparable to domxmlCertain features are node specific - they need to beabstractedNeeds to be married with Kubernetes concepts (pv, networks)Needs additional data for cluster-only features like scheduling

24

Page 32: RUNNING VIRTUAL MACHINES ON KUBERNETES · RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1

INTEGRATION CHALLENGESProperly integrate the VirtualMachine lifecycle in a Pod lifecycle.

DisksNetworkingqemu with libvirt in a Podcgroups and NamespacesMigrations on top of Kubernetes

25

Page 33: RUNNING VIRTUAL MACHINES ON KUBERNETES · RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1

ADDITIONAL FEATURES

VirtualMachineReplicaSetCloud ProviderNested Kubernetes NodesCloud InitConsole/Spice accessMore to come ...

26

Page 34: RUNNING VIRTUAL MACHINES ON KUBERNETES · RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1

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 isleveraged

API server

(tabor-roeder, CC BY 2.0)27

Page 35: RUNNING VIRTUAL MACHINES ON KUBERNETES · RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1

$ 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

Page 36: RUNNING VIRTUAL MACHINES ON KUBERNETES · RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1

$ bash run-mini-demo.sh# Deploying KubeVirt...vm "testvm" createdWaiting 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 vmsNAME KINDtestvm VM.v1alpha1.kubevirt.io

$ kubectl get podsNAME READY STATUS RESTARTS AGEhaproxy-723816479-wcblm 1/1 Running 1 49siscsi-demo-target-tgtd-1270025779-nckbh 1/1 Running 0 48slibvirt-8zj1k 2/2 Running 0 48sspice-proxy-3525077118-fswn9 1/1 Running 0 47svirt-api-1956313626-t9rhj 1/1 Running 0 46svirt-controller-2251532855-tfm9f 1/1 Running 0 45svirt-handler-s7g76 1/1 Running 0 43svirt-launcher-testvm-----q05vh 1/1 Running 0 38svirt-manifest-1665692876-cs8wp 2/2 Running 0 42s

$ kubectl exec -it libvirt-8zj1k bashDefaulting 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

Page 37: RUNNING VIRTUAL MACHINES ON KUBERNETES · RUNNING VIRTUAL MACHINES ON KUBERNETES Roman Mohr & Fabian Deutsch, Red Hat, KVM Forum, 2017 1

@kubevirt

kubevirt

Thank you.

Learn and contribute at http://kubevirt.io

29