introduction to kubernetes ( cluster containers...

36
Introduction to Kubernetes ( Cluster Containers Orchestration ) This Document: http://arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf Lesson iut.univ-paris8.fr 2018-05 [email protected]

Upload: others

Post on 21-Oct-2019

73 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Introduction to Kubernetes ( Cluster Containers ...arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf · Kubernetes = Docker + ... Docker Already have (Toy) Docker Swarm (Docker

Introduction to Kubernetes( Cluster Containers Orchestration )

This Document: http://arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf

Lesson iut.univ-paris8.fr 2018-05

[email protected]

Page 2: Introduction to Kubernetes ( Cluster Containers ...arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf · Kubernetes = Docker + ... Docker Already have (Toy) Docker Swarm (Docker

Comparison, Alternatives

Docker Compose & Docker Swarm

Page 3: Introduction to Kubernetes ( Cluster Containers ...arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf · Kubernetes = Docker + ... Docker Already have (Toy) Docker Swarm (Docker

Google Stack Foundation: Borg → Omega (~ Kubernetes)

Page 4: Introduction to Kubernetes ( Cluster Containers ...arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf · Kubernetes = Docker + ... Docker Already have (Toy) Docker Swarm (Docker

Vision : DataCenter as a Computer

Page 5: Introduction to Kubernetes ( Cluster Containers ...arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf · Kubernetes = Docker + ... Docker Already have (Toy) Docker Swarm (Docker

Programming Model Analogy

1 Process → N Threads

Schedule on CPU Cores(on GPU Processing Units)

Inter-Threads communications

Low Level Thread APIHigh Level Concurrent Library

1 Service → N Containers

Schedule on Nodes

Inter Containers Networks

Low Level Docker APIHigh Level Cloud-Native Library

Page 6: Introduction to Kubernetes ( Cluster Containers ...arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf · Kubernetes = Docker + ... Docker Already have (Toy) Docker Swarm (Docker

https://en.wikipedia.org/wiki/Fallacies_of_distributed_computing

Page 7: Introduction to Kubernetes ( Cluster Containers ...arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf · Kubernetes = Docker + ... Docker Already have (Toy) Docker Swarm (Docker

Expect Chaos ..

Disk → Crashes

Electricity → Shutdown

CPU → Burn

Network → unplug / noise

Page 8: Introduction to Kubernetes ( Cluster Containers ...arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf · Kubernetes = Docker + ... Docker Already have (Toy) Docker Swarm (Docker

Design for Resiliency .. Test

Page 9: Introduction to Kubernetes ( Cluster Containers ...arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf · Kubernetes = Docker + ... Docker Already have (Toy) Docker Swarm (Docker

https://kubernetes.io/

Page 10: Introduction to Kubernetes ( Cluster Containers ...arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf · Kubernetes = Docker + ... Docker Already have (Toy) Docker Swarm (Docker

Kubernetes Name & Logo ...

https://kubernetes.io/docs/concepts/overview/what-is-kubernetes/

Page 11: Introduction to Kubernetes ( Cluster Containers ...arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf · Kubernetes = Docker + ... Docker Already have (Toy) Docker Swarm (Docker

Features

Page 12: Introduction to Kubernetes ( Cluster Containers ...arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf · Kubernetes = Docker + ... Docker Already have (Toy) Docker Swarm (Docker

https://kubernetes.io/docs/home/

Page 13: Introduction to Kubernetes ( Cluster Containers ...arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf · Kubernetes = Docker + ... Docker Already have (Toy) Docker Swarm (Docker

Master - Nodes

Page 14: Introduction to Kubernetes ( Cluster Containers ...arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf · Kubernetes = Docker + ... Docker Already have (Toy) Docker Swarm (Docker

Master – Node – Pod - Container

Page 15: Introduction to Kubernetes ( Cluster Containers ...arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf · Kubernetes = Docker + ... Docker Already have (Toy) Docker Swarm (Docker

Master Detail : kubectl,API,..Node Detail :Kubelet, Kube-Proxy,..

Page 16: Introduction to Kubernetes ( Cluster Containers ...arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf · Kubernetes = Docker + ... Docker Already have (Toy) Docker Swarm (Docker

Kubernetes = Docker + ...

Docker Already have (Toy) Docker Swarm(Docker Swarm = same API as Docker… for Cluster)

So, what’s more in Kubernetes compared to Docker ?

… different API ! New Higher-Level Concepts

Page 17: Introduction to Kubernetes ( Cluster Containers ...arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf · Kubernetes = Docker + ... Docker Already have (Toy) Docker Swarm (Docker

Docker → KubernetesImperatif → Declaratif

$ docker run image …$ docker start/stop/rm/ ….

$ kubelet rs create ...$ kubelet rs delete ...

One-shot action executionCommand = verb to execute

Manage persistent resourceCommand = REST

Behind → Controller loop to reconcile(start/stop/..)

Page 18: Introduction to Kubernetes ( Cluster Containers ...arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf · Kubernetes = Docker + ... Docker Already have (Toy) Docker Swarm (Docker

REST – Persistent Resources

Page 19: Introduction to Kubernetes ( Cluster Containers ...arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf · Kubernetes = Docker + ... Docker Already have (Toy) Docker Swarm (Docker

Controller = Reconcilediff : Expected - Observed

Expected State

Real Observed State

Diff StateSchedule Actions

Page 20: Introduction to Kubernetes ( Cluster Containers ...arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf · Kubernetes = Docker + ... Docker Already have (Toy) Docker Swarm (Docker

Example: Scale UP => schedule run

Expected State

Real Observed State

Diff StateSchedule Actions

X 8 containers

X 10 containers

X 8 containers alive-2 containers Run +2 containers

Run +1 container on nodeARun +1 container on nodeB

Page 21: Introduction to Kubernetes ( Cluster Containers ...arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf · Kubernetes = Docker + ... Docker Already have (Toy) Docker Swarm (Docker

Example: Scale DOWN => schedule rm

Expected State

Real Observed State

Diff StateSchedule Actions

X 10 containers

X 8 containers

X 10 containers alive+2 containers Kill -2 containers

Kill -1 container on nodeAKill -1 container on nodeB

Page 22: Introduction to Kubernetes ( Cluster Containers ...arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf · Kubernetes = Docker + ... Docker Already have (Toy) Docker Swarm (Docker

Objects

Page 23: Introduction to Kubernetes ( Cluster Containers ...arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf · Kubernetes = Docker + ... Docker Already have (Toy) Docker Swarm (Docker

Kubernetes Core Concepts

Page 24: Introduction to Kubernetes ( Cluster Containers ...arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf · Kubernetes = Docker + ... Docker Already have (Toy) Docker Swarm (Docker

Node API

https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.10/#node-v1-core

Page 25: Introduction to Kubernetes ( Cluster Containers ...arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf · Kubernetes = Docker + ... Docker Already have (Toy) Docker Swarm (Docker

Kubernetes API … Rest Json/Yaml

Page 26: Introduction to Kubernetes ( Cluster Containers ...arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf · Kubernetes = Docker + ... Docker Already have (Toy) Docker Swarm (Docker

Http Rest Yaml → Json ...

$ curl -X POST ..or$ kubelet ..

Page 27: Introduction to Kubernetes ( Cluster Containers ...arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf · Kubernetes = Docker + ... Docker Already have (Toy) Docker Swarm (Docker

Kubectl Client

Page 28: Introduction to Kubernetes ( Cluster Containers ...arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf · Kubernetes = Docker + ... Docker Already have (Toy) Docker Swarm (Docker

Kubetcl commands

Page 29: Introduction to Kubernetes ( Cluster Containers ...arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf · Kubernetes = Docker + ... Docker Already have (Toy) Docker Swarm (Docker

Kubectl commands details

https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands

Page 30: Introduction to Kubernetes ( Cluster Containers ...arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf · Kubernetes = Docker + ... Docker Already have (Toy) Docker Swarm (Docker

Kubernetes Controllers: ReplicationSet, ..

scale=N times … image“schedule” on nodes

1 container per node (example: cAdvisor monitoring)

Launch Job (short tasks, batches)

Page 31: Introduction to Kubernetes ( Cluster Containers ...arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf · Kubernetes = Docker + ... Docker Already have (Toy) Docker Swarm (Docker

Networks...

Page 32: Introduction to Kubernetes ( Cluster Containers ...arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf · Kubernetes = Docker + ... Docker Already have (Toy) Docker Swarm (Docker

Port Forwarding

Page 33: Introduction to Kubernetes ( Cluster Containers ...arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf · Kubernetes = Docker + ... Docker Already have (Toy) Docker Swarm (Docker

Level 7 Reverse Proxy, Ingress

Page 34: Introduction to Kubernetes ( Cluster Containers ...arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf · Kubernetes = Docker + ... Docker Already have (Toy) Docker Swarm (Docker

Overlay Network

Page 35: Introduction to Kubernetes ( Cluster Containers ...arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf · Kubernetes = Docker + ... Docker Already have (Toy) Docker Swarm (Docker

Volumes

Page 36: Introduction to Kubernetes ( Cluster Containers ...arnaud-nauwynck.github.io/docs/Intro-Kubernetes.pdf · Kubernetes = Docker + ... Docker Already have (Toy) Docker Swarm (Docker

Summary

Part 1: VM & Containers

Part 2 : Docker

Part 3: Kubernetes

(Cluster Orchestration)