Slide 1

Slide 1 text

‹#› @tpryan Terry Ryan Developer Advocate Introduction to Containers and Kubernetes

Slide 2

Slide 2 text

‹#› @tpryan Who are you?

Slide 3

Slide 3 text

‹#› @tpryan 01 Introduction Why Containers?

Slide 4

Slide 4 text

‹#› @tpryan Matrix from Hell Dev 1 Laptop Dev 2 Laptop QA Stage Production OS ? ? ? ? ? Frontend ? ? ? ? ? Services ? ? ? ? ? Database ? ? ? ? ? Logs ? ? ? ? ?

Slide 5

Slide 5 text

‹#› @tpryan Matrix from Hell 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 6

Slide 6 text

‹#› @tpryan It worked fine in dev It worked fine in dev Ops Problem now Ops Problem now

Slide 7

Slide 7 text

‹#› @tpryan

Slide 8

Slide 8 text

‹#› @tpryan Hypervisor Virtual Machine OS OS OS

Slide 9

Slide 9 text

‹#› @tpryan Container Host Containers OS

Slide 10

Slide 10 text

‹#› @tpryan Dockerfile FROM gcr.io/php-mvm-a/php-nginx:latest ENV DOCUMENT_ROOT /app/web COPY default /app/web RUN chmod -R 755 /app/web/*

Slide 11

Slide 11 text

‹#› @tpryan Matrix from Hell Dev 1 Laptop Dev 2 Laptop QA Stage Production OS Frontend Services Database Logs

Slide 12

Slide 12 text

‹#› @tpryan 02 Introduction Why Kubernetes?

Slide 13

Slide 13 text

‹#› @tpryan What problem are 
 we trying to solve?

Slide 14

Slide 14 text

‹#› @tpryan # FRONTEND AND SERVICES FROM nginx-php-fpm COPY nginx.conf /etc/nginx/nginx.conf ADD www /var/www/

Slide 15

Slide 15 text

‹#› @tpryan # BACKEND FROM ubuntu:12.04 ADD ./mysql-setup.sh /tmp/mysql-setup.sh RUN /bin/sh /tmp/mysql-setup.sh EXPOSE 3306 CMD ["/usr/sbin/mysqld"]

Slide 16

Slide 16 text

‹#› @tpryan

Slide 17

Slide 17 text

‹#› @tpryan # FRONTEND AND SERVICES FROM nginx-php-fpm COPY nginx.conf /etc/nginx/nginx.conf ADD www /var/www/ # JUST SERVICES FROM nginx-php-fpm COPY nginx.conf /etc/nginx/nginx.conf ADD www /var/www/

Slide 18

Slide 18 text

‹#› @tpryan # FRONTEND AND SERVICES FROM nginx-php-fpm COPY nginx.conf /etc/nginx/nginx.conf ADD www /var/www/ # FRONTEND FROM nginx COPY nginx.conf /etc/nginx/nginx.conf ADD www /var/www/

Slide 19

Slide 19 text

‹#› @tpryan

Slide 20

Slide 20 text

‹#› @tpryan # BACKEND FROM ubuntu:12.04 ADD ./mysql-setup.sh /tmp/mysql-setup.sh RUN /bin/sh /tmp/mysql-setup.sh EXPOSE 3306 CMD ["/usr/sbin/mysqld"] # BACKEND FROM ubuntu:12.04 ADD ./mysql-setup.sh /tmp/mysql-setup.sh RUN /bin/sh /tmp/mysql-setup.sh EXPOSE 3306 VOLUME ["/etc/mysql", "/var/lib/mysql"] CMD ["/usr/sbin/mysqld"]

Slide 21

Slide 21 text

‹#› @tpryan

Slide 22

Slide 22 text

‹#› @tpryan

Slide 23

Slide 23 text

‹#› @tpryan

Slide 24

Slide 24 text

‹#› @tpryan

Slide 25

Slide 25 text

‹#› @tpryan

Slide 26

Slide 26 text

‹#› @tpryan That’s a lot to manage.

Slide 27

Slide 27 text

‹#› @tpryan 4 3 2

Slide 28

Slide 28 text

‹#› @tpryan Kubernetes • Container Orchestration System • Open Source • Started by Google • Contributed to by others

Slide 29

Slide 29 text

‹#› @tpryan 03 App in Kubernetes

Slide 30

Slide 30 text

‹#› @tpryan DB API UI LAMP

Slide 31

Slide 31 text

‹#› @tpryan Dockerfiles FROM mysql/mysql-server:5.6 ADD sql/load.sql /docker-entrypoint-initdb.d/load.sql EXPOSE 3306 DB FROM httpd:2.4 COPY ui /usr/local/apache2/htdocs/ui COPY static /usr/local/apache2/htdocs/static UI FROM php:7.0-apache RUN apt-get update && apt-get install -y php5-mysqlnd RUN docker-php-ext-install mysqli RUN a2enmod rewrite && a2enmod headers && service apache2 restart COPY app/ /var/www/html/ API

Slide 32

Slide 32 text

‹#› @tpryan Running containers Pod Pod Pod Pod Replica Set Deployment

Slide 33

Slide 33 text

‹#› @tpryan Deployment apiVersion: extensions/v1beta1 kind: Deployment metadata: name: frontend-deployment spec: replicas: 4 strategy: type: RollingUpdate template: metadata: labels: layer: ui spec: containers: - name: "frontend" image: "gcr.io/lamp-in-containers/locations-frontend" ports: - name: "http" containerPort: 80 protocol: TCP Pod Replica Set Deployment

Slide 34

Slide 34 text

‹#› @tpryan Create a Deployment # Create deployment kubectl create -f deployment.yaml

Slide 35

Slide 35 text

‹#› @tpryan Containers as Pets Pod Stateful Set Persistent Volume Claim

Slide 36

Slide 36 text

‹#› @tpryan Stateful Set apiVersion: apps/v1beta1 kind: StatefulSet metadata: name: db-set spec: serviceName: "mysql" replicas: 1 template: metadata: labels: layer: db spec: terminationGracePeriodSeconds: 0 containers: - name: db image: "gcr.io/lamp-in-containers/locations-db" ports: - containerPort: 3306 name: mysql volumeMounts: - name: mysql-pvc mountPath: /var/lib/mysql volumeClaimTemplates: - metadata: name: mysql-pvc annotations: volume.alpha.kubernetes.io/storage-class: anything spec: accessModes: [ "ReadWriteOnce" ] resources: requests: storage: 1Gi Pod Persistent Volume Claim Stateful Set

Slide 37

Slide 37 text

‹#› @tpryan Exposing containers Pod Pod Pod Pod Service

Slide 38

Slide 38 text

‹#› @tpryan Deployment apiVersion: extensions/v1beta1 kind: Deployment metadata: name: frontend-deployment spec: replicas: 4 strategy: type: RollingUpdate template: metadata: labels: layer: ui spec: containers: - name: "frontend" image: "gcr.io/lamp-in-containers/locations-frontend" ports: - name: "http" containerPort: 80 protocol: TCP Pod Label

Slide 39

Slide 39 text

‹#› @tpryan Service apiVersion: v1 kind: Service metadata: labels: name: frontend name: frontend spec: type: LoadBalancer ports: - port: 80 targetPort: 80 protocol: TCP selector: layer: ui Selector

Slide 40

Slide 40 text

‹#› @tpryan ui Pod ui deployment ui Pod ui Pod ui Pod ui service (public) api Pod api deployment api service (public) api Pod api Pod db statefulset db service (private) db Pod

Slide 41

Slide 41 text

‹#› @tpryan Demo: Kubernetes in Action

Slide 42

Slide 42 text

‹#› @tpryan 05 Conclusions Bring it home

Slide 43

Slide 43 text

‹#› @tpryan Kubernetes is Open Source We want your help! • http://kubernetes.io • https://github.com/kubernetes/kubernetes • irc.freenode.net #google-containers • @kubernetesio

Slide 44

Slide 44 text

‹#› @tpryan

Slide 45

Slide 45 text

‹#› @tpryan Roadmap Kubernetes 1.6 Released: March 2017 • Scale enhancement - 5000 nodes, 150,000 pods • Advanced Scheduling • Storage Enhancements for 
 AWS, Azure, GCP, OpenStack and VMware vSphere • Interesting alpha: • Nvidia GPU support http://blog.kubernetes.io/2017/03/kubernetes-1.6-multi-user-multi-workloads-at-scale.html

Slide 46

Slide 46 text

‹#› @tpryan Roadmap Kubernetes 1.7 Target: June 2017 https://github.com/kubernetes/kubernetes/milestones/

Slide 47

Slide 47 text

Google has been developing and using containers to manage our applications for over 10 years.

Slide 48

Slide 48 text

‹#› @tpryan Everything at Google runs on Containers: • Gmail, Web Search, Maps, ... • MapReduce, batch, ... • GFS, Colossus, ... • Even Google’s Cloud Platform: VMs run in containers! We launch 2 Billion Containers a week

Slide 49

Slide 49 text

‹#› @tpryan We think containers are the way to manage scale.

Slide 50

Slide 50 text

‹#› @tpryan You should carefully consider whether running everything on containers is right for you.

Slide 51

Slide 51 text

‹#› @tpryan You should run everything on containers.

Slide 52

Slide 52 text

‹#› @tpryan You should carefully consider whether running everything on containers is right for you.

Slide 53

Slide 53 text

‹#› @tpryan

Slide 54

Slide 54 text

‹#› @tpryan Thank You terrenceryan.com @tpryan This preso: http://bit.ly/tpryan-intro-k8s