Slide 1

Slide 1 text

Google Container Engine (Kubernetes 101) Google NEXT Extended 2017 Singapore @vincentdesmet

Slide 2

Slide 2 text

@vincentdesmet DevOps - honestbee.sg

Slide 3

Slide 3 text

Applications evolve Reference: http://docker.com Loosely Coupled Services Many Small Servers ~2000 Today Monolithic Big Servers Slow changing Rapidly updated

Slide 4

Slide 4 text

Containers / VMs Infrastructure Container Runtime Interface Bins / Libs Host OS Infrastructure Hypervisor AppA Bins / Libs AppA Guest OS Bins/Libs AppB Guest OS Bins/Libs AppB

Slide 5

Slide 5 text

Docker containers Reference: http://docker.com • Packages up software binaries and dependencies • Isolates software from each other • Container is a standard format • Easily portable across environment • Allows ecosystem to develop around its standard Container

Slide 6

Slide 6 text

Docker Concepts Docker Image The basis of a Docker container Docker Container The standard unit in which the application service resides Docker Engine Creates, ships and runs Docker containers deployable on physical or virtual host locally, in a datacenter or cloud service provider Docker Registry On-premises registry for image storing and collaboration

Slide 7

Slide 7 text

Docker Tools: BUILD, SHIP, RUN

Slide 8

Slide 8 text

KUBERNETES "κυβερνήτης" (kubernetes) is Greek for "pilot" or "helmsman of ship"

Slide 9

Slide 9 text

WHAT IS KUBERNETES? •Container orchestrator •Runs and manages containers •Supports multiple cloud & bare-metal environments •100% Open Source written in Go •Built on decades of experience of running containers at Google •First project hosted by CNCF (Accepted on Mar. 11 2016) Container packaged Dynamically scheduled (Micro) Service oriented

Slide 10

Slide 10 text

PODS & VOLUMES Container Foo Container Bar Namespaces: - Net - IPC - … volumes

Slide 11

Slide 11 text

PODS & VOLUMES volumes

Slide 12

Slide 12 text

LABELS app : my-app role : master track: stable

Slide 13

Slide 13 text

LABELS app : my-app role : master track: stable app : my-app role : worker track: stable app : my-app role : worker track: canary app : my-app role : master track: canary

Slide 14

Slide 14 text

SELECTORS app : my-app app : my-app role : master track: stable app : my-app role : worker track: stable app : my-app role : worker track: canary app : my-app role : master track: canary

Slide 15

Slide 15 text

SELECTORS app : my-app role : worker app : my-app role : master track: stable app : my-app role : worker track: stable app : my-app role : worker track: canary app : my-app role : master track: canary

Slide 16

Slide 16 text

SELECTORS app : my-app track: canary app : my-app role : master track: stable app : my-app role : worker track: stable app : my-app role : worker track: canary app : my-app role : master track: canary

Slide 17

Slide 17 text

CONTROL LOOPS Desired state Actual state pods: - foo - bar pods: - foo

Slide 18

Slide 18 text

CONTROL LOOPS Desired state Actual state pods: - foo - bar pods: - foo create “bar” Create

Slide 19

Slide 19 text

CONTROL LOOPS Desired state Actual state pods: - foo - bar pods: - foo - bar

Slide 20

Slide 20 text

REPLICA SETS + Replica Set: - replicas: 1 - selector: - app: my-app - version: 1.0 - Desired State: - Pod Specification - Replica Count - Label Selector

Slide 21

Slide 21 text

REPLICA SETS + Replica Set: - replicas: 2 - selector: - app: my-app - version: 1.0

Slide 22

Slide 22 text

REPLICA SETS + Replica Set: - replicas: 4 - selector: - app: my-app - version: 1.0

Slide 23

Slide 23 text

SERVICES Service: - nodePort: 30128 - selector: - app: my-app - version: 1.0 - de-couple discovery from application - Define how to access pods - Act as a proxy (Virtual IP - stable for DNS) Think of: - Dynamic Routing Table

Slide 24

Slide 24 text

CANARIES + Replica Set: - replicas: 2 - selector: - app: my-app - version: 1.0 Service: - nodePort: 30128 - selector: - app: my-app + Replica Set: - replicas: 1 - selector: - app: my-app - version: canary Think of: - Partially live the new version

Slide 25

Slide 25 text

DEPLOYMENTS Service: - nodePort: 30128 - selector: - app: my-app + Replica Set: - replicas: 2 - selector: - app: my-app - version: 1.0 + - Manage updates with Deployment resources

Slide 26

Slide 26 text

UPDATES Service: - nodePort: 30128 - selector: - app: my-app + Replica Set: - replicas: 4 - selector: - app: my-app - version: 1.0 + Deployment: - strategy: - rollingUpdate

Slide 27

Slide 27 text

UPDATES Service: - nodePort: 30128 - selector: - app: my-app + + Replica Set: - replicas: 1 - selector: - app: my-app - version: 2.0 Replica Set: - replicas: 4 - selector: - app: my-app - version: 1.0 + Deployment: - strategy: - rollingUpdate

Slide 28

Slide 28 text

UPDATES Service: - nodePort: 30128 - selector: - app: my-app + + Replica Set: - replicas: 1 - selector: - app: my-app - version: 2.0 Replica Set: - replicas: 3 - selector: - app: my-app - version: 1.0 + Deployment: - strategy: - rollingUpdate

Slide 29

Slide 29 text

UPDATES Service: - nodePort: 30128 - selector: - app: my-app + + Replica Set: - replicas: 2 - selector: - app: my-app - version: 2.0 Replica Set: - replicas: 3 - selector: - app: my-app - version: 1.0 + Deployment: - strategy: - rollingUpdate

Slide 30

Slide 30 text

UPDATES Service: - nodePort: 30128 - selector: - app: my-app + + Replica Set: - replicas: 2 - selector: - app: my-app - version: 2.0 Replica Set: - replicas: 2 - selector: - app: my-app - version: 1.0 + Deployment: - strategy: - rollingUpdate

Slide 31

Slide 31 text

UPDATES Service: - nodePort: 30128 - selector: - app: my-app + + Replica Set: - replicas: 3 - selector: - app: my-app - version: 2.0 Replica Set: - replicas: 2 - selector: - app: my-app - version: 1.0 + Deployment: - strategy: - rollingUpdate

Slide 32

Slide 32 text

UPDATES Service: - nodePort: 30128 - selector: - app: my-app + + Replica Set: - replicas: 3 - selector: - app: my-app - version: 2.0 Replica Set: - replicas: 1 - selector: - app: my-app - version: 1.0 + Deployment: - strategy: - rollingUpdate

Slide 33

Slide 33 text

UPDATES Service: - nodePort: 30128 - selector: - app: my-app + Replica Set: - replicas: 4 - selector: - app: my-app - version: 2.0 Replica Set: - replicas: 1 - selector: - app: my-app - version: 1.0 + + Deployment: - strategy: - rollingUpdate

Slide 34

Slide 34 text

UPDATES Service: - nodePort: 30128 - selector: - app: my-app + Replica Set: - replicas: 4 - selector: - app: my-app - Version: 2.0 Replica Set: - replicas: 0 - selector: - app: my-app - version: 1.0 + + Deployment: - strategy: - rollingUpdate

Slide 35

Slide 35 text

UPDATES Service: - nodePort: 30128 - selector: - app: my-app + Replica Set: - replicas: 4 - selector: - app: my-app - Version: 2.0 + Deployment: - strategy: - rollingUpdate

Slide 36

Slide 36 text

CONFIGMAPS Service: - nodePort: 30128 - selector: - app: my-app + + Deployment: - strategy: - rollingUpdate ConfigMap: - sample.yaml: | env: production cache: true max_threads: 8

Slide 37

Slide 37 text

SECRETS Service: - nodePort: 30128 - selector: - app: my-app + + Deployment: - strategy: - rollingUpdate Secret: - sample.yaml: | key: *** db_user: *** db_pw: ***

Slide 38

Slide 38 text

Demo Minikube

Slide 39

Slide 39 text

Getting Started - Free trial cluster - cloud.google.com/container-engine (single node) locally - github.com/kubernetes/minikube - Join www.meetup.com/GCPUGSG/

Slide 40

Slide 40 text

Honestbee We are Hiring DevOps!

Slide 41

Slide 41 text

Thank you!

Slide 42

Slide 42 text

Recap - Multiple resource types - Deployments - Services - ConfigMaps - Secrets - … - Serializable Manifests: Infrastructure as code

Slide 43

Slide 43 text

Overview Concepts: - Containers - Pods - Volumes - Labels & Label Queries - Control Loops & Controllers - Deployment - ReplicaSet - Service

Slide 44

Slide 44 text

Shipping, Deploying & Service Discovery

Slide 45

Slide 45 text

Helm: Package Manager - Collaboration with Google, Bitnami, Deis and others - Deis/Helm -> Kubernetes/Helm - Architecture: - Client: Helm - Server: Tiller - This talk: - Focused on writing charts

Slide 46

Slide 46 text

Helm core values - Aim for the Apt/Yum/Homebrew UX - Ensure collaboration - Reproducible releases - Shareable Packages

Slide 47

Slide 47 text

Chart, Repositories, Releases - Chart: “Package”, “Bundle” - Repository: Package Repository Evolving towards a registry (CoreOS) - Release: Installed Chart (same chart can be installed multiple times)

Slide 48

Slide 48 text

Basic Architecture Client - Server

Slide 49

Slide 49 text

Usage

Slide 50

Slide 50 text

Review using helm - Install charts (creates a release) - helm install - List releases - helm ls - - Bootstrap charts - helm create

Slide 51

Slide 51 text

More features - Upgrade Releases - helm upgrade - Search Charts - helm search - KubeApps.com (Monocular - https://github.com/helm/monocular) - Manage Chart dependencies - requirements.yaml - helm dep up - Helm Plugins - Keybase: helm keybase sign/verify - GitHub: helm github push

Slide 52

Slide 52 text

More info Kubecon talk