Slide 1

Slide 1 text

Kubernetes 101 #k8sbday #gdgcv @Vikram_Tiwari @gdgvancouver

Slide 2

Slide 2 text

2 2 What’s in this for you...

Slide 3

Slide 3 text

3 3 SlackGuest Slack4U2!

Slide 4

Slide 4 text

4 The App (Monolith) nginx monolith

Slide 5

Slide 5 text

5 The App (Microservices) nginx hello auth

Slide 6

Slide 6 text

6 6 Packaging and Distributing Apps

Slide 7

Slide 7 text

7 Dependency Matrix Dev 1 Laptop Dev 2 Laptop QA Stage Production OS ? ? ? ? ? Frontend ? ? ? ? ? Services ? ? ? ? ? Database ? ? ? ? ? Logs ? ? ? ? ?

Slide 8

Slide 8 text

8 Dependency Matrix Dev 1 Laptop Dev 2 Laptop QA Stage Production OS OS X Windows Debian Debian Debian Frontend nginx (homebrew) nginx (download) nginx (apt-get) nginx (apt-get) nginx (apt-get) Services php (homebrew) php (download) php (apt-get) php (apt-get) php (apt-get) Database mysql (download) mysql (download) mysql (apt-get) mysql (apt-get) mysql (apt-get) Logs /usr/local/etc/nginx/logs/ C:\nginx-1.9.5\logs /var/log/nginx/ /var/log/nginx/ /var/log/nginx/

Slide 9

Slide 9 text

9 Virtual Machines Hypervisor OS OS OS

Slide 10

Slide 10 text

‹#› @kubernetesio

Slide 11

Slide 11 text

11 Container Host OS Containers

Slide 12

Slide 12 text

12 Docker Containers FROM alpine:3.1 MAINTAINER Vikram Tiwari ADD monolith /usr/bin/monolith ENTRYPOINT ["monolith"]

Slide 13

Slide 13 text

13 Dependency Matrix Dev 1 Laptop Dev 2 Laptop QA Stage Production OS Frontend Services Database Logs

Slide 14

Slide 14 text

14 14 But that's just one machine! Discovery Scaling Security Monitoring Configuration Scheduling Health

Slide 15

Slide 15 text

15 Kubernetes Manage applications, not machines Open source, open API container orchestrator Supports multiple cloud and bare-metal environments Inspired and informed by Google’s experiences and internal systems

Slide 16

Slide 16 text

16 16 Kubernetes Concepts Cattle > Pets No grouping Modular Control Loops Network-centric Open > Closed Simple > Complex Legacy compatible

Slide 17

Slide 17 text

17 17 Cattle vs Pets

Slide 18

Slide 18 text

18 Cattle vs Pets Cattle • Has a number • One is much like any other • Run as a group • If it gets ill, you make hamburgers Pet • Has a name • Is unique or rare • Personal Attention • If it gets ill, you make it better

Slide 19

Slide 19 text

19 19 Desired State

Slide 20

Slide 20 text

20 Desired States ./create_docker_images.sh ./launch_frontend.sh x 3 ./launch_services.sh x 2 ./launch_backend.sh x 1

Slide 21

Slide 21 text

21 Desired States ./create_docker_images.sh ./launch_frontend.sh x 3 ./launch_services.sh x 2 ./launch_backend.sh x 1

Slide 22

Slide 22 text

22 Desired States There should be: 3 Frontends 2 Services 1 Backend

Slide 23

Slide 23 text

23 23 Employees, not Children

Slide 24

Slide 24 text

24 Children vs Employees Child • Go upstairs • Get undressed • Put on pajamas • Brush your teeth • Pick out 2 stories Employee • Go get some sleep

Slide 25

Slide 25 text

25 25 Pods

Slide 26

Slide 26 text

26 Pods Logical Application • One or more containers and volumes • Shared namespaces • One IP per pod Pod nginx monolith NFS iSCSI GCE 10.10.1.100

Slide 27

Slide 27 text

27 27 Health checks

Slide 28

Slide 28 text

28 Monitoring and Health Checks Node Kubelet Pod Pod app v1

Slide 29

Slide 29 text

29 Monitoring and Health Checks Hey, app v1... You alive? Node Kubelet Pod app v1 app v1

Slide 30

Slide 30 text

30 Monitoring and Health Checks Node Kubelet Nope! Pod app v1 app v1

Slide 31

Slide 31 text

31 Monitoring and Health Checks OK, then I’m going to restart you... Node Kubelet Pod app v1 app v1

Slide 32

Slide 32 text

32 Monitoring and Health Checks Node Kubelet Pod

Slide 33

Slide 33 text

33 Monitoring and Health Checks Node Kubelet Pod app v1

Slide 34

Slide 34 text

34 Monitoring and Health Checks Node Kubelet Hey, app v1... You alive? Pod app v1

Slide 35

Slide 35 text

35 Monitoring and Health Checks Node Kubelet Yes! Pod app v1

Slide 36

Slide 36 text

36 36 Secrets

Slide 37

Slide 37 text

37 Secrets and Configmaps Kubernetes Master etcd API Server Node Kubelet secret $ kubectl create secret generic tls-certs --from-file=tls/

Slide 38

Slide 38 text

38 Secrets and Configmaps Kubernetes Master etcd API Server Node Kubelet pod $ kubectl create -f pods/secure-monolith.yaml

Slide 39

Slide 39 text

39 Secrets and Configmaps Kubernetes Master etcd API Server Node Kubelet API Server Node Kubelet Pod Pod

Slide 40

Slide 40 text

40 Secrets and Configmaps Kubernetes Master etcd API Server Node Kubelet API Server Node Kubelet Pod Pod secret

Slide 41

Slide 41 text

41 Secrets and Configmaps Kubernetes Master etcd API Server Node Kubelet API Server Node Kubelet Pod Pod /etc/tls secret

Slide 42

Slide 42 text

42 Secrets and Configmaps Kubernetes Master etcd API Server Node Kubelet Node Kubelet Pod Pod /etc/tls /etc/tls 10.10.1.100 secret API Server

Slide 43

Slide 43 text

43 Secrets and Configmaps Kubernetes Master etcd API Server Node Kubelet API Server Node Kubelet Pod Pod /etc/tls nginx 10.10.1.100 secret

Slide 44

Slide 44 text

44 44 Services

Slide 45

Slide 45 text

45 Services Pod hello Service Pod hello Pod hello

Slide 46

Slide 46 text

46 Services Persistent Endpoint for Pods Pod hello Service Pod hello Pod hello

Slide 47

Slide 47 text

47 Persistent Endpoint for Pods • Use Labels to Select Pods Services Pod hello Service Pod hello Pod hello

Slide 48

Slide 48 text

48 Labels Arbitrary meta-data attached to Kubernetes object Pod hello Pod hello labels: version: v1 track: stable labels: version: v1 track: test

Slide 49

Slide 49 text

49 Labels selector: “version=v1” Pod hello Pod hello labels: version: v1 track: stable labels: version: v1 track: test

Slide 50

Slide 50 text

50 Labels selector: “track=stable” Pod hello Pod hello labels: version: v1 track: stable labels: version: v1 track: test

Slide 51

Slide 51 text

51 Services Persistent Endpoint for Pods • Use Labels to Select Pods • Internal or External IPs Pod hello Service Pod hello Pod hello

Slide 52

Slide 52 text

52 52 Deployments

Slide 53

Slide 53 text

53 Drive current state towards desired state Deployments Node1 Node2 Node3 Pod hello app: hello replicas: 1

Slide 54

Slide 54 text

54 Drive current state towards desired state Deployments Node1 Node2 Node3 Pod hello app: hello replicas: 3

Slide 55

Slide 55 text

55 Drive current state towards desired state Deployments Node1 Node2 Node3 Pod hello app: hello replicas: 3 Pod hello Pod hello

Slide 56

Slide 56 text

56 Drive current state towards desired state Deployments Node1 Node2 Node3 Pod hello app: hello replicas: 3 Pod hello

Slide 57

Slide 57 text

57 Drive current state towards desired state Deployments Node1 Node2 Node3 Pod hello app: hello replicas: 3 Pod hello Pod hello

Slide 58

Slide 58 text

58 58 Rolling Updates

Slide 59

Slide 59 text

59 Rolling Update Node1 Node3 Node2 ghost Pod app v1 Service ghost Pod app v1 Pod app v1

Slide 60

Slide 60 text

60 Rolling Update Node1 Node3 Node2 ghost Pod app v1 Service ghost Pod app v1 Pod app v1 Pod app v2

Slide 61

Slide 61 text

61 Rolling Update Node1 Node3 Node2 ghost Pod app v1 Service ghost Pod app v1 Pod app v1 Pod app v2

Slide 62

Slide 62 text

62 Rolling Update Node1 Node3 Node2 ghost Pod app v1 Service ghost Pod app v1 Pod app v1 Pod app v2

Slide 63

Slide 63 text

63 Rolling Update Node1 Node3 Node2 Service ghost Pod app v1 Pod app v1 Pod app v2

Slide 64

Slide 64 text

64 Rolling Update Node1 Node3 Node2 Service ghost Pod app v1 Pod app v1 Pod app v2 Pod app v2

Slide 65

Slide 65 text

65 Rolling Update Node1 Node3 Node2 Service ghost Pod app v1 Pod app v1 Pod app v2 Pod app v2

Slide 66

Slide 66 text

66 Rolling Update Node1 Node3 Node2 Service ghost Pod app v1 Pod app v1 Pod app v2 Pod app v2

Slide 67

Slide 67 text

67 Rolling Update Node1 Node3 Node2 Service Pod app v1 Pod app v2 Pod app v2

Slide 68

Slide 68 text

68 Rolling Update Node1 Node3 Node2 Service Pod app v1 Pod app v2 Pod app v2 Pod app v2

Slide 69

Slide 69 text

69 Rolling Update Node1 Node3 Node2 Service Pod app v1 Pod app v2 Pod app v2 Pod app v2

Slide 70

Slide 70 text

70 Rolling Update Node1 Node3 Node2 Service Pod app v1 Pod app v2 Pod app v2 Pod app v2

Slide 71

Slide 71 text

71 Rolling Update Node1 Node3 Node2 Service Pod app v2 Pod app v2 Pod app v2

Slide 72

Slide 72 text

72 72 Recap

Slide 73

Slide 73 text

73 Kubernetes Manage applications, not machines Open source, Open API container orchestrator Supports multiple cloud and bare-metal environments Inspired and informed by Google’s experiences and internal systems

Slide 74

Slide 74 text

74 Container • Subatomic unit in Kubernetes • Can use Dockerfile just like you’re used to

Slide 75

Slide 75 text

75 Pods Logical Application • One or more containers and volumes • Shared namespaces • One IP per pod Pod nginx monolith NFS iSCSI GCE 10.10.1.100

Slide 76

Slide 76 text

76 Monitoring and Health Checks Hey, app v1... You alive? Node Kubelet Pod app v1 app v1

Slide 77

Slide 77 text

77 Secrets and Configmaps Kubernetes Master etcd API Server Node Kubelet secret $ kubectl create secret generic tls-certs --from-file=tls/

Slide 78

Slide 78 text

78 Services Persistent Endpoint for Pods • Use Labels to Select Pods • Internal or External IPs Pod hello Service Pod hello Pod hello

Slide 79

Slide 79 text

79 Labels Arbitrary meta-data attached to Kubernetes object Pod hello Pod hello labels: version: v1 track: stable labels: version: v1 track: test

Slide 80

Slide 80 text

80 Drive current state towards desired state Deployments Node1 Node2 Node3 Pod hello app: hello replicas: 3 Pod hello Pod hello

Slide 81

Slide 81 text

81 Rolling Update Node1 Node3 Node2 ghost Pod app v1 Service ghost Pod app v1 Pod app v1 Pod app v2

Slide 82

Slide 82 text

82 But wait there’s more. • Persistent disks • Logging & Monitoring • Node & Pod Autoscaling • Web UI • Jobs & Daemon Sets • Cluster Federation • Ingress

Slide 83

Slide 83 text

83 Scalable Microservices with Kubernetes https://www.udacity.com/course/scalable-microservices-with-kubernetes--ud615

Slide 84

Slide 84 text

Thank you! (Additional resources in the slide notes below) Transition to CodeLab