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

deploying mysql and mongodb in
SMART_READER_LITE
LIVE PREVIEW

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?


slide-1
SLIDE 1

Deploying MySQL and MongoDB in Kubernetes

Alexander Rubin Percona

slide-2
SLIDE 2

2

About me

  • Working with MySQL for 10-15 years

○ Started at MySQL AB, Sun Microsystems, Oracle (MySQL Consulting) ○ Joined Percona in 2013

slide-3
SLIDE 3

3

What is Kubernetes?

Container orchestration system

/* Operating system */ * Kubernetes is an open source system for managing containerized applications across multiple hosts

slide-4
SLIDE 4

4

Container orchestration

slide-5
SLIDE 5

5

Container Orchestration in Barcelona

slide-6
SLIDE 6

6

Why ?

Deployment, Deployment, Deployment!

○ Challenge: how to deploy massively scaled application ○ Or databases: how do you deploy 100 nodes clustering system

slide-7
SLIDE 7

7

Kubernetes Implementations

slide-8
SLIDE 8

8

Let’s look under the hood

slide-9
SLIDE 9
slide-10
SLIDE 10
slide-11
SLIDE 11
slide-12
SLIDE 12

12

Databases in Containers: Challenges

1. Preserving state 2. Setup as cluster/replication

slide-13
SLIDE 13

slide-14
SLIDE 14
slide-15
SLIDE 15

15

Why for databases?

slide-16
SLIDE 16

16

MySQL In Kubernetes

  • A single instance is easy

○ https://kubernetes.io/docs/tasks/run-application/run-single-instance-stateful-appli cation/

slide-17
SLIDE 17

17

A complex setup is … more complex

  • High Availability
  • Persistent Storage
  • Backup and recovery
  • Traffic routing
  • Monitoring
slide-18
SLIDE 18

18

slide-19
SLIDE 19

Replication

slide-20
SLIDE 20

20

Replication Options

  • Traditional MySQL replication
  • Group Replication
  • Percona XtraDB Cluster
slide-21
SLIDE 21

21

Traditional Replication challenges

  • No automatic failover

○ New master detection can be quite complicated

  • No automatic slave setup
slide-22
SLIDE 22

22

Group Replication

  • Not mature enough
  • Still no automatic slave setup
slide-23
SLIDE 23

23

What is Percona XtraDB Cluster (PXC)?

slide-24
SLIDE 24

24

Why PXC? Auto provisioning...

slide-25
SLIDE 25

25

PXC: Data transfer

slide-26
SLIDE 26

Storage

slide-27
SLIDE 27

27

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

slide-28
SLIDE 28

Traffic routing

slide-29
SLIDE 29

29

Traffic routing

  • ProxySQL

○ High-performance MySQL proxy ○ Query Routing ○ Supports Failover

slide-30
SLIDE 30

30

What is ProxySQL?

slide-31
SLIDE 31

31

ProxySQL read/write split

Query routing is one of the core features of ProxySQL. Read/write split is perhaps

  • ne of the most common

query routing use

slide-32
SLIDE 32

32

ProxySQL read-write split

slide-33
SLIDE 33

33

PXC + ProxySQL on Kubernetes / Openshift

slide-34
SLIDE 34

34

Monitoring

  • Percona Monitoring

And Management

slide-35
SLIDE 35

35

Percona Labs - MySQL for Kubernetes

https://github.com/Percona-Lab/percona-openshift $ git clone git@github.com:Percona-Lab/percona-openshift.git

slide-36
SLIDE 36

Deployment options

slide-37
SLIDE 37

37

Deployment options

  • Manual
  • Helm Charts
  • Operator
slide-38
SLIDE 38

38

Manual

  • Manual juggling multiple YAML files
  • Cumbersome and error-prone
  • Practically not feasible for a complicated setup
  • Deployment logic and configuration parameters are mixed together

backup-volume.yaml mysql-configmap.yaml proxysql-pxc.yaml pxc.yaml secret.yaml xtrabackup-job.yaml

slide-39
SLIDE 39

39

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

slide-40
SLIDE 40

40

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
slide-41
SLIDE 41

41

* image: RedHat OpenShift documentation

slide-42
SLIDE 42

42

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

slide-43
SLIDE 43

43

$ 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

slide-44
SLIDE 44

44

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
slide-45
SLIDE 45

45

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

slide-46
SLIDE 46

46

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

slide-47
SLIDE 47

47

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

slide-48
SLIDE 48

48

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 | +--------------+-----------+------+--------+---------+-------------+-----------------+----+---------+

slide-49
SLIDE 49

49

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

slide-50
SLIDE 50

50

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 | +--------------+-----------+------+--------------+---------+-------------+-----------------+---------+

slide-51
SLIDE 51

51

Let’s scale it up

kubectl scale --replicas=4 statefulset/cluster1-node statefulset "cluster1-node" scaled

slide-52
SLIDE 52

52

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 | +--------------+-----------+------+--------------+---------+-------------+-----------------+---------+

slide-53
SLIDE 53

53

Demo Failover

slide-54
SLIDE 54

54

The Road Ahead

  • Operators
  • Encryptions

○ At Rest ○ End-to-end

  • Key Management
slide-55
SLIDE 55

55

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
slide-56
SLIDE 56

56

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/

slide-57
SLIDE 57

57

Operator

MongoDB server: Operator https://github.com/Percona-Lab/percona-server-mongodb-operator

slide-58
SLIDE 58

58

Conclusion

  • Openshift provides easy deployment for MySQL (Percona XtraDB Cluster)

○ Great for deployment and testing

  • ProxySQL provides the cluster endpoint

○ Implements read-write split

slide-59
SLIDE 59

59

Thank you!

slide-60
SLIDE 60

60

Thank You Sponsors!!