So, I have all these containers! Now what? Image by Connie Zhou - - PowerPoint PPT Presentation

so i have all these containers now what
SMART_READER_LITE
LIVE PREVIEW

So, I have all these containers! Now what? Image by Connie Zhou - - PowerPoint PPT Presentation

So, I have all these containers! Now what? Image by Connie Zhou Developer View job hello_world = { runtime = { cell = 'ic' } // Cell (cluster) to run in binary = '.../hello_world_webserver' // Program to run args = { port = '%port%'


slide-1
SLIDE 1

So, I have all these containers! Now what?

slide-2
SLIDE 2

Image by Connie Zhou

slide-3
SLIDE 3

@tekgrrl #europython #kubernetesio

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

slide-4
SLIDE 4

@tekgrrl #europython #kubernetesio

Developer View

slide-5
SLIDE 5

@tekgrrl #europython #kubernetesio

web browsers BorgMaster link shard UI shard BorgMaster link shard UI shard BorgMaster link shard UI shard BorgMaster 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 just happened?

slide-6
SLIDE 6

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!

slide-7
SLIDE 7

@tekgrrl #europython #kubernetesio

Developer View

slide-8
SLIDE 8

@tekgrrl #europython #kubernetesio

task-eviction rates and causes

Failures

slide-9
SLIDE 9

@tekgrrl #europython #kubernetesio

stranded resources available resources

  • ne

machine

Efficiency

Advanced bin- packing algorithms

Experimental placement of production VM workload, July 2014

slide-10
SLIDE 10

@tekgrrl #europython #kubernetesio

tasks per machine

Efficiency

Multiple applications per machine

CPI^2 paper, EuroSys 2013

slide-11
SLIDE 11

@tekgrrl #europython #kubernetesio

potentially reusable resources

Resource reclamation

time

limit: amount of resource requested usage: actual resource consumption reservation: estimate of future usage

Efficiency

slide-12
SLIDE 12

Images by Connie Zhou

Observations:

1. If your developers are spending time thinking about individual machines, you’re

  • perating at too low-level of an
  • abstraction. You want to operate at the

level of applications 2. We get efficiency by: a. sharing resources b. reclaiming unused allocations 3. Containers make users more productive

http://kubernetes.io

http://goo.gl/1C4nuo (Borg paper)

slide-13
SLIDE 13

@tekgrrl #europython #kubernetesio

php

memcached

php php

Python

Guestbook App

Client

MySQL

slide-14
SLIDE 14

Containers

slide-15
SLIDE 15

@tekgrrl #europython #kubernetesio

Old Way: Shared Machines

No isolation No namespacing Common libs Highly coupled apps and OS

kernel libs app app app app

slide-16
SLIDE 16

@tekgrrl #europython #kubernetesio

Old Way: Virtual Machines

Some isolation Inefficient Still highly coupled to the guest OS Hard to manage

app libs kernel libs app app kernel app libs libs kernel kernel

slide-17
SLIDE 17

@tekgrrl #europython #kubernetesio

New Way: Containers

libs app kernel libs app libs app libs app

slide-18
SLIDE 18

@tekgrrl #europython #kubernetesio

Docker Example

Server Debian Docker Engine PHP & Apache MySQL Memcached libs libs libs libs

slide-19
SLIDE 19

Why containers?

  • Performance
  • Repeatability
  • Quality of service
  • Accounting
  • Portability

A fundamentally different way of managing applications

Images by Connie Zhou

slide-20
SLIDE 20

Demo

slide-21
SLIDE 21

Kubernetes

slide-22
SLIDE 22

@tekgrrl #europython #kubernetesio

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

slide-23
SLIDE 23

@tekgrrl #europython #kubernetesio

Concepts Intro

Container Pod Volume Replication Controller Service Node Label

slide-24
SLIDE 24

@tekgrrl #europython #kubernetesio

Kubernetes Master

Replication Controller Scheduler API Server

Kubernetes Node

Kubelet Proxy Pod Container Container Container Container Pod Container Container Container Container

Kubernetes Node

Kubelet Proxy Pod Container Container Container Container Pod Container Container Container Container

Kubernetes Node

Kubelet Proxy Pod Container Pod Container Container

Kubernetes Cluster

slide-25
SLIDE 25

@tekgrrl #europython #kubernetesio

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

slide-26
SLIDE 26

@tekgrrl #europython #kubernetesio

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

slide-27
SLIDE 27

@tekgrrl #europython #kubernetesio

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

Git Synchronizer Node.js App Container

Volume

Consumers Github

slide-28
SLIDE 28

@tekgrrl #europython #kubernetesio

Bound to the Pod that encloses it Look like Directories to Containers What and where they are determined by Volume Type Many Volume Type options

Volume

Pod

  • EmptyDir

○ Lives with the pod ○ Can be backed by Memory (tmpfs)

slide-29
SLIDE 29

@tekgrrl #europython #kubernetesio

Bound to the Pod that encloses it Look like Directories to Containers What and where they are determined by Volume Type Many Volume Type options

Volume

Pod

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

  • EmptyDir
  • HostPath

○ Maps to directory on host ○ Use with caution

slide-30
SLIDE 30

@tekgrrl #europython #kubernetesio

Bound to the Pod that encloses it Look like Directories to Containers What and where they are determined by Volume Type Many Volume Type options

Volume

Pod

NFS

  • EmptyDir
  • HostPath
  • nfs (and similar services)
slide-31
SLIDE 31

@tekgrrl #europython #kubernetesio

Bound to the Pod that encloses it Look like Directories to Containers What and where they are determined by Volume Type Many Volume Type options

Volume

Pod

  • EmptyDir
  • HostPath
  • nfs (and similar services)
  • Cloud Provider Persistent Block Storage
slide-32
SLIDE 32

@tekgrrl #europython #kubernetesio

Sidecar Pattern

Pod

Git Synchronizer Node.js App Container

Volume

Consumers Github

slide-33
SLIDE 33

@tekgrrl #europython #kubernetesio

Ambassador Pattern

Pod

PHP App Redis Proxy

Consumers

localhost Redis Shards

slide-34
SLIDE 34

@tekgrrl #europython #kubernetesio

Adapter Pattern

Pod

Redis Redis Exporter localhost OR Monitoring System

Volume

slide-35
SLIDE 35

@tekgrrl #europython #kubernetesio

Dashboard

show: type = FE

Pod Pod frontend Pod frontend Pod Pod Dashboard

show: version = v2

type = FE version = v2 type = 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

slide-36
SLIDE 36

@tekgrrl #europython #kubernetesio

Replication Controller Pod Pod frontend Pod frontend Pod Pod Replication Controller #pods = 1 version = v2

show: version = v2

version= v1 version = v1 version = v2

Replication Controller #pods = 2 version = 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

slide-37
SLIDE 37

@tekgrrl #europython #kubernetesio

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

slide-38
SLIDE 38

@tekgrrl #europython #kubernetesio

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
  • pen a socket to the container)

Image: IStockPhoto

slide-39
SLIDE 39

@tekgrrl #europython #kubernetesio

Portal (VIP)

Client

Pod Container Pod Container Pod Container Container

A group of pods that act as one == Service

  • group == selector

Defines access policy

  • nly “load balanced” for now

Gets a stable virtual IP and port

  • called the service portal
  • also a DNS name

VIP is captured by kube-proxy

  • watches the service constituency
  • updates when backends change

Hide complexity - ideal for non-native apps

Services

slide-40
SLIDE 40

@tekgrrl #europython #kubernetesio

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 Controller Replication Controller version = v2 #pods = 1

show: version = v2

Pod frontend Pod

version = v2 type = FE

slide-41
SLIDE 41

@tekgrrl #europython #kubernetesio

php MySQL php php

python

memcache d

Mapping to Kubernetes

Client

slide-42
SLIDE 42

@tekgrrl #europython #kubernetesio

Developer View (Replication Controller)

spec:

containers:

  • name: php-guestbook

image: php-guestbook:europython resources: limits: memory: "128Mi" cpu: "500m" ports:

  • containerPort: 80

protocol: TCP replicas: 1 10000

slide-43
SLIDE 43

@tekgrrl #europython #kubernetesio

Scheduling Capabilities

Predicate based Currently

  • Pod Selection
  • Node Capacity (based on requested resource

limits) Prioritisation

  • Nodes that match all predicates are ranked
  • Priority for Node whose already-running pods

consume the least resources To Come

  • Resource aware scheduling
slide-44
SLIDE 44

@tekgrrl #europython #kubernetesio

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

slide-45
SLIDE 45

@tekgrrl #europython #kubernetesio

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

slide-46
SLIDE 46

Demo - Clusters and resizing

slide-47
SLIDE 47

@tekgrrl #europython #kubernetesio

Node3

Kubelet Proxy Pod Container Container Container Container Pod Container Container Container Container

Node3

Kubelet Proxy Pod Container Container Container Container Pod Container Container Container Container

Node1

Kubelet Proxy Pod Container Container Pod

$ kubectl proxy --www=k8s-visualizer/

Visualizing Kubernetes

Master APIs Scheduling REST (pods, services, controllers) AuthN Scheduler Replication Controller

Container

slide-48
SLIDE 48

@tekgrrl #europython #kubernetesio

Container Engine Cluster Scaling

Managed Instance Group

create/ destroy VMs monitor

Instance Template Instance Group Manager

Managed Instance Group (MIG)

  • Grouping of identical instances
  • Instances are cluster nodes

Nodes Created from Template

  • Includes Credentials and Tokens

required to auth to the Master

MIG can be manually scaled

  • New nodes request to be

added to cluster

  • Will eventually facilitate node

level autoscale

slide-49
SLIDE 49

@tekgrrl #europython #kubernetesio

Google Developers Console Google Deployment Manager HashiCorp Terraform

Container Engine Cluster Creation

resource "google_container_cluster" "primary" { name = “europython-gke” zone = “europe-west1-c” initial_node_count = 3 node_config { machine-type = “n1-standard-4” } master_auth { username = “bilbao” password = “notverysecret” } }

slide-50
SLIDE 50

Demo - Visualization

slide-51
SLIDE 51

@tekgrrl #europython #kubernetesio

  • Q. How does Kubernetes handle secrets?

docs/secrets.md

  • Q. How will Kubernetes scale pods?

docs/proposals/autoscaling.md (Based on Traffic, predictive analysis or arbitrary data)

  • Q. How will Kubernetes scale nodes?

http://www.slideshare.net/craigbox/autoscaling-kubernetes (Likely based on resources, signals from scheduler and pending queue)

  • Q. How can we make Kubernetes highly available

docs/availability.md

Frequently Asked Questions

slide-52
SLIDE 52

@tekgrrl #europython #kubernetesio

Kubernetes is Open Source

We want your help!

http://kubernetes.io https://github.com/GoogleCloudPlatform/kubernetes irc.freenode.net #google-containers @kubernetesio

slide-53
SLIDE 53

@tekgrrl #europython #kubernetesio

Also tweet questions to: @tekgrrl Or find me at the Google Booth today

Questions