Kubernetes 有状态集群服务部署与管理

Kubernetes 有状态集群服务部署与管理

Background

Kubernetes Stateful Service Features

Kubernetes Storage

Run MySQL Cluster on Kubernetes

展开查看详情

1.Kubernetes有状态集群服务 部署与管理 时速云:张寿红

2.

3. Agenda • Background • Kubernetes Stateful Service Features • What is Kubernetes? • Init Container • Run stateful services • Pet Set on Kubernetes • Kubernetes Storage • Run MySQL Cluster on Kubernetes • Volume • Galera MySQL Introduction • Persistent Volume • Deploy MySQL Cluster with PetSet • Dynamic Storage • Cluster Operation on Kubernetes Provision

4.What is Kubernetes

5.What is Kubernetes

6.What is Kubernetes

7.What is Kubernetes Cattle Pet

8.Run Stateful Service on Kubernetes • Stateless services are popular in containerized world because they are disposable and easy to be re-created with container images. • Beyond stateless services like web server, users are increasingly deploying stateful services with containers to benefit from “build once, run anywhere” and to improve bare metal efficiency/utilization. • These “pets” bring new requirements including longer life cycle, configuration dependencies and stateful failover. Container orchestration must address these needs to successfully deploy and scale apps.

9.Run Stateful Service on Kubernetes Stateless Stateful Clustered • Pod • Volume • Pet Set • RC/Replica Set • Persistent • Init Container • Service Volume • Headless Service • Dynamic Storage Provision

10. Agenda • Background • Kubernetes Stateful Service Features • What is Kubernetes? • Init Container • Run stateful services • Pet Set on Kubernetes • Kubernetes Storage • Run MySQL Cluster on Kubernetes • Volume • Galera MySQL Introduction • Persistent Volume • Deploy MySQL Cluster with PetSet • Dynamic Storage • Cluster Operation on Kubernetes Provision

11. Kubernetes Storage • Node Based Volume • emptyDir • hostPath • Use Cases: • Store temp data • Data sharing among containers

12. Kubernetes Storage • emptyDir • hostPath

13. Kubernetes Storage • Cross Node Volume

14.Kubernetes Storage Kubernetes Cluster Node Node Node C C C C C C C C C C C C Various volume plugins Shared Volume Unshared Volume • nfs • emptyDir • hostPath • hostPath • glusterfs • gcePersistentDisk • flocker • awsElasticBlockStore • cephfs • iscsi • secret • rbd • vsphereVirtualDisk • azureFileVolume

15. Kubernetes Storage • Add your volume plugin

16. Kubernetes Storage • Persistent Volume & Persistent Volume Claim • PV/PVC abstracts details of how storage is provided from how it is consumed. • PV/PVC are API resources. • PVs are volume plugins like Volumes, but have a lifecycle independent of any individual pod that uses the PV.

17. Kubernetes Storage • PV Access Modes

18. Kubernetes Storage • PV Lifecycle Releasin Provisioning Binding Using g Reclaiming Retain Static Delete Dynamic Recycle Available Bound Released Failed

19. Kubernetes Storage • PV Provision & Binding Process

20. Kubernetes Storage • Dynamic Storage Provision kind: StorageClass kind: StorageClass apiVersion: apiVersion: storage.k8s.io/v1beta1 storage.k8s.io/v1beta1 metadata: metadata: name: slow name: fast provisioner: kubernetes.io/gce- provisioner: pd kubernetes.io/gce-pd parameters: parameters: type: pd-standard type: pd-ssd

21. Kubernetes Storage • Dynamic Storage Provision "kind": "PersistentVolumeClaim", "spec": { "apiVersion": "v1", "accessModes": [ "metadata": { "ReadWriteOnce" "name": "claim1", ], "annotations": { "resources": { "requests": { "volume.beta.kubernetes.io/storage- "storage": "30Gi" class": "fast" } } } }, } This claim will result in an SSD-like Persistent Disk being automatically provisioned. When the claim is deleted, the volume will be destroyed.

22. Agenda • Background • Kubernetes Stateful Service Features • What is Kubernetes? • Init Container • Run stateful services • Pet Set on Kubernetes • Kubernetes Storage • Run MySQL Cluster on Kubernetes • Volume • Galera MySQL Introduction • Persistent Volume • Deploy MySQL Cluster with PetSet • Dynamic Storage • Cluster Operation on Kubernetes Provision

23. Init Container • What is Init Container • Sequentially executed containers in a pod • Initialize shared volumes • Always run to completion • Used on a pod, replica set, deployment, daemon set, pet set or job. Pod … Primary Init Container 1 Init Container 2 Container Shared Volumes

24. Init Container • Why Init Container • Waiting for other components to be available • Performing configuration • Registering the pod into a central database • Downloading application dependencies • …

25.Init Container

26. Pet Set • Pet vs Pod Pet Pod Stateful Stateless Identit No y Identity Complex Simple

27. Pet Set Pet PV/PVC Stable Storage • No Cluster IP Network Headless • DNS Record Identity Service Creation Ordinal Index Pet Set

28. Pet Set • PetSet Operations • Peer discovery • Scaling a PetSet • Image upgrades • Deleting a PetSet

29. Agenda • Background • Kubernetes Stateful Service Features • What is Kubernetes? • Init Container • Run stateful services • Pet Set on Kubernetes • Kubernetes Storage • Run MySQL Cluster on Kubernetes • Volume • Galera MySQL Introduction • Persistent Volume • Deploy MySQL Cluster with PetSet • Dynamic Storage • Cluster Operation on Kubernetes Provision