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

Kubernetes-Einstieg: Mit der Tür ins Haus

Kubernetes-Einstieg: Mit der Tür ins Haus

Du hast verstanden was Docker und Container sind und würdest nun gerne wissen was es mit Kubernetes auf sich hat?
Das lässt sich am besten mit den Fingern an der Tastatur herausfinden!

In dieser Session werden wir ohne lange Vorrede Kubernetes praxisorientiert kennenlernen. Dazu werden wir gemeinsam eine Anwendung deployen, im Internet bereitstellen, horizontal skalieren, Lastverteilung realisieren, Selbstheilung beobachten und rolling Updates durchführen.
Dadurch stellt sich spielerisch ein Verständnis grundlegender Funktionen von Kubernetes ein.

Einzige Voraussetzungen für die Teilnahme ist ein Rechner, auf dem Docker installiert ist.

schnatterer

July 17, 2020
Tweet

More Decks by schnatterer

Other Decks in Technology

Transcript

  1. / // // KUBERNETES EINSTIEG: KUBERNETES EINSTIEG: MIT DER TÜR

    INS HAUS MIT DER TÜR INS HAUS JOHANNES SCHNATTERER CLOUDOGU GMBH VERSION: 202007161843-176895E 1 . 1
  2. / Pull image for workshop Pull image for workshop #

    Start container with all tools necessary for workshop $ docker run -it cloudogu/k8s-training 1 . 2
  3. / Operations on "plain" Docker host in production — what

    is missing? Operations on "plain" Docker host in production — what is missing? • For some use cases: Nothing! • For others: • High availability • Load Balancing • Solutions for challenges of distributed systems, e.g networking, storage • Scaling out containers • Rolling updates 2 . 2
  4. / Kubernetes (k8s) Kubernetes (k8s) You will see the following

    features hands-on: • Scheduling containers on multiple nodes • Scaling out (scaling horizontally) • Load balancing • Self healing • Rolling updates 3 . 3
  5. / Cluster access Cluster access # In cloudogu/k8s-training container -

    Create cluster config $ k8s-training-auth fdt 2020 # Test connection: no error means success $ kubectl version 3 . 5
  6. / First deployment First deployment $ NAME=think-of-something-unique $ kubectl create

    deployment $NAME --image=cloudogu/hello-k8s # Success? $ k get deployment $NAME 3 . 6
  7. / Access via the internet Access via the internet k

    expose deployment $NAME --port=80 --target-port 8080 --type=LoadBalancer # Query EXTERNAL-IP, then open in browser k get service $NAME 3 . 7
  8. / Deployment ➜ Pod ➜ Container Deployment ➜ Pod ➜

    Container Deployment Container 1 Container n Container 1 Container n Pod 1 Pod n $ k get pod | grep $NAME 3 . 10
  9. / Pod ➜ Node Pod ➜ Node K8s Cluster Node

    n Node 1 Pod n Pod 1 Pod 2 $ k get pod -owide $ k get node 3 . 11
  10. / Scaling out Scaling out $ k scale deployment $NAME

    --replicas=2 $ k get deployment $NAME $ k get pod | grep $NAME 3 . 13
  11. / Load Balancing Load Balancing • Reload app in browser

    multiple times (look at "pod:") • or run script: # k get service $NAME $ EXTERNAL_IP=w.x.y.z $ while [ 1 ]; do echo $(curl -s http://$EXTERNAL_IP/api/hostName); done 3 . 14
  12. / Services Services K8s Cluster Node n Node 1 Service

    Pod n Service Pod 1 Pod 2 Load Balancer 3 . 15
  13. / Self healing Self healing # New terminal (or use

    tmux) $ docker run -it cloudogu/k8s-training $ k8s-training-auth fdt 2020 # k get service $NAME $ EXTERNAL_IP=w.x.y.z $ while [ 1 ]; do echo $(curl -s http://$EXTERNAL_IP/api/hostName); done $ k get pod | grep $NAME $ PODNAME=one-of-your-pods $ k delete pod $PODNAME $ k get pod | grep $NAME 3 . 16
  14. / Rolling update Rolling update Version 1.0 active Begin rolling

    update Both versions active Version 2.0 active Service 1.0 active 1.0 active 1.0 active Service 2.0 deploying 1.0 active 1.0 active Service 2.0 active 2.0 deploying 1.0 active Service 2.0 active 2.0 active 2.0 active 3 . 17
  15. / $ EXTERNAL_IP=w.x.y.z $ while [ 1 ]; do echo

    $(curl -s --connect-timeout 1 -m 1 http://$EXTERNAL_IP/api/appVersion); done # -m ➜ max-time # Other terminal $ k get pod | grep $NAME $ k set image deploy $NAME hello-k8s=cloudogu/hello-k8s:1.9.1 # Multiple times $ k get pod | grep $NAME 3 . 18
  16. / Key takeaways Key takeaways • k8s - run containers

    in a cluster (on multiple nodes) • pod - smallest resource in k8s (comprising containers) • deployment • scaling out containers • self-healing • rolling updates • service • cluster access • load balancing 4 . 2
  17. / Johannes Schnatterer Johannes Schnatterer Cloudogu GmbH Questions or feedback?

    Questions or feedback? my.cloudogu.com cloudogu.com/schulungen https://forum.cloudogu.com/topic/65 @cloudogu @jschnatterer 4 . 3