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

Stateful Applications mit Kubernetes

F029ec9c798e4dc447cab5e76f62fa17?s=47 Nicolas Byl
September 21, 2017

Stateful Applications mit Kubernetes

F029ec9c798e4dc447cab5e76f62fa17?s=128

Nicolas Byl

September 21, 2017
Tweet

Transcript

  1. STATEFUL APPLICATIONS MIT KUBERNETES BED-CON 2017 Nicolas Byl, codecentric AG

    1
  2. 2

  3. PERSISTENT APPLICATION STATE 3 . 1

  4. GOALS Scalable Highly Available Fault Tolerance 3 . 2

  5. EXAMPLE ARCHITECTURE 3 . 3

  6. CANDIDATES MySQL PostgreSQL Cassandra MongoDB Kafka … 3 . 4

  7. KUBERNETES 4 . 1

  8. DESIGN PHILOSOPHY portable: public, private, hybrid, multi-cloud extensible: modular, pluggable,

    hookable, composable self-healing: auto-placement, auto-restart, auto-replication, auto-scaling 4 . 2
  9. PODS 4 . 3

  10. SERVICES 4 . 4

  11. PERSISTENT VOLUMES 5 . 1

  12. 5 . 2

  13. GCEPersistentDisk CephFS AWSElasticBlockStore Cinder (OpenStack block storage) AzureFile Glusterfs AzureDisk

    VsphereVolume FC (Fibre Channel) Quobyte Volumes FlexVolume HostPath Flocker VMware Photon
  14. NFS vPortworx Volumes iSCSI ScaleIO Volumes RBD (Ceph Block Device)

    StorageOS 5 . 3
  15. ACCESS MODES ReadWriteOnce – the volume can be mounted as

    read-write by a single node ReadOnlyMany – the volume can be mounted read-only by many nodes ReadWriteMany – the volume can be mounted as read-write by many nodes 5 . 4
  16. USAGE Provision Disk Create Persistent Volume Create Persistent Volume Claim

    Mount Claim in Pod 5 . 5
  17. PERSISTENT VOLUME apiVersion: v1 kind: PersistentVolume metadata: name: pv0003 spec:

    capacity: storage: 5Gi accessModes: - ReadWriteOnce persistentVolumeReclaimPolicy: Recycle nfs: path: /tmp server: 172.17.0.2 5 . 6
  18. PERSISTENT VOLUME CLAIM kind: PersistentVolumeClaim apiVersion: v1 metadata: name: myclaim

    spec: accessModes: - ReadWriteOnce resources: requests: storage: 8Gi 5 . 7
  19. MOUNTING A PVC kind: Pod apiVersion: v1 metadata: name: mypod

    spec: containers: - name: mydatabase image: mysql:5.7 volumeMounts: - mountPath: "/var/lib/mysql" name: mypd volumes: - name: mypd persistentVolumeClaim: claimName: myclaim 5 . 8
  20. COMMON PITFALLS The abstraction is leaky. Local storage vs. SAN

    storage vs. Network Filesystems 5 . 9
  21. AUTO-PROVISIONING 6 . 1

  22. AUTO-PROVISIONING Manual creation of Persistent Volumes is error-prone. Does not

    scale well. 6 . 2
  23. STORAGECLASS kind: StorageClass apiVersion: storage.k8s.io/v1 metadata: name: standard provisioner: kubernetes.io/aws-ebs

    parameters: type: gp2 6 . 3
  24. USING A STORAGECLASS kind: PersistentVolumeClaim apiVersion: v1 metadata: name: myclaim

    spec: accessModes: - ReadWriteOnce resources: requests: storage: 8Gi storageClassName: standard 6 . 4
  25. SUPPORTED PROVISIONERS default volume plugins (in-tree provisioners) out-of-tree provisioners community

    provisioners: write your own: https://github.com/kubernetes- incubator/external-storage https://github.com/kubernetes- incubator/external- storage/tree/master/docs/demo/hostpath-provisioner 6 . 5
  26. SCALING 7 . 1

  27. ARCHITECTURE REVISITED 7 . 2

  28. SHARING PVCS Need different paths per Pod. Share needs to

    be available on every host. Corruption of file system affects all database nodes. Sharing a Persistent Volume Claim is not a good idea. 7 . 3
  29. STATEFUL SETS 8 . 1

  30. STATEFULSETS Pod template mechanism Hostnames are atomically increased: pod-0 pod-1

    … Volume Claims can be provisioned on-the-fly 8 . 2
  31. STATEFULSET EXAMPLE apiVersion: apps/v1beta1 kind: StatefulSet metadata: name: web spec:

    serviceName: "nginx" replicas: 2 template: metadata: labels: app: nginx spec: containers: - name: nginx image: gcr.io/google_containers/nginx-slim:0.8 ports: - containerPort: 80 name: web volumeMounts: 8 . 3
  32. ARCHITECTURE STATEFULSETS 8 . 4

  33. WRAP UP 9 . 1

  34. LINKS Persistent Volumes: Tutorial StatefulSet: Demos: https://kubernetes.io/docs/concepts/storage/persistent- volumes https://kubernetes.io/docs/tutorials/stateful-application/basic- stateful-set/

    https://goo.gl/NCnzq8 9 . 2
  35. THE END Copyright 2017 @NicolasByl 9 . 3