$30 off During Our Annual Pro Sale. View Details »

Kubernetes Fundamentals

Kubernetes Fundamentals

Kubernetes. It's so hot right now. But what is it?

This session is designed to show the fundamentals of Kubernetes. It assumes you know what a container is, that Kubernetes does something called "orchestration" with it, but that's it.

We'll cover the following: Container Registry, Pods, Services, Ingress, Scaling, Networking, mounting volumes, package management (Helm) and what's next.

Tommy Falgout

June 01, 2019
Tweet

More Decks by Tommy Falgout

Other Decks in Technology

Transcript

  1. View Slide

  2. View Slide

  3. View Slide

  4. VM
    VM
    VM
    VM
    Server
    Host OS
    Hypervisor
    Guest OS Guest OS Guest OS
    App C
    App B
    App A
    Server
    Host OS
    Hypervisor

    View Slide

  5. VM
    VM
    VM
    VM
    Server
    Host OS
    Hypervisor
    Guest OS Guest OS Guest OS
    App C
    App B
    App A
    Server
    Host OS
    Hypervisor

    View Slide

  6. VM
    Container
    VM
    VM
    VM
    Server
    Host OS
    Hypervisor
    Guest OS Guest OS Guest OS
    App C
    App B
    App A
    Server
    Host OS
    Hypervisor
    Bins/Libs
    App A

    View Slide

  7. VM
    Container
    Container
    Container
    VM
    VM
    VM
    Server
    Host OS
    Hypervisor
    Guest OS Guest OS Guest OS
    App C
    App B
    App A
    Server
    Host OS
    Hypervisor
    Bins/Libs
    App B
    App C
    Bins/Libs
    App A
    Bins/Libs

    View Slide

  8. VM
    Container
    Container
    Container
    VM
    VM
    VM
    Server
    Host OS
    Hypervisor
    Guest OS Guest OS Guest OS
    App C
    App B
    App A
    Server
    Host OS
    Hypervisor
    Bins/Libs
    App B
    App C
    Bins/Libs
    App A
    Bins/Libs

    View Slide

  9. View Slide

  10. Image Name
    Process
    started in an
    executing
    container
    Initializes a
    new build
    stage and sets
    the base
    image
    Execute commands
    in a new layer on
    top of the current
    image and commit
    results
    Provide defaults
    for an executing
    container
    Captures the steps to build a container
    image
    Version-able asset in your DevOps flows
    Configuration-as-Code

    View Slide

  11. View Slide

  12. VM
    Container
    Container
    Container
    Server
    Host OS
    Hypervisor
    Bins/Libs
    App B
    App C
    Bins/Libs
    App A
    Bins/Libs
    Container Image
    Container Image
    Container Image
    Container Image
    Container Image
    Container Image

    View Slide

  13. VM
    Container
    Container
    Container
    Server
    Host OS
    Hypervisor
    Bins/Libs
    App B
    App C
    Bins/Libs
    App A
    Bins/Libs
    Container Image
    Container Image
    Container Image
    Container Image
    Container Image
    Container Image

    View Slide

  14. View Slide

  15. VM
    Container
    Container
    Container
    Server
    Host OS
    Hypervisor
    Bins/Libs
    App B
    App C
    Bins/Libs
    App A
    Bins/Libs
    VM
    Container
    Container
    Container
    Server
    Host OS
    Hypervisor
    Bins/Libs
    App B
    App C
    Bins/Libs
    App A
    Bins/Libs

    View Slide

  16. View Slide

  17. View Slide

  18. View Slide

  19. Container Orchestrator

    View Slide

  20. Container Orchestrator
    Cluster

    View Slide

  21. VM
    Server
    Host OS
    Hypervisor
    Guest OS
    Container Orchestrator
    Cluster

    View Slide

  22. VM
    Server
    Host OS
    Hypervisor
    Guest OS
    Cluster

    View Slide

  23. Kubernetes comes from the Greek
    word κυβερνήτης:, which
    means helmsman or ship pilot, ie: the
    captainer of a container ship.
    "Kubernetes is an open-source system for automating deployment,
    scaling, and management of containerized applications."

    View Slide

  24. VM
    Server
    Host OS
    Hypervisor
    Guest OS
    Kubernetes
    Master
    Cluster
    Node Node Node
    Node Node Node

    View Slide

  25. AKS reduces the complexity and operational
    overhead of managing Kubernetes by
    offloading much of that responsibility to
    Azure.
    You only pay for the worker nodes within
    your clusters, not for the master nodes

    View Slide

  26. View Slide

  27. Kubernetes
    Cluster
    Node Node Node
    Node Node Node

    View Slide

  28. Master
    Cluster
    Node
    api-server
    etcd
    controller-
    manager
    scheduler

    View Slide

  29. Master
    Cluster
    Node
    api-server
    etcd
    controller-
    manager
    scheduler

    View Slide

  30. Container
    Container
    Container
    Bins/Libs
    App B
    App C
    Bins/Libs
    App A
    Bins/Libs
    Where do the Containers go?

    View Slide

  31. Container
    Container
    Container
    Bins/Libs
    App B
    App C
    Bins/Libs
    App A
    Bins/Libs
    Introducing…. Pods!

    View Slide

  32. Pods
    Master
    Cluster
    Node
    api-server
    etcd
    controller-
    manager
    scheduler

    View Slide

  33. Pods
    Master
    Cluster
    Node
    api-server
    etcd
    controller-
    manager
    scheduler

    View Slide

  34. ratings-api
    Label(s) app=ratings-api
    Container-image my.azurecr.io/ratings-api
    Port 3001
    (VolumeMount) /mnt/share
    (Resources)
    ratings-web
    Label(s) app=ratings-web
    Container-image my.azurecr.io/ratings-web
    Port 3000
    (VolumeMount) /mnt/share
    (Resources)
    Pods – What are they?
    otherApp
    Label(s) app=otherApp
    Container-image other.azurecr.io/other
    App
    Port 4045
    (VolumeMount) /mnt/share
    Metadata that describes how the containers are configured.

    View Slide

  35. Deployments
    Metadata that describes how to deploy a pod
    More Metadata
    ratings-web
    replicas 2
    ratings-web
    Label(s) app=ratings-web
    Container-
    image
    my.azurecr.io/
    ratings-web
    Port 3000
    (Volume) …
    (Resources) …

    View Slide

  36. Cluster
    Node Node
    Master

    View Slide

  37. Cluster
    Node Node
    Master

    View Slide

  38. Cluster
    Node Node
    Master

    View Slide

  39. ratings-web2
    Label(s) app=ratings-web
    Container-
    image
    my.azurecr.io/
    ratings-web
    Port 3000
    Services
    Metadata that describes how to reach the pods
    Yet More Metadata!
    ratings-web
    Selector app=ratings-web
    Port Mapping 8080:3000
    Type (Internal
    or External)
    LoadBalancer
    ratings-web1
    Label(s) app=ratings-web
    Container-
    image
    my.azurecr.io/
    ratings-web
    Port 3000

    View Slide

  40. Services Cluster
    Node Node
    Service
    ratings-web
    IP Address
    Master

    View Slide

  41. Services Cluster
    Node Node
    Service
    ratings-web
    IP Address
    Master

    View Slide

  42. Manual via Kubernetes Portal
    Infra-as-Code a YAML file

    View Slide

  43. View Slide

  44. Scaling Pods
    ratings-web
    replicas 3
    ratings-web
    Label(s) app=ratings-web
    Container-
    image
    my.azurecr.io/
    ratings-web
    Port 3000
    (Volume) …
    (Resources) …

    View Slide

  45. Scaling Pods
    ratings-web
    replicas 6
    ratings-web
    Label(s) app=ratings-web
    Container-
    image
    my.azurecr.io/
    ratings-web
    Port 3000
    (Volume) …
    (Resources) …

    View Slide

  46. Node
    Master
    Cluster
    Node Node

    View Slide

  47. Node
    Node
    Node
    Master
    Cluster
    Node
    az scale –name –g –node-count

    View Slide

  48. Azure Container Instances
    Node
    With Azure Container Instances
    Master
    Cluster
    Node
    az enable-addons –g –name
    –addons –subnet-name

    View Slide

  49. View Slide

  50. Master
    Cluster
    Service
    ratings-web
    IP Address
    Updated App Updated App Updated App

    View Slide

  51. Node
    Node
    Node
    Master
    Cluster
    Service
    ratings-web
    IP Address

    View Slide

  52. Node
    Node
    Node
    Master
    Cluster
    Service
    ratings-web
    IP Address

    View Slide

  53. View Slide

  54. Why do we need volumes ?
    Volume
    (state)

    View Slide

  55. View Slide

  56. PV vs PVC
    Volumes
    emptyDir
    hostPath
    Persistent Volume
    Claim (PVC)
    ConfigMap
    Security
    ….
    Persistent Volume (PV)

    View Slide

  57. Dynamic Storage in AKS – Azure Disk

    View Slide

  58. View Slide

  59. Inter-Pod Communication

    View Slide

  60. Why Services?

    View Slide

  61. Why Services?

    View Slide

  62. View Slide

  63. How does ClusterIP Work

    View Slide

  64. How does LoadBalancer Work

    View Slide

  65. How does NodePort Work

    View Slide

  66. How does Ingress Controller Work

    View Slide

  67. View Slide

  68. 1. Kubernetes users communicate with
    API server and apply desired state
    2. Master nodes actively enforce
    desired state on worker nodes
    3. Worker nodes support
    communication between containers
    Kubernetes
    control
    API server
    replication, namespace,
    serviceaccounts, etc.
    -controller-
    manager -scheduler
    etcd
    Master node
    Worker node
    kubelet Service
    Docker
    Pods Pods
    Worker node
    kubelet Service
    Docker
    Pods Pods
    Internet
    4. Worker nodes support
    communication from the
    Internet

    View Slide

  69. API server
    Controller
    Manager
    Scheduler
    etcd
    Store
    Cloud
    Controller
    Self-managed master node(s)
    • Automated upgrades, patches
    • High reliability, availability
    • Easy, secure cluster scaling
    • Self-healing
    • API server monitoring
    • At no charge
    Customer VMs
    App/
    workload
    definition
    User
    Docker
    Pods
    Docker
    Pods
    Docker
    Pods
    Docker
    Pods
    Docker
    Pods
    Schedule pods over
    private tunnel
    Kubernetes API
    endpoint
    Azure managed control plane

    View Slide

  70. Task The old way With Azure
    Create a cluster Provision network and VMs
    Install dozens of system components including etcd
    Create and install certificates
    Register agent nodes with control plane
    az aks create
    Upgrade a cluster Upgrade your master nodes
    Cordon/drain and upgrade worker nodes individually
    az aks upgrade
    Scale a cluster Provision new VMs
    Install system components
    Register nodes with API server
    az aks scale

    View Slide

  71. View Slide

  72. View Slide

  73. Operationalizing Kubernetes

    View Slide

  74. Helm
    Helm Charts helps you define, install, and upgrade even
    the most complex Kubernetes application
    pods
    services
    Chart.yml
    db
    deployments
    ci

    View Slide

  75. Helm
    The best way to find, share, and use software built
    for Kubernetes
    Manage complexity
    Charts can describe complex
    apps; provide repeatable app
    installs, and serve as a single
    point of authority
    Easy updates
    Take the pain out
    of updates with in-place
    upgrades and custom
    hooks
    Simple sharing
    Charts are easy to
    version, share, and host
    on public or private
    servers
    Rollbacks
    Use helm rollout to
    roll back to an older
    version of a release with
    ease

    View Slide

  76. Many Choices

    View Slide

  77. A fully managed service of Red Hat OpenShift on Azure, jointly, engineered, operated and
    supported by Microsoft and Red Hat

    View Slide

  78. https://kubernetes.io/docs/home/
    https://aka.ms/learnkubernetes
    https://aksworkshop.io/
    https://helm.sh/blog/helm-3-preview-pt7/
    https://docs.microsoft.com/en-us/azure/aks/best-practices

    View Slide

  79. View Slide

  80. View Slide