Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Docker and Kubernetes: The Way to Cloud-Native Computing

Docker and Kubernetes: The Way to Cloud-Native Computing

The cloud has become indispensable today because it increases speed, flexibility and agility of its users. The underlying software architecture that allows for this efficient use is called Cloud Native Computing and consists of software containers such as Docker and service orchestration through Kubernetes.

Thanks to the open standard, it enables the infrastructure-independent development and operation of your applications and thus makes you future-proof.

This 60-minute webinar teaches the fundamentals of Docker and Kubernetes to IT managers and software developers who want to learn the basics of these technologies and build and run cloud-native applications. It introduces participants to containerizing an existing application and deploying it in a Kubernetes cluster and provides basic terminology and a roadmap for common scenarios:

Introduction to Docker, Kubernetes, DevOps and 12-Factor Apps
Containerization of an existing application and deployment on a Kubernetes cluster
Overview over various Kubernetes distributions: Azure AKS, Amazon EKS, Google GKE, K3s, Minikube, OpenShift
Questions and discussion

Adrian Kosmaczewski

May 26, 2020
Tweet

More Decks by Adrian Kosmaczewski

Other Decks in Technology

Transcript

  1. 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
  2. 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
  3. VSHN – The DevOps Company Webinar – May 26th, 2020

    Adrian Kosmaczewski – Developer Relations Docker and Kubernetes: The Way to Cloud-Native Computing 3
  4. 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
  5. 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
  6. 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
  7. 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
  8. 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
  9. 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
  10. 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
  11. 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
  12. 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
  13. 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
  14. 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
  15. 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
  16. 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 <[email protected]> # 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
  17. 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 <[email protected]> ---> Running in adcf3447d6b1 Removing intermediate container adcf3447d6b1 ---> 8fa0b316aa41 Step 3/10 : RUN apk add fortune ---> Running in 74c97d15e086 00:00 29
  18. VSHN – The DevOps Company Part of the source code

    Versioned in git repos Sharing Docker les 30
  19. 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
  20. 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
  21. 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
  22. 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
  23. 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
  24. VSHN – The DevOps Company Greek word: Κυβερνήτης or "Kivernitis"

    Meaning: governor, commander, or captain Root of "government" and "cybernetics" How do you pronounce it? 38
  25. 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
  26. 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
  27. 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
  28. 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
  29. 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 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └────────────────────────────────────────────────────────────────────────────── <deployment> 00:00 43
  30. 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
  31. 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
  32. VSHN – The DevOps Company Docker Desktop kind Minikube Rancher

    K3s Canonical Microk8s Red Hat OpenShift CodeReady Containers (CRC) Kubernetes in your Laptop 47
  33. 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
  34. 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
  35. 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
  36. 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
  37. 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
  38. 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