Skip to content
This repository was archived by the owner on May 28, 2021. It is now read-only.

Commit 0306087

Browse files
prydieowainlewis
authored andcommitted
Update router documentation (#206)
Fixes: #194
1 parent 0b9e7bb commit 0306087

File tree

1 file changed

+18
-83
lines changed

1 file changed

+18
-83
lines changed

docs/user/router.md

Lines changed: 18 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
# Using the MySQL Router
22

3-
When connecting your applications to MySQL clusters created by the MySQL Operator, we recommend that you use the [MySQL Router][1].
3+
When connecting your applications to MySQL clusters created by the MySQL
4+
Operator, we recommend that you use the [MySQL Router][1].
45

5-
> The MySQL Router is part of InnoDB cluster, and is lightweight middleware that provides transparent routing between your application and back-end MySQL Servers. It can be used for a wide variety of use cases, such as providing high availability and scalability by effectively routing database traffic to appropriate back-end MySQL Servers. The pluggable architecture also enables developers to extend MySQL Router for custom use cases.
6+
> The MySQL Router is part of InnoDB cluster, and is lightweight middleware that
7+
> provides transparent routing between your application and back-end MySQL
8+
> Servers. It can be used for a wide variety of use cases, such as providing
9+
> high availability and scalability by effectively routing database traffic to
10+
> appropriate back-end MySQL Servers. The pluggable architecture also enables
11+
> developers to extend MySQL Router for custom use cases.
612
713
## Configuration
814

@@ -14,103 +20,32 @@ Typically the MySQL Router is deployed [alongside your application][2].
1420

1521
### Create a MySQL Cluster
1622

17-
We'll use WordPress as an example of how you might setup the MySQL Router for a a real application. The first thing we want to do is create our MySQL Cluster using the operator.
18-
19-
```yaml
20-
apiVersion: "mysql.oracle.com/v1alpa1"
21-
kind: Cluster
22-
metadata:
23-
name: mysql-wordpress
24-
spec:
25-
members: 3
26-
secretRef:
27-
name: wordpress-mysql-root-password
28-
```
23+
We'll use WordPress as an example of how you might setup the MySQL Router for a
24+
real application. The first thing we want to do is create our MySQL Cluster
25+
using the operator.
2926

30-
Create this with
27+
Create this with:
3128

3229
```
3330
kubectl apply -f examples/demo/wordpress-router/wordpress-database.yaml
3431
```
3532

3633
### Create an application + router
3734

38-
We'll create a standard WordPress application but connect directly to the MySQL Router which runs as a sidecar container alongside inside your Wordpress pod.
39-
40-
```yaml
41-
---
42-
apiVersion: v1
43-
kind: Service
44-
metadata:
45-
name: wordpress-router
46-
labels:
47-
app: wordpress-router
48-
spec:
49-
ports:
50-
- port: 80
51-
selector:
52-
app: wordpress-router
53-
type: LoadBalancer
54-
---
55-
apiVersion: extensions/v1beta1
56-
kind: Deployment
57-
metadata:
58-
name: wordpress-router
59-
labels:
60-
app: wordpress-router
61-
spec:
62-
strategy:
63-
type: Recreate
64-
template:
65-
metadata:
66-
labels:
67-
app: wordpress-router
68-
spec:
69-
containers:
70-
- name: mysqlrouter
71-
image: pulsepointinc/mysql-router:2.1.3
72-
env:
73-
- name: MYSQL_ROOT_PASSWORD
74-
valueFrom:
75-
secretKeyRef:
76-
name: wordpress-mysql-root-password
77-
key: password
78-
command:
79-
- "/bin/bash"
80-
- "-cx"
81-
- |
82-
echo "Bootstraping the router"
83-
echo $MYSQL_ROOT_PASSWORD | mysqlrouter --bootstrap mysql-wordpress-0.mysql-wordpress:3306 --user=root
84-
85-
echo "Updating resolv.conf"
86-
search=$(grep ^search /etc/resolv.conf)
87-
echo "$search mysql-wordpress.default.svc.cluster.local" >> /etc/resolv.conf
88-
89-
echo "Running the router"
90-
mysqlrouter --user=root
91-
- name: wordpress
92-
image: wordpress:4.8.0-apache
93-
env:
94-
- name: WORDPRESS_DB_HOST
95-
value: 127.0.0.1:6446
96-
- name: WORDPRESS_DB_PASSWORD
97-
valueFrom:
98-
secretKeyRef:
99-
name: wordpress-mysql-root-password
100-
key: password
101-
ports:
102-
- containerPort: 80
103-
```
35+
We'll create a standard WordPress application but connect directly to the MySQL
36+
Router which runs as a sidecar container alongside inside your Wordpress Pod.
10437

105-
Create this with
38+
Create this with:
10639

10740
```
10841
kubectl apply -f examples/demo/wordpress-router/wordpress-deployment.yaml
10942
```
11043

11144
### Verify
11245

113-
If you used a LoadBalancer service to expose your WordPress deployment, you can visit the load balancer IP address and verify your deployment successfully connects to your MySQL cluster.
46+
If you used a Service type=LoadBalancer to expose your WordPress deployment,
47+
you can visit the load balancer IP address and verify your deployment
48+
successfully connects to your MySQL cluster.
11449

11550
[1]: https://dev.mysql.com/doc/mysql-router/2.1/en/
11651
[2]: https://dev.mysql.com/doc/mysql-router/2.1/en/mysql-router-general-using-deploying.html

0 commit comments

Comments
 (0)