Top Banner
OK, so I have all these Containers What now?
52

What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

Sep 24, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

OK, so I have all these ContainersWhat now?

Page 2: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

Image by Connie Zhou

Page 3: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

#kubernetes @tekgrrl

job hello_world = {

runtime = { cell = 'ic' } // Cell (cluster) to run in

binary = '.../hello_world_webserver' // Program to run

args = { port = '%port%' } // Command line parameters

requirements = { // Resource requirements

ram = 100M

disk = 100M

cpu = 0.1

}

replicas = 5 // Number of tasks

}

10000

Developer View

Page 4: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

#kubernetes @tekgrrl

Developer View

Page 5: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

#kubernetes @tekgrrl

web browsers

BorgMaster

link shard

UI shardBorgMaster

link shard

UI shardBorgMaster

link shard

UI shardBorgMaster

link shard

UI shard

Scheduler

borgcfg web browsers

scheduler

Borglet Borglet Borglet Borglet

Config file

BorgMaster

link shard

UI shard

persistent store (Paxos)

Binary

Developer View

What justhappened?

Page 6: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

Hello world!

Hello world!

Hello world!

Hello world!Hello

world! Hello world! Hello

world!

Hello world!

Hello world!

Hello world!

Hello world!

Hello world!

Hello world!

Hello world!

Hello world!

Hello world!

Hello world!Hello world!

Hello world!

Hello world!

Hello world!

Hello world!

Hello world! Hello

world!

Hello world!

Hello world!

Hello world!

Image by Connie Zhou

Hello world!

Hello world!

Hello world! Hello

world!

Hello world! Hello

world!

Hello world!

Hello world!

Hello world!

Hello world!

Hello world! Hello

world!

Hello world! Hello

world!

Hello world!

Hello world!

Hello world!

Hello world!

Hello world! Hello

world!

Hello world! Hello

world!

Hello world!

Hello world!

Page 7: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

#kubernetes @tekgrrl

php

MySQL

memcached

phpphp

PHP

Guestbook App

Client

Page 8: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

Containers

Page 9: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

#kubernetes @tekgrrl

Old Way: Shared Machines

No isolation

No namespacing

Common libs

Highly coupled apps and OS

kernel

libs

app

app app

app

Page 10: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

#kubernetes @tekgrrl

Old Way: Virtual Machines

Some isolation

Inefficient

Still highly coupled to the guest OS

Hard to manage app

libskernel

libs

app app

kernel

app

libs

libskernel

kernel

Page 11: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

#kubernetes @tekgrrl

New Way: Containers

libs

app

kernel

libs

app

libs

app

libs

app

Page 12: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

#kubernetes @tekgrrl

Container Images

● An image is a stack of Read-Only file system layers.

● Usual process:○ build○ push to repository○ pull to execution host○ start container from image Debian

App

PHP & Apache

Libs

Page 13: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

#kubernetes @tekgrrl

Image Layers

Read / Write Read / Write

Debian

App

PHP & Apache

Libs

Read / Write

● A container is a process ○ started with kernel restrictions○ a stack of shared Read-Only

file system layers○ plus a process specific Read-

Write layer

● Every new container gets a new Read-Write later. All containers from the same image start from exactly the same state!

Page 14: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

#kubernetes @tekgrrl

Mounting Host Directories● It's possible to mount host

directories into a container's filesystem.

● These are mutable and do outlive the container.

● They're only available on that host.

Debian

App

PHP & Apache

Libs

Read / Write

host dir

Page 15: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

#kubernetes @tekgrrl

Docker Example

Server

Debian

Docker Engine

MySQLMemcached

libs

libs

libslibs

App

PHP & Apache

Page 16: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

Why containers?

• Performance

• Repeatability

• Quality of service

• Accounting

• Portability

A fundamentally different way of managing applications

Images by Connie Zhou

Page 17: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

#kubernetes @tekgrrl

containers are awesomelet's use lots of them!

Page 18: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

Demo

Page 19: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

Kubernetes

Page 20: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

Greek for “Helmsman”; also the root of the word “Governor”

• Orchestrator for Docker containers

• Supports multi-cloud environments

• Inspired and informed by Google’s experiences and internal systems

• Open source, written in Go

Manage applications, not machines

Kubernetes

Page 21: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

#kubernetes @tekgrrl

Concepts Intro

Container Pod Volume

Replication Controller

Service

NodeLabel

Page 22: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

@tekgrrl #kubernetes #gotoldn

web browsers

yKubelet Kubelet Kubelet Kubelet

Kubernetes Master

ReplicationController Scheduler

API Server

Kube-UI

ContainerRegistry

kubectl

Proxy

<Your App>

web browsersDeveloper View (Kubernetes)

Page 23: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

Cluster Options

From Laptop to high-availability multi-node cluster

Hosted or self managed

On-Premise or Cloud

Bare Metal or Virtual Machines

Many options, See Matrix for details

Kubernetes Cluster Matrix: http://bit.ly/1MmhpMW

Page 24: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

So what do we run on the nodes? Containers?

Page 25: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

Demo

Page 26: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

#kubernetes @tekgrrl

The atom of scheduling for containers

Application specific “logical host”

Ephemeral• can die and be replaced

Single container pods can be created directly from a container image

Pod

Web Server

Volume

Consumers

Pods

Page 27: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

Can be used to group containers & shared volumes

Containers are tightly coupled

Shared namespace• Shared network IP and port namespace

Ephemeral• Containers in pods live and die together

Think in terms of services that you usually run on the same machine

Pods

Pod

GitSynchronizer

Node.js App Container

Volume

ConsumersGithub

Page 28: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

Bound to the Pod that encloses it

Look like Directories to Containers

What and where they are determined by Volume Type

Many Volume options

Volume

Pod● EmptyDir○ Lives with the pod

Page 29: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

Bound to the Pod that encloses it

Look like Directories to Containers

What and where they are determined by Volume Type

Many Volume options

Volume

Pod● EmptyDir● HostPath

○ Maps to directory on host○ Use with caution

/<rootdir> | |__/etc |--/usr |--/var | |--/log

Page 30: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

Bound to the Pod that encloses it

Look like Directories to Containers

What and where they are determined by Volume Type

Many Volume options

Volume

Pod● EmptyDir● HostPath● nfs (and similar services) NFS

Page 31: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

Bound to the Pod that encloses it

Look like Directories to Containers

What and where they are determined by Volume Type

Many Volume options

Volume

Pod● EmptyDir● HostPath● nfs (and similar services)● Cloud Provider Block Storage

Page 32: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

#kubernetes @tekgrrl

Dashboard

show: type = FE

Pod Pod

frontend

Pod

frontend

Pod Pod

Dashboard

show: version = v2type = FE

version = v2type = FE version = v2

● Metadata with semantic meaning● Membership identifier● The only Grouping Mechanism

Behavior Benefits

➔ Allow for intent of many users (e.g. dashboards)➔ Build higher level systems … ➔ Queryable by Selectors

Labels ← These are important

Page 33: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

#kubernetes @tekgrrl

Developer View (Replication Controller) selector: name: frontend … spec: containers: - name: php-guestbook image: php-guestbook:europython resources: limits: memory: "128Mi" cpu: "500m" ports: - containerPort: 80 protocol: TCP replicas: 110000

Page 34: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

#kubernetes @tekgrrl

Replication Controller

Pod Pod

frontend

Pod

frontend

Pod Pod

Replication Controller

#pods = 1version = v2

show: version = v2

version= v1 version = v1 version = v2

Replication Controller

#pods = 2version = v1

show: version = v2 Behavior Benefits

● Keeps Pods running● Gives direct control of Pod #s● Grouped by Label Selector

➔ Recreates Pods, maintains desired state➔ Fine-grained control for scaling ➔ Standard grouping semantics

Replication Controllers

Page 35: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

#kubernetes @tekgrrl

Replication Controller

Replication Controller- Name = “nifty-rc”- Selector = {“App”: “Nifty”}- PodTemplate = { ... }- NumReplicas = 4

API Server

3

Start 1 more

OK 4

How many?

How many?

Canonical example of control loops

Have one job: ensure N copies of a pod● if too few, start new ones● if too many, kill some● group == selector

Replicated pods are fungible● No implied order or identity

Replication Controllers

Page 36: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

#kubernetes @tekgrrl

Container Liveness

Process Level: Kubelet checks with Docker that Container is running

App Level: User defined health checks:

● HTTP Health checks (Kubelet calls a Web Hook)

● Container Exec (Kubelet runs command in container)

● TCP Socket (Kubelet attempts to open a socket to the container)

Page 37: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

#kubernetes @tekgrrl

Portal (VIP)

Client

Pod

Container

Pod

Container

Pod

ContainerContainer

A logical grouping of pods that perform the same function

• group == selector

Choice of pod is random but supports session affinity (ClientIP)

Gets a stable virtual IP and port• also a DNS name

Hide complexity - ideal for non-native apps

Services

Page 38: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

#kubernetes @tekgrrl

Service

Label selectors: version = 1.0 type = Frontend

Service

Label selector: type = FE

Replication Controller

Pod Pod

frontend

Pod

version= v1 version = v1

Replication Controller

version = v1#pods = 2

show: version = v2

type = FE type = FE

VIP

Canary Example

Replication ControllerReplication Controller

version = v2#pods = 1

show: version = v2

Pod

frontend

Pod

version = v2type = FE

Page 39: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

#kubernetes @tekgrrl

php

MySQL

phpphppython

memcached

Mapping to Kubernetes

Client

Page 40: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

#kubernetes @tekgrrl

Database

I still have questions about state!

In a cluster of ephemeral containersApplication state must exist outside of the container

Page 41: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

#kubernetes @tekgrrl

Outside the Cluster

App Pod App Pod App Pod

App Pod App Pod App Pod

App Pod App Pod App Pod

e.g.: MySQL managed by DBAs or managed cloud services

Database

Page 42: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

#kubernetes @tekgrrl

Adapt to run in the Cluster

Database

App Pod App Pod App Pod

App Pod App Pod App Pod

App Pod App Pod App Pod

e.g.: MySQL runs in a pod and mounts a filesystem provided by the cluster

Page 43: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

#kubernetes @tekgrrl

Cluster Native

App Pod App Pod App Pod

App Pod App Pod App Pod

App Pod App Pod App Pod

ex: run Cassandra or Riak inside the cluster

Page 44: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

Demo

Page 45: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

Container Engine

Page 46: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

Google Container Engine (Beta)Managed Kubernetes (Kubernetes v1)

Manages Kubernetes master uptime

Manages Updates

Cluster Resize via Managed Instance Groups

Centralised Logging

Google Cloud VPN support

Page 47: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

Kubernetes 1.0 as of mid July• Formerly announced at OSCON this week

Open sourced in June, 2014• won the BlackDuck “rookie of the year” award

Google launched Google Container Engine (GKE)• hosted Kubernetes• https://cloud.google.com/container-engine/

Roadmap:• https://github.com/GoogleCloudPlatform/kubernetes/milestones

Kubernetes Status

Page 48: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

Demo - Visualization

Page 49: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

#kubernetes @tekgrrl

Node3

Kubelet Proxy

Pod

ContainerContainerContainerContainer

Pod

ContainerContainerContainerContainer

Node3

Kubelet Proxy

Pod

ContainerContainerContainerContainer

Pod

ContainerContainerContainerContainer

Node1

Kubelet Proxy

Pod

ContainerContainer

Pod

$ kubectl proxy --www=k8s-visualizer/

Visualizing Kubernetes

Master

APIs

SchedulingREST

(pods, services, controllers)

AuthN

Scheduler ReplicationController

Container

Page 50: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

Open Container Initiative

why argue about the width of train tracks, when you can worry about laying track and building the best possible engines?

Page 51: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

#kubernetes @tekgrrl

Kubernetes is Open SourceWe want your help!

http://kubernetes.io

https://github.com/GoogleCloudPlatform/kubernetes

irc.freenode.net #google-containers

@kubernetesio

Page 52: What now? OK, so I have all these Containersgotocon.com/dl/goto-london-2015/slides/MandyWaite_OKSoI...#kubernetes @tekgrrl Mounting Host Directories It's possible to mount host directories

#kubernetes @tekgrrl

Tweet questions to: @tekgrrl

Questions