deploying mysql and mongodb in
play

Deploying MySQL and MongoDB in Kubernetes Alexander Rubin Percona - PowerPoint PPT Presentation

Deploying MySQL and MongoDB in Kubernetes Alexander Rubin Percona About me Working with MySQL for 10-15 years Started at MySQL AB, Sun Microsystems, Oracle (MySQL Consulting) Joined Percona in 2013 2 What is Kubernetes?


  1. Deploying MySQL and MongoDB in Kubernetes Alexander Rubin Percona

  2. About me ● Working with MySQL for 10-15 years ○ Started at MySQL AB, Sun Microsystems, Oracle (MySQL Consulting) ○ Joined Percona in 2013 2

  3. What is Kubernetes? Container orchestration system /* Operating system */ * Kubernetes is an open source system for managing containerized applications across multiple hosts 3

  4. Container orchestration 4

  5. Container Orchestration in Barcelona 5

  6. Why ? Deployment, Deployment, Deployment! ○ Challenge: how to deploy massively scaled application ○ Or databases: how do you deploy 100 nodes clustering system 6

  7. Kubernetes Implementations ● ● ● ● ● ● ● 7

  8. Let’s look under the hood 8

  9. ● ● ● ● ● ○

  10. Databases in Containers: Challenges 1. Preserving state 2. Setup as cluster/replication 12

  11. ● ○ ○

  12. Why for databases? 15

  13. MySQL In Kubernetes ● A single instance is easy ○ https://kubernetes.io/docs/tasks/run-application/run-single-instance-stateful-appli cation/ 16

  14. A complex setup is … more complex ● High Availability ● Persistent Storage ● Backup and recovery ● Traffic routing ● Monitoring 17

  15. 18

  16. Replication

  17. Replication Options ● Traditional MySQL replication ● Group Replication ● Percona XtraDB Cluster 20

  18. Traditional Replication challenges ● No automatic failover ○ New master detection can be quite complicated ● No automatic slave setup 21

  19. Group Replication ● Not mature enough ● Still no automatic slave setup 22

  20. What is Percona XtraDB Cluster (PXC)? 23

  21. Why PXC? Auto provisioning... 24

  22. PXC: Data transfer 25

  23. Storage

  24. Storage options ● Local storage ○ Can be fast (SSD, NVMe options) ○ Still limited management capabilities in Kubernetes ● Network storage ○ Management and Flexibility if supported by your setup Supported by major cloud providers ■ ○ On-premise setup may require Ceph or SAN ○ The dynamic provision of persistent volumes is required 27

  25. Traffic routing

  26. Traffic routing ● ProxySQL ○ High-performance MySQL proxy ○ Query Routing ○ Supports Failover 29

  27. What is ProxySQL? 30

  28. ProxySQL read/write split Query routing is one of the core features of ProxySQL. Read/write split is perhaps one of the most common query routing use 31

  29. ProxySQL read-write split 32

  30. PXC + ProxySQL on Kubernetes / Openshift 33

  31. Monitoring ● Percona Monitoring And Management 34

  32. Percona Labs - MySQL for Kubernetes https://github.com/Percona-Lab/percona-openshift $ git clone git@github.com:Percona-Lab/percona-openshift.git 35

  33. Deployment options

  34. Deployment options ● Manual ● Helm Charts ● Operator 37

  35. Manual ● Manual juggling multiple YAML files backup-volume.yaml mysql-configmap.yaml proxysql-pxc.yaml pxc.yaml secret.yaml xtrabackup-job.yaml ● Cumbersome and error-prone ● Practically not feasible for a complicated setup ● Deployment logic and configuration parameters are mixed together 38

  36. Helm Charts Helm - The package manager for Kubernetes ● Separate configuration from logic To continue “Kubernetes is an Operating System” analogy - Helm chart is like RPM/DEB packages 39

  37. Operator ● Method of packaging, deploying and managing a Kubernetes application ● The most advanced way of the deployment ● Requires software engineering efforts ● A way to think about “Operator” is it’s goal is to replace a human in typical operations ● Assumes a high degree of automation 40

  38. 41 * image: RedHat OpenShift documentation

  39. Demo: Let’s start our PXC cluster $ helm install --name cluster1 . -f values.yaml Will start: ● 3 nodes of Percona XtraDB Cluster, each with PMM Client ● ProxySQL instance Configure ProxySQL to route traffic 42

  40. $ kubectl get pods NAME READY STATUS RESTARTS AGE cluster1-node-0 2/2 Running 0 5m cluster1-node-1 2/2 Running 0 4m cluster1-node-2 2/2 Running 0 2m cluster1-proxysql-0 2/2 Running 0 5m monitoring-0 1/1 Running 0 16m 43

  41. Let’s take a minute here With a single command we ● Started multiple MySQL nodes (and Kubernetes will handle a node failure) ● Started and configured ProxySQL ● Added all nodes under PMM Server 44

  42. What’s so big deal about it? ● One can do it with reasonably simple Ansible playbooks? Kubernetes is Cloud-agnostic; provides an uniform API; “write once - run anywhere” approach 45

  43. Demo / Howto - pods $ kubectl get pods NAME READY STATUS RESTARTS cluster1-proxysql-0 2/2 Running 0 cluster1-node-0 2/2 Running 0 cluster1-node-1 2/2 Running 0 cluster1-node-2 2/2 Running 0 46

  44. Demo / Howto $ kubectl get services NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) cluster1-proxysql ClusterIP 10.11.251.66 <none> 3306/TCP,6032/TCP MySQL Port (for app) Proxy Admin Port 47

  45. ProxySQL Admin Configuration kubectl exec cluster1-proxysql-0 -it -- mysql -uadmin -padmin -h127.0.0.1 -P6032 mysql> select * from mysql_servers; +--------------+-----------+------+--------+---------+-------------+-----------------+----+---------+ | hostgroup_id | hostname | port | status | weight | compression | max_connections | .. | comment | +--------------+-----------+------+--------+---------+-------------+-----------------+----+---------+ | 10 | 10.8.2.10 | 3306 | ONLINE | 1000000 | 0 | 1000 | .. | WRITE | | 11 | 10.8.1.6 | 3306 | ONLINE | 1000 | 0 | 1000 | .. | READ | | 11 | 10.8.0.10 | 3306 | ONLINE | 1000 | 0 | 1000 | .. | READ | +--------------+-----------+------+--------+---------+-------------+-----------------+----+---------+ 48

  46. Let’s kill one pod… NAME READY STATUS RESTARTS AGE cluster1-node-0 0/2 Terminating 0 41m cluster1-node-1 2/2 Running 0 41m cluster1-node-2 2/2 Running 0 40m cluster1-proxysql-0 2/2 Running 0 41m monitoring-0 1/1 Running 0 35m 49

  47. Kubernetes will restart it mysql> select * from mysql_servers; +--------------+-----------+------+--------------+---------+-------------+-----------------+---------+ | hostgroup_id | hostname | port | status | weight | compression | max_connections | comment | +--------------+-----------+------+--------------+---------+-------------+-----------------+---------+ | 11 | 10.8.2.10 | 3306 | OFFLINE_HARD | 1000 | 0 | 1000 | READ | | 11 | 10.8.1.6 | 3306 | ONLINE | 1000 | 0 | 1000 | READ | | 10 | 10.8.0.10 | 3306 | ONLINE | 1000000 | 0 | 1000 | WRITE | | 11 | 10.8.2.12 | 3306 | ONLINE | 1000 | 0 | 1000 | READ | +--------------+-----------+------+--------------+---------+-------------+-----------------+---------+ 50

  48. Let’s scale it up kubectl scale --replicas=4 statefulset/cluster1-node statefulset "cluster1-node" scaled 51

  49. mysql> select * from mysql_servers; +--------------+-----------+------+--------------+---------+-------------+-----------------+---------+ | hostgroup_id | hostname | port | status | weight | compression | max_connections | comment | +--------------+-----------+------+--------------+---------+-------------+-----------------+---------+ | 11 | 10.8.2.10 | 3306 | OFFLINE_HARD | 1000 | 0 | 1000 | READ | | 11 | 10.8.1.6 | 3306 | ONLINE | 1000 | 0 | 1000 | READ | | 10 | 10.8.0.10 | 3306 | ONLINE | 1000000 | 0 | 1000 | WRITE | | 11 | 10.8.2.12 | 3306 | ONLINE | 1000 | 0 | 1000 | READ | | 11 | 10.8.1.7 | 3306 | ONLINE | 1000 | 0 | 1000 | READ | +--------------+-----------+------+--------------+---------+-------------+-----------------+---------+ 52

  50. Demo Failover 53

  51. The Road Ahead ● Operators ● Encryptions ○ At Rest ○ End-to-end ● Key Management 54

  52. Additional resources ● Oracle’s MySQL Operator (Alpha quality) https://github.com/oracle/mysql-operator ● Presslab’s Operator https://github.com/presslabs/mysql-operator ● MariaDB Helm https://github.com/mariadb-corporation/mariadb-kubernetes ● GRTL MySQL Operator https://github.com/grtl/mysql-operator 55

  53. Helm for MongoDB https://github.com/Percona-Lab/percona-server-mongodb-openshi ft/tree/master/helm/mongodb-replicaset Install Helm in OpenShift For the details see https://blog.openshift.com/getting-started-helm-openshift/ 56

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend