Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Introduction to kubernetes

146 views

Published on

Those are the slides that were used to give an introduction to Kubernetes at the Nardoz Berlin Meetup on the 2018-06-28.

Published in: Internet
  • Be the first to comment

Introduction to kubernetes

  1. 1. Introduction to Kubernetes 2018-06-28 - Nardoz Berlin Raffaele Di Fazio - @x0rg
  2. 2. Agenda ● What is Kubernetes? ● Architecture ● Main concepts with hands on examples
  3. 3. Pre-check: who doesn’t know what a container is? ● “Containers are an abstraction at the app layer that packages code and dependencies together.” ● They don’t really exist… ○ CGroups ○ Namespaces ● Docker: nice UX on top of running isolated self contained applications ● Immutable artifacts
  4. 4. Kubernetes ● Open Source container orchestration system ● Inspired by Borg, Omega, Mesos ● Started at Google, donated to CNCF
  5. 5. The history so far
  6. 6. The OSS history so far
  7. 7. Kubernetes (April 2018)
  8. 8. Kubernetes (June 2018)
  9. 9. Kubernetes Architecture
  10. 10. Kubernetes architecture API Server Controller manager Scheduler etcd Worker Node (VM) Worker Node (VM) Kubelet Kubelet nginx nginx nginx kube-proxy kube-proxy
  11. 11. Kubernetes: running an application API Server
  12. 12. Kubernetes: running an application API Server Deployment yaml
  13. 13. Kubernetes: running an application API Server Deployment yaml Scheduler
  14. 14. Kubernetes: running an application API Server Kubelet Deployment yaml Scheduler
  15. 15. Kubernetes: running an application API Server Kubelet Deployment yaml Scheduler Controller manager
  16. 16. Kubernetes: running an application https://jvns.ca/blog/2017/07/27/how-does-the-kubernetes-scheduler-work/
  17. 17. Main Concepts
  18. 18. Pod ● The “scheduling unit” of Kubernetes ● Doesn’t get restarted when terminates (can be one shot) ● Pods are collection of one or more containers
  19. 19. Pod in one picture Instance (node 1) Pod 1 Pod 2 Container 1 Container 2 Container 3 Container 4 Instance (node 2) Pod 3 Pod 4 Container 5 Container 6 Container 7 Container 8
  20. 20. Pod ● Containers in the same pod are guaranteed to be on the same host ● Containers in the same pod can talk via localhost ● Every pod gets a dedicated virtual IP address in the “pod network” ● Analogy: your application instance in AWS
  21. 21. Pod apiVersion: v1 kind: Pod metadata: name: pod-example spec: containers: - name: ubuntu image: ubuntu:trusty command: ["echo"] args: ["Hello World"]
  22. 22. Kubernetes patterns: reconciler ● Controllers in Kubernetes are built by implementing the reconciler pattern ○ GetCurrentState() ○ GetDesiredState() ○ Apply() ● Controller manager: enforces deployment replicas
  23. 23. Deployment ● Defines a single application in Kubernetes handled by the system ● Analogy: Autoscaling Group in AWS ○ You set the desired state, Kubernetes enforces it
  24. 24. Deployment apiVersion: apps/v1beta1 kind: Deployment metadata: # Unique key of the Deploymentinstance name: deployment-example spec: # 3 Pods should exist at all times. replicas: 3 template: metadata: labels: app: nginx spec: containers: - name: nginx # Run this image image: nginx:1.10
  25. 25. Demo
  26. 26. Kubernetes’ overlay networking ● Every pod gets its own IP from a dedicated overlay network ○ Solves the problem of port mapping ○ No NAT needed ● Implemented via software solution (flannel, calico, weave, …) ● Iptables everywhere!
  27. 27. Service ● Defines how to to reach your app ● Internal Service: cluster valid IP + DNS ● Can use service as Service Discovery (DNS based) ● Label based selection of targets
  28. 28. Service kind: Service apiVersion: v1 metadata: name: service-example spec: ports: - name: http port: 80 targetPort: 80 selector: app: nginx type: LoadBalancer
  29. 29. Demo
  30. 30. ConfigMap & Secrets ● Object containing a K/V storage for configuration purposes ● Can be “mounted”: ○ File ○ Environment variable ● Keep your configuration for the app generic and customize via ConfigMap ● Secret: like a ConfigMap with hidden fields :-)
  31. 31. DaemonSet ● Run one instance of the pod for each node of the cluster ● Useful mostly for cluster ops ● Ideal for “system agents”
  32. 32. Daemonset apiVersion: extensions/v1beta1 kind: DaemonSet metadata: name: daemonset-example spec: template: metadata: labels: app: daemonset-example spec: containers: - name: daemonset-example image: ubuntu:trusty command: - /bin/sh args: - -c - >- while [ true ]; do echo "DaemonSet running on $(hostname)" ; sleep 10 ; done
  33. 33. Demo
  34. 34. A lot more to cover ● StatefulSets ● ServiceAccounts ● Namespaces ● Quotas ● …. ● Check out: https://kubernetes.io
  35. 35. If you want to know more https://www.youtube.com/watch?v=WwBdNXt6wO4
  36. 36. If you want to know more https://www.youtube.com/watch?v=9YYeE-bMWv8&list=PLvmPtYZtoXOENHJiAQc6HmV2jmuexKfrJ
  37. 37. If you want to know more https://www.youtube.com/watch?v=w34txLmpEuM
  38. 38. Thank you! Raffaele Di Fazio - @x0rg

×