unified kubernetes cri runtimes based on kata …...unified kubernetes cri runtimes based on kata...

22
Unified Kubernetes CRI runtimes based on Kata Containers Xu Wang (@gnawux) hyper.sh

Upload: others

Post on 22-May-2020

13 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Unified Kubernetes CRI runtimes based on Kata …...Unified Kubernetes CRI runtimes based on Kata Containers Xu Wang (@gnawux) hyper.sh Agenda •Kubernetes CRI Deep Dive •The Current

Unified Kubernetes CRI runtimes based on Kata Containers

Xu Wang (@gnawux)hyper.sh

Page 2: Unified Kubernetes CRI runtimes based on Kata …...Unified Kubernetes CRI runtimes based on Kata Containers Xu Wang (@gnawux) hyper.sh Agenda •Kubernetes CRI Deep Dive •The Current

Agenda

• Kubernetes CRI Deep Dive

• The Current CRI Implementations

• CRI and Kata Containers

Page 3: Unified Kubernetes CRI runtimes based on Kata …...Unified Kubernetes CRI runtimes based on Kata Containers Xu Wang (@gnawux) hyper.sh Agenda •Kubernetes CRI Deep Dive •The Current

A Brief History of K8S CRI• Once upon a time…

• rkt was added into kubelet as the 2nd runtime.• Increased the complexity on maintenance

• Docker (the 1st runtime) introduced more and more feature.

• Don’t like a simple runtime any more

• Hyper.sh joined the community and tried to become a third runtime.

Page 4: Unified Kubernetes CRI runtimes based on Kata …...Unified Kubernetes CRI runtimes based on Kata Containers Xu Wang (@gnawux) hyper.sh Agenda •Kubernetes CRI Deep Dive •The Current

The Birth of CRI

• Developers from Google, CoreOS, and Hyper.sh drafted a kubelet-runtime interface together.

• The interface, CRI, was written with gRPC• gRPC had already been open sourced at that time.• The performance difference between gRPC and HTTP/REST was tested

• First CRI implementation: dockershim• First Non-Docker CRI implementation: Frakti

The Kubelet should not vendor a runtime implementation.(Unfortunately, this is not the original words literally)

Page 5: Unified Kubernetes CRI runtimes based on Kata …...Unified Kubernetes CRI runtimes based on Kata Containers Xu Wang (@gnawux) hyper.sh Agenda •Kubernetes CRI Deep Dive •The Current

The CRI Interface

• Describe what kubelet expects from container runtimes • Imperative container-centric interface • Extensibility

kubeletSyncLoop SyncPod

GenericRuntimepod CRI shim(cri-o, frakti, etc.)

CRI gRPC

kubeletCRI Spec

SandboxCreateDeleteListContainerCreateStartExecImagePullList

Page 6: Unified Kubernetes CRI runtimes based on Kata …...Unified Kubernetes CRI runtimes based on Kata Containers Xu Wang (@gnawux) hyper.sh Agenda •Kubernetes CRI Deep Dive •The Current

Implement a CRI Runtime (1)

Pod foo

ContainerA

ContainerB

Lifecycle

1. RunPodSandbox(foo)

2. CreatContainer(A)

3. StartContainert(A)

4. CreatContainer(B)

5. StartContainer(B)

Node

A B

Sandbox foo

Created Running Exitednil nil

CreatContainer()

StartContainer()

StopContainer()

RemoveContainer()

Page 7: Unified Kubernetes CRI runtimes based on Kata …...Unified Kubernetes CRI runtimes based on Kata Containers Xu Wang (@gnawux) hyper.sh Agenda •Kubernetes CRI Deep Dive •The Current

Implement a CRI Runtime (2)Streaming

apiserver

kubelet

CRI shim

RuntimeService

StreamServer

Exec() request

url

CRI Exec()

url of streaming server

"/exec/{token}"

stream resp

Page 8: Unified Kubernetes CRI runtimes based on Kata …...Unified Kubernetes CRI runtimes based on Kata Containers Xu Wang (@gnawux) hyper.sh Agenda •Kubernetes CRI Deep Dive •The Current

The Existing CRI RuntimesCRI-O, cri-containerd, frakti, and how they work

Page 9: Unified Kubernetes CRI runtimes based on Kata …...Unified Kubernetes CRI runtimes based on Kata Containers Xu Wang (@gnawux) hyper.sh Agenda •Kubernetes CRI Deep Dive •The Current

The Existing CRI Runtimes• containerd/cri (cri-containerd)

• containerd and k8s node team

• CRI-O• Red Hat etc.

• frakti• Hyper.sh etc.

Page 10: Unified Kubernetes CRI runtimes based on Kata …...Unified Kubernetes CRI runtimes based on Kata Containers Xu Wang (@gnawux) hyper.sh Agenda •Kubernetes CRI Deep Dive •The Current

Containerd (w/ cri plugin) in brief

Kubelet CRI service(cri plugin)

Meta services(images, containers…)

Runtime service(tasks)

Storage service(snapshot)

shim

runtime(e.g. runc)

CRI/gRPC

Other Containerd client(ctr, standalone cri-

containerd)

containerd

Containerd gRPCinterface

Container

Pod Sandbox

shim

runtime(e.g. runc)

Page 11: Unified Kubernetes CRI runtimes based on Kata …...Unified Kubernetes CRI runtimes based on Kata Containers Xu Wang (@gnawux) hyper.sh Agenda •Kubernetes CRI Deep Dive •The Current

CRI-O in brief

Kubelet CRI service

-

Runtime(oci)

Image/rootfs storage

shim

runtime(e.g. runc)

CRI/gRPC

CRI-O

Container

Pod Sandbox

shim

runtime(e.g. runc)

Similar to Containerd, right?

Page 12: Unified Kubernetes CRI runtimes based on Kata …...Unified Kubernetes CRI runtimes based on Kata Containers Xu Wang (@gnawux) hyper.sh Agenda •Kubernetes CRI Deep Dive •The Current

Frakti 1.0 in brief

• Frakti is a CRI shim

• Hyperd implements the CRI semantics for runV

Kubelet

CRI s

ervi

ce

Dockershim

Hyperdclient

unikernel

CRI/gRPC

frakti

Container

Pod Sandbox

Docker daemon(for privileged pods)

Runtime(runV)

Image/rootfsstorage

streams

gRPC

serv

ice

hyperd

HyperdgRPC

Page 13: Unified Kubernetes CRI runtimes based on Kata …...Unified Kubernetes CRI runtimes based on Kata Containers Xu Wang (@gnawux) hyper.sh Agenda •Kubernetes CRI Deep Dive •The Current

CRI and Kata Containers

Page 14: Unified Kubernetes CRI runtimes based on Kata …...Unified Kubernetes CRI runtimes based on Kata Containers Xu Wang (@gnawux) hyper.sh Agenda •Kubernetes CRI Deep Dive •The Current

History of Kata

Page 15: Unified Kubernetes CRI runtimes based on Kata …...Unified Kubernetes CRI runtimes based on Kata Containers Xu Wang (@gnawux) hyper.sh Agenda •Kubernetes CRI Deep Dive •The Current

Technical Vision of Kata• Light and fast VM-based containers

• Merge Intel® Clear Containers and Hyper runV technologies

• Supporting existing user projects

• Seamless integration with Kubernetes (CRI), Docker and Openstack

• Support multiple architectures

• Support multiple hypervisors

Page 16: Unified Kubernetes CRI runtimes based on Kata …...Unified Kubernetes CRI runtimes based on Kata Containers Xu Wang (@gnawux) hyper.sh Agenda •Kubernetes CRI Deep Dive •The Current

How Kata Works• Each pod is hypervisor

isolated

• As secure as a VM

• As fast as a container

• Seamless integration with the container ecosystem and management layers

*Other names and brands may be claimed as the property of others.

Page 17: Unified Kubernetes CRI runtimes based on Kata …...Unified Kubernetes CRI runtimes based on Kata Containers Xu Wang (@gnawux) hyper.sh Agenda •Kubernetes CRI Deep Dive •The Current

CRI for Kata Contaienrs• Kata Containers is designed to be compatible with

Kubernetes• Integration Methods

• Kata Containers as a standalone tool• runC compatible command line• OCI specs• Work with containerd and CRI-O

• Kata Containers as a runtime lib• runV compatible APIs• Work with frakti• (containerd plugin?)

Page 18: Unified Kubernetes CRI runtimes based on Kata …...Unified Kubernetes CRI runtimes based on Kata Containers Xu Wang (@gnawux) hyper.sh Agenda •Kubernetes CRI Deep Dive •The Current

containerd/CRI-O + Kata

Runtime

Image/rootfs storage

Kata Agent

Pod Sandbox

shim

Kata cmdline

Container

shim

proxy

Container

virt-serial or vsock

No proxy when vscok enabled

filesystem sharing

Create container with translated OCI spec

runc cmdline and OCIspec

Page 19: Unified Kubernetes CRI runtimes based on Kata …...Unified Kubernetes CRI runtimes based on Kata Containers Xu Wang (@gnawux) hyper.sh Agenda •Kubernetes CRI Deep Dive •The Current

Frakti + KataCR

I ser

vice

Kata Lib

unikernel

frakti 2

Image/rootfsstorage

streamsCRI/gRPC

Kata Agent

Pod Sandbox

Container

Container

virt-serial or vsock

Create container with translated OCI spec

filesystem, block, network storages

Page 20: Unified Kubernetes CRI runtimes based on Kata …...Unified Kubernetes CRI runtimes based on Kata Containers Xu Wang (@gnawux) hyper.sh Agenda •Kubernetes CRI Deep Dive •The Current

Comparison• Share more code parts• Shims and Proxy Process• Process• Memory

• And more resources• Rootfs and Volumes• Networking plug-ins

Page 21: Unified Kubernetes CRI runtimes based on Kata …...Unified Kubernetes CRI runtimes based on Kata Containers Xu Wang (@gnawux) hyper.sh Agenda •Kubernetes CRI Deep Dive •The Current

What’s the Next of Frakti• Integration with containerd

• Plug-in instead of vendor

• Integrate with kata via kata runtime lib

• Coming soon

• Improvements on Unikernel(like) runtime support

CRI s

ervi

ce

unikernel

containerd / frakti plugins

Image/rootfsstorage

streams

Kata Agent

(VM) Pod Sandbox

Container

Container

virt-serial or vsock

Create container with translated OCI spec

filesystem, block, network storages

Kata libs based task plugin

CR

I/gR

PC

Kata Agent Container

Container

Unix domain socket

Page 22: Unified Kubernetes CRI runtimes based on Kata …...Unified Kubernetes CRI runtimes based on Kata Containers Xu Wang (@gnawux) hyper.sh Agenda •Kubernetes CRI Deep Dive •The Current

Meet Kata Containers at the OpenStack Summit Vancouver

https://katacontainers.io/posts/kata-containers-openstack-vancouver/