Slide 1

Slide 1 text

VSHN – The DevOps Company  Welcome and thanks for attending! This webinar will start in a few minutes.  Feel free to ask questions in the "Q&A" box. We will answer them at the end of the webinar. Docker and Kubernetes: The Way to Cloud-Native Computing 1

Slide 2

Slide 2 text

VSHN – The DevOps Company Webinar – May 26th, 2020 Julian Deb – Partner New Business Sales Floriana Adam – Partner Specialised Sales Docker and Kubernetes: The Way to Cloud-Native Computing 2

Slide 3

Slide 3 text

VSHN – The DevOps Company Webinar – May 26th, 2020 Adrian Kosmaczewski – Developer Relations Docker and Kubernetes: The Way to Cloud-Native Computing 3

Slide 4

Slide 4 text

VSHN – The DevOps Company Pronounced ˈvɪʒn – like "vision" Founded 2014, 45 VSHNeers located in Zürich Switzerland’s leading DevOps, Docker & Kubernetes partner, with 24/7 support & ISO 27001 Certi ed First Swiss Kubernetes Certi ed Service Provider 4

Slide 5

Slide 5 text

VSHN – The DevOps Company 5

Slide 6

Slide 6 text

VSHN – The DevOps Company 1. Introduction to Cloud Native, Docker, Kubernetes, and DevOps 2. Containerization of an existing application and deployment on a Kubernetes cluster 3. Overview of various Kubernetes distributions 4. Questions and discussion Agenda 6

Slide 7

Slide 7 text

VSHN – The DevOps Company Deploying Applications in 1997 7

Slide 8

Slide 8 text

VSHN – The DevOps Company 8

Slide 9

Slide 9 text

VSHN – The DevOps Company Cloud-Native Applications 9

Slide 10

Slide 10 text

VSHN – The DevOps Company Architecture to build applications built with cloud computing in mind Cloud-native ≠ cloud only ⇒ public cloud and on- premises Focus on interconnected (micro-)services Enabled by open-source implementations and open standards What is a Cloud-Native App? 10

Slide 11

Slide 11 text

VSHN – The DevOps Company 11

Slide 12

Slide 12 text

VSHN – The DevOps Company Declarative formats ⇒ automation Portable across environments Suitable for deployment on modern cloud environments Minimize divergence between "dev" & "prod" ⇒ continuous deployment Built with scaling in mind Twelve-Factor Patterns 12

Slide 13

Slide 13 text

VSHN – The DevOps Company Collaboration between development and operations Maximum automation through "infrastructure as code" Cost e cient ⇒ Lean Agile ⇒ react to changing requirements faster Continuous improvement built-in DevOps Principles 13

Slide 14

Slide 14 text

VSHN – The DevOps Company 14

Slide 15

Slide 15 text

VSHN – The DevOps Company Book Recommendation 15

Slide 16

Slide 16 text

VSHN – The DevOps Company Componentize apps in microservices ⇒ Horizontal scalability & team scaling Automate the release pipeline ⇒ Faster time-to market Use infrastructure as code ⇒ Repeatability & testability Increase application observability ⇒ Resilience Automate app lifecycle ⇒ Increased security & availability Best Practices for Cloud-Native 16

Slide 17

Slide 17 text

VSHN – The DevOps Company Docker and Application Containers 17

Slide 18

Slide 18 text

VSHN – The DevOps Company 18

Slide 19

Slide 19 text

VSHN – The DevOps Company Standard shipping container Built for "intermodal" freight transport Help reduce cost and times of transport Universal standard open to anyone Ecosystem of vehicles, training, accessories, tools… Shipping Containers 19

Slide 20

Slide 20 text

VSHN – The DevOps Company Standard (code) shipping containers Bundle: app + dependencies + libraries + runtimes + con guration + … Runtime isolation through OS-level virtualization Not a new idea: Version 7 Unix "chroot" (1979-1982), FreeBSD "jails" (2000), LXC (2008), Docker (2013) Application Containers 20

Slide 21

Slide 21 text

VSHN – The DevOps Company Dependencies Runtime Engine Container Code Configuration 21

Slide 22

Slide 22 text

VSHN – The DevOps Company Tools 22

Slide 23

Slide 23 text

VSHN – The DevOps Company 23

Slide 24

Slide 24 text

VSHN – The DevOps Company Key element of collaboration & communication Continuous Integration ⇒ Continuous Deployment Speed: fast to start, fast to stop Portable: across operating systems, hardware, cloud platforms, environments… Isolation: controlled resource utilization Security: each container runs isolated from others Bene ts of Containers 24

Slide 25

Slide 25 text

VSHN – The DevOps Company Docker Images Template to create containers; one image can be used to create many containers. Docker Containers Running instance. Each container is created from one image. "Containers" and "Images" 25

Slide 26

Slide 26 text

VSHN – The DevOps Company Example: Fortune Cookie Service """ Fortune Cookie Service """ import os from flask import Flask from subprocess import run, PIPE from random import randrange APP = Flask(__name__) # Standard Flask app @APP.route("/") def fortune(): """ Print a random, hopefully interesting, adage """ number = randrange(1000) fortune = run('fortune', stdout=PIPE, text=True).stdout result = 'Fortune cookie of the day #' + str(number) + ':\n\n' + fortune return result if __name__ == "__main__": APP.run(host='0.0.0.0', port=os.environ.get('listenport', 9090)) 26

Slide 27

Slide 27 text

VSHN – The DevOps Company Requirements # # This file is autogenerated by pip-compile # To update, run: # # pip-compile requirements.in # click==7.0 # via flask flask==1.1.2 # via -r requirements.in itsdangerous==1.1.0 # via flask jinja2==2.10.1 # via flask markupsafe==1.1.1 # via jinja2 werkzeug==0.15.3 # via flask 27

Slide 28

Slide 28 text

VSHN – The DevOps Company # Inherit from this "empty base image", see https://hub.docker.com/_/python/ FROM python:3.7-alpine # Take some responsibility for this container MAINTAINER Jane Smith # Install some required software on Alpine Linux RUN apk add fortune # Directory to install the app inside the container WORKDIR /usr/src/app # Install python dependencies (cached if requirements.txt does not change) COPY requirements.txt ./ RUN pip install --no-cache-dir -r requirements.txt # Copy application source code into container COPY app.py . # Drop root privileges when running the application USER 1001 # Run this command at run-time CMD [ "python", "app.py" ] # Expose this TCP-port, same as app.py EXPOSE 9090 28

Slide 29

Slide 29 text

VSHN – The DevOps Company asciinema.org/a/333322 asciinema $ docker build --tag vshn/fortune-cookie-service:1.0 . Sending build context to Docker daemon 7.168kB Step 1/10 : FROM python:3.7-alpine 3.7-alpine: Pulling from library/python cbdbe7a5bc2a: Already exists 26ebcd19a4e3: Pull complete 8341bd19193b: Pull complete ecc595bd65e1: Pull complete 4b1c9d8f69d2: Pull complete Digest: sha256:778802b5b9797279772814fb15a7c6ee494848ced17965bb57092a0b900c0e4f Status: Downloaded newer image for python:3.7-alpine ---> e854017db514 Step 2/10 : MAINTAINER Jane Smith ---> Running in adcf3447d6b1 Removing intermediate container adcf3447d6b1 ---> 8fa0b316aa41 Step 3/10 : RUN apk add fortune ---> Running in 74c97d15e086 00:00 29

Slide 30

Slide 30 text

VSHN – The DevOps Company Part of the source code Versioned in git repos Sharing Docker les 30

Slide 31

Slide 31 text

VSHN – The DevOps Company Through "Image Repositories" Make images available to team members, outside contributors, or other deployment environments Public & Private Ready to run Sharing Container Images 31

Slide 32

Slide 32 text

VSHN – The DevOps Company Public Cloud Services Docker Hub Red Hat Quay Amazon Elastic Container Registry GitHub On-Premises GitLab OpenShift Container Registry APPUiO On-Premises Quay Container Repositories hub.docker.com quay.io 32

Slide 33

Slide 33 text

VSHN – The DevOps Company 33

Slide 34

Slide 34 text

VSHN – The DevOps Company Kubernetes 34

Slide 35

Slide 35 text

VSHN – The DevOps Company Most cloud applications have di erent components: Databases Web servers Message queues Monitoring systems … all deployed in various environments: "dev", "test"… … all connected to each other… … and with redundancy! Application Complexity 35

Slide 36

Slide 36 text

VSHN – The DevOps Company If each component is inside a container… … each with its own IP or port… … each loosely connected to one another… … we need a "Container Orchestrator" How to Coordinate those Components? 36

Slide 37

Slide 37 text

VSHN – The DevOps Company Usually referred to as "K8s" Container orchestrator platform originally created by Google Open Source and cross-platform Part of the CNCF ecosystem Latest version: 1.18 (March 25, 2020) What is Kubernetes? 37

Slide 38

Slide 38 text

VSHN – The DevOps Company Greek word: Κυβερνήτης or "Kivernitis" Meaning: governor, commander, or captain Root of "government" and "cybernetics" How do you pronounce it? 38

Slide 39

Slide 39 text

VSHN – The DevOps Company Cluster Group of machines working together. Node A machine (virtual or not) in a cluster. Pod Minimum unit of code execution, with one or many containers inside, and which can be scaled up and down. Ephemeral! Kubernetes Terminology 1/2 39

Slide 40

Slide 40 text

VSHN – The DevOps Company Service Used to expose a deployment to the network. Persistent Volume A unit of disk storage available for pods to save data. Deployment A set of "Pods", "Services" and "Persistent Volumes" running in the nodes of a cluster. Kubernetes Terminology 2/2 40

Slide 41

Slide 41 text

VSHN – The DevOps Company Kubernetes Deployment apiVersion: apps/v1 kind: Deployment metadata: name: fortune-deployment labels: app: fortune-app spec: template: spec: containers: - image: vshn/fortune-cookie-service:1.0 name: fortune-container ports: - containerPort: 9090 name: fortune-port metadata: labels: app: fortune-app selector: matchLabels: app: fortune-app strategy: type: Recreate 41

Slide 42

Slide 42 text

VSHN – The DevOps Company Kubernetes Service apiVersion: v1 kind: Service metadata: name: fortune-service labels: app: fortune-app spec: ports: - port: 3000 targetPort: fortune-port selector: app: fortune-app type: LoadBalancer 42

Slide 43

Slide 43 text

VSHN – The DevOps Company asciinema.org/a/333331 Context: minikube <0> all … ____ __.________ Cluster: minikube <1> default …| |/ _/ __ \______ User: minikube …| < \____ / ___/ K9s Rev: 0.19.4 [15964] …| | \ / /\___ \ K8s Rev: v1.18.2 …|____|__ \ /____//____ > … \/ \/ ┌──────────────────────────────── Deployments(default)[1] ───────────────────────── │ NAME READY UP-TO-DATE AVAILABLE AGE │ │ fortune-deployment 1/1 1 1 89s │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └────────────────────────────────────────────────────────────────────────────── 00:00 43

Slide 44

Slide 44 text

VSHN – The DevOps Company Kubernetes is a container orchestrator that manages clusters Clusters consist of Nodes Kubernetes runs Deployments in Nodes Deployments usually consist of Pods, Services and Storage Services expose network ports to the outside world Pods consist of Containers Containers are built from Images Images are built with a Docker le 44

Slide 45

Slide 45 text

VSHN – The DevOps Company 45

Slide 46

Slide 46 text

VSHN – The DevOps Company Rancher RKE Red Hat OpenShift Amazon Web Services: Elastic Kubernetes Service (EKS) Microsoft Azure: Azure Kubernetes Service (AKS) Google Cloud: Google Kubernetes Engine (GKE) APPUiO ("OpenShift as a Service") Kubernetes Distributions 46

Slide 47

Slide 47 text

VSHN – The DevOps Company Docker Desktop kind Minikube Rancher K3s Canonical Microk8s Red Hat OpenShift CodeReady Containers (CRC) Kubernetes in your Laptop 47

Slide 48

Slide 48 text

VSHN – The DevOps Company Migrating your Application to Docker & Kubernetes 48

Slide 49

Slide 49 text

VSHN – The DevOps Company 1. Follow DevOps principles and Twelve-Factor application guidelines. 2. Encapsulate your applications in Docker images: docker build -t company/imagename . 3. Specify the interconnections of those images in YAML les. 4. Deploy all to a Kubernetes cluster: kubectl apply -f deployment.yaml Steps 49

Slide 50

Slide 50 text

VSHN – The DevOps Company Docker les and YAML les serve as documentation and communication tools Docker images ensure replicability and coherence across environments, machines, and time Same standards apply to all Kubernetes clusters, on all cloud environments: Portability! Advantages 50

Slide 51

Slide 51 text

VSHN – The DevOps Company 1. DevOps principles: automation & infrastructure as code 2. Containers are the basic blocks of cloud-native apps 3. Kubernetes is a container orchestrator 4. Kubernetes comes in various "distributions" 5. The tools shown today can be adopted progressively Conclusion 51

Slide 52

Slide 52 text

VSHN – The DevOps Company Get a FREE 30-day evaluation Kubernetes cluster! 1. Go to 2. Click "Redeem Code" 3. docker-k8s-webinar- 2020 Conditions O er valid until August 26th, 2020 Con guration: 2 GiB RAM / 1100 mC Try Docker & Kubernetes appuio.ch/en 52

Slide 53

Slide 53 text

VSHN – The DevOps Company  Recording, slides and whitepaper will be shared via email after the webinar.  For the impatient: Slides $ docker run --name="webinar" --rm --detach vshn/docker-and-kubernetes-webinar:1.0 $ docker cp webinar:usr/share/nginx/html/slides.pdf . $ docker cp webinar:usr/share/nginx/html/whitepaper.pdf . $ docker kill webinar 53

Slide 54

Slide 54 text

VSHN – The DevOps Company Adrian Kosmaczewski – Developer Relations: VSHN AG – Neugasse 10 – CH-8005 Zürich – +41 44 545 53 00 – – Thanks! [email protected] vshn.ch [email protected] 54

Slide 55

Slide 55 text

VSHN – The DevOps Company Have more questions? Need help? Reach out via e-mail: Questions? [email protected] 55