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

Managing Stateful apps on Kubernetes

Managing Stateful apps on Kubernetes

This talk was presented at All Things Open 2018. The presentation is an introduction to Kubernetes objects used to manage stateful apps. It also includes an introduction to containers, container orchestration and Kubernetes itself.

Avatar for Rajashree Mandaogane

Rajashree Mandaogane

October 23, 2018
Tweet

Other Decks in Technology

Transcript

  1. Application packaging • Source code, dependencies, env vars • Application

    portability • Performance consistency • No more “it works on my machine”
  2. OS level virtualization • Containers share host Operating System •

    Lightweight as opposed to a VM • One host can run multiple containers • Resource isolation • Increased efficiency
  3. EC2 Container EC2 EC2 Client Managing containers Container Container Container

    Container Container Container Container Container Run 3 containers Run 3 containers Run 3 containers
  4. Managing containers • Which machine is my container running on?

    • Are there sufficient resources for my app? • How do containers communicate with each other? • How do I manage load balancing? • How do I ensure healthcheck/monitoring?
  5. Pod • Smallest deployable unit • One or more containers

    • “one-container-per-pod” • Unique IP address Container Pod 10.10.1.1 Node
  6. Deployment • Pods are ephemeral • Deployments manage pod life-cycle

    • Ensure actual state same as desired • Provide easy scaling, upgrades for apps
  7. k8s cluster Pod 1 10.10.1.1 10.11.1.1 10.11.1.2 Pod 2 Pod

    3 Node 1 Node 2 Deployment selector=
 app: nginx labels=
 app: nginx labels=
 app: nginx labels=
 app: nginx
  8. Stateless • No persisted data • No application state •

    Pods are replaceable • Examples: edge API server, nginx
  9. Why run stateful apps on k8s? 1. Depends on use

    case 2. Leverage containerization benefits 3. Manage stateless and stateful apps together 4. Ability to use same infrastructure provider 5. Easy scalability 6. Affordability
  10. K8s objects for statefulness • Persistent Volumes (PV) • Persistent

    Volume Claims (PVC) • Storage Class • StatefulSet
  11. Persistent volume • Storage resource in k8s • Volume plugins

    • Created by cluster admin • Lifecycle independent of pod
  12. Persistent Volume Claims • Request to claim a storage resource

    • Abstracts storage details of PV from user • User only specifies size and access mode • Access modes: RWO, RWM, ROM
  13. Static Provisioning Cluster admin Creates PV PV size: 10 GB

    AccessMode: RWO User Creates PVC PVC requests: size: 3 GB (min) AccessMode: RWO Available PVController Bound
  14. Limitations? • User created PVC requesting 3 Gib • But

    there was only one PV with 10 Gib • PV got bound to PVC with excess volume • User will get a PV-PVC binding only if admin has created enough PVs
  15. Storage Class • Resource for classifying storage • Specifies provisioner,

    parameters, reclaimPolicy • Created by cluster admin • User must know name of Storage Class
  16. Dynamic Provisioning Cluster admin Creates 
 Storage Class Name: standard


    Provisioner: aws-ebs Parameters: type=gp2 ReclaimPolicy: Delete User Creates PVC PVC storageClass: standard size: 3 GB (min) AccessMode: RWO Creates PV PV size: 3 GB AccessMode: RWO
  17. Pod in stateful app • Stores data independently • Should

    have separate PV • Needs separate PVC for separate PV
  18. • Lets say you want 10 pods for your app

    • Do you create 10 PVCs? • What about when you want to scale up? • Can something create PVCs dynamically too? Pod in stateful app
  19. StatefulSets • Stable unique persistent volume for each pod •

    Creates PVC using a volume claim template • Stable unique network identifier for all pods • Ordered deployment and scaling • Automated rolling updates
  20. Use Case - Cassandra • Highly available, scalable • Uses

    replication while storing data • All nodes are equal • Cassandra nodes can identify each other