Skip to content

Commit f2148a5

Browse files
Sync docs from Discourse (#221)
Sync charm docs from https://discourse.charmhub.io Co-authored-by: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 63e683f commit f2148a5

24 files changed

+518
-293
lines changed

docs/explanation/e-legacy-charm.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Legacy charms
2+
This page contains explanations regarding the legacy version of this charm. This includes clarification about Charmhub tracks, supported endpoints and interfaces, config options, and other important information.
3+
4+
## Summary
5+
* [Charm types: "legacy" vs. "modern"](#heading--charm-types)
6+
* [Default track `latest/` vs. track `1/`](#heading--default-track)
7+
* [How to migrate to the modern charm](#heading--how-to-migrate)
8+
* [How to deploy the legacy charm](#heading--how-to-deploy-legacy)
9+
* [Features supported by the modern charm](#heading--features-supported-by-modern)
10+
* [Config options](#heading--config-options)
11+
* [Extensions](#heading--extensions)
12+
* [Roles](#heading--roles)
13+
* [MySQL versions](#heading--postgresql-versions)
14+
* [Architectures](#heading--architectures)
15+
* [Contact us](#heading--contact-us)
16+
17+
---
18+
19+
<a href="#heading--charm-types"><h2 id="heading--charm-types"> Charm types: "legacy" vs. "modern" </h2></a>
20+
21+
There are [two types of charms](https://juju.is/docs/sdk/charm-taxonomy#heading--charm-types-by-generation) stored under the same charm name `mysql-router`:
22+
23+
1. [Reactive](https://juju.is/docs/sdk/charm-taxonomy#heading--reactive) charm in the channel `latest/stable`, `8.0/stable`, `8.0.19/stable` (called `legacy`)
24+
2. [Ops-based](https://juju.is/docs/sdk/ops) charm in the channel `dpe/candidate`, `8.4/edge` (called `modern`)
25+
26+
Both legacy and modern charms are [**subordinated**](https://juju.is/docs/sdk/charm-taxonomy#heading--subordinate-charms).
27+
28+
The legacy charm provided SQL endpoints `shared-db` (for the interface `mysql-shared`). The modern charm provides those old endpoint and a new endpoint `database` (for the interface `mysql_client`). Read more details about the available endpoints and interfaces [here](https://charmhub.io/mysql-router/docs/e-interfaces?channel=dpe/candidate).
29+
30+
**Note**: Please choose one endpoint to use. No need to relate all of them simultaneously!
31+
32+
<a href="#heading--default-track"><h2 id="heading--default-track"> Default track `latest/` vs. track `8.4/` </h2></a>
33+
34+
The [default track](https://docs.openstack.org/charm-guide/yoga/project/charm-delivery.html) will be switched from the `latest` to `8.4` soon. This is to ensure all new deployments use a modern codebase. We strongly advise against using the latest track, since a future charm upgrade may result in a MySQL Router version incompatible with an integrated application. Track `8.4/` guarantees a major router version 8.4 deployment only. The track `latest/` will be closed after all applications migrated from reactive to the ops-based charm.
35+
36+
37+
<a href="#heading--how-to-migrate"><h2 id="heading--how-to-migrate"> How to migrate to the modern charm </h2></a>
38+
39+
The modern charm provides temporary support for the legacy interfaces:
40+
41+
**Quick try**: relate the current application with new charm using endpoint `shared-db` (set the channel to `dpe/candidate`). No extra changes necessary:
42+
43+
```
44+
mysql-router:
45+
charm: mysql-router
46+
channel: dpe/candidate
47+
```
48+
49+
**Proper migration**: migrate the application to the new interface [`mysql_client`](https://github.com/canonical/charm-relation-interfaces). The application will connect MySQl Router using the [data_interfaces](https://charmhub.io/data-platform-libs/libraries/data_interfaces) library from [data-platform-libs](https://github.com/canonical/data-platform-libs/) via the endpoint `database`.
50+
51+
**Warning**: In-place upgrades are NOT possible! The reactive charm cannot be upgraded to the operator-framework-based one. The second/modern charm application must be launched nearby and relations should be switched from the legacy application to the modern one.
52+
53+
54+
<a href="#heading--how-to-deploy-legacy"><h2 id="heading--how-to-deploy-legacy"> How to deploy the legacy charm </h2></a>
55+
56+
Deploy the charm using the channel `latest/stable`:
57+
58+
```
59+
mysql-router:
60+
charm: mysql-router
61+
channel: 8.0/stable
62+
```
63+
64+
**Note**: remove Charm store prefix `cs:` from the bundle. Otherwise the modern charm will be chosen by Juju (due to the default track will be pointing to `8.4/stable` and not `latest/stable`). The common error message is: `cannot deploy application "mysql-router": unknown option "..."`.
65+
66+
<a href="#heading--features-supported-by-modern"><h2 id="heading--features-supported-by-modern"> Features supported by the modern charm </h2></a>
67+
This section goes over the key differences in feature support and functionality between the legacy and modern charm.
68+
69+
<a href="#heading--config-options"><h3 id="heading--config-options"> Config options </h3></a>
70+
71+
The legacy charm config options were not moved to the modern charm, since the modern charm applies the best possible configuration automatically. Feel free to [contact us](/t/12323?channel=dpe/candidate) about the MySQl Router config options.
72+
73+
<a href="#heading--extensions"><h3 id="heading--extensions"> Extensions </h3></a>
74+
75+
Both legacy and modern charms provide no plugins/extensions support.
76+
77+
<a href="#heading--postgresql-versions"><h3 id="heading--postgresql-versions"> MySQL versions </h3></a>
78+
79+
At the moment, the modern MySQL Router charm supports relation to the modern Charmed MySQL 8.0 (based on Jammy/22.04 series) only.
80+
Please [contact us](/t/12323?channel=dpe/candidate) if you need different versions/series.
81+
82+
<a href="#heading--architectures"><h3 id="heading--architectures"> Architectures </h3></a>
83+
84+
Currently, the modern charm supports architecture `amd64` and `arm64` only.
85+
86+
<a href="#heading--contact-us"><h2 id="heading--contact-us"> Report issues </h2></a>
87+
88+
The "legacy charm" (from `latest/stable`) is stored on [Launchpad](TODO). Report legacy charm issues [here](TODO).
89+
90+
The "modern charm" (from `dpe/candidate`) is stored on [GitHub](https://github.com/canonical/mysql-router-operator). Report modern charm issues [here](https://github.com/canonical/mysql-router-operator/issues/new/choose).
91+
92+
Do you have questions? [Reach out](/t/12323?channel=dpe/candidate) to us!
File renamed without changes.
File renamed without changes.

docs/how-to/h-enable-monitoring.md

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,54 @@
1-
# Enable monitoring
1+
[note]
2+
**Note**: All commands are written for [`juju >= v3.0`](https://juju.is/docs/juju/roadmap#heading--juju-3-0-0---22-oct-2022)
3+
[/note]
24

3-
> **:information_source: Hint**: Use [Juju 3](/t/5064). Otherwise replace `juju run ...` with `juju run-action --wait ...` and `juju integrate` with `juju relate` for Juju 2.9
5+
# How to enable monitoring with COS and Grafana
46

5-
Enabling monitoring requires that you:
6-
* [Have a Charmed MySQL and Charmed MySQLRouter deployed](https://charmhub.io/mysql-router/docs/t-deploy-charm?channel=dpe/edge)
7-
* [Deploy ‘cos-lite’ bundle in a Kubernetes environment](https://charmhub.io/topics/canonical-observability-stack/tutorials/install-microk8s)
7+
This guide goes over the steps to integrate your MySQL Router deployment with COS to enable monitoring in Grafana.
88

9-
Switch to the COS K8s environment and offer COS interfaces to be cross-model integrated (related) with Charmed MySQLRouter VM model:
9+
To learn about Alert Rules, see [Charmed MySQL > How to enable COS Alert Rules](https://charmhub.io/mysql/docs/h-enable-alert-rules).
1010

11+
## Prerequisites
12+
* Deployed [Charmed MySQL and Charmed MySQL Router](https://charmhub.io/mysql-router/docs/t-deploy-charm?channel=dpe/edge) operators
13+
* A deployed [‘cos-lite’ bundle in a Kubernetes environment](https://charmhub.io/topics/canonical-observability-stack/tutorials/install-microk8s)
14+
15+
## Summary
16+
* [Offer interfaces via the COS controller](#offer-interfaces-via-the-cos-controller)
17+
* [Consume offers via the MySQL Router model](#consume-offers-via-the-mysql-router-model)
18+
* [Deploy and integrate Grafana](#deploy-and-integrate-grafana)
19+
* [Connect to the Grafana web interface](#connect-to-the-grafana-web-interface)
20+
21+
---
22+
23+
## Offer interfaces via the COS controller
24+
25+
First, we will switch to the COS K8s environment and offer COS interfaces to be cross-model integrated with the Charmed MySQLRouter VM model.
26+
27+
To switch to the Kubernetes controller for the COS model, run
1128
```shell
12-
# Switch to the Kubernetes controller, in particular the COS model
1329
juju switch <k8s_controller>:<cos_model_name>
14-
30+
```
31+
To offer the COS interfaces, run
32+
```shell
1533
juju offer grafana:grafana-dashboard
1634
juju offer loki:logging
1735
juju offer prometheus:receive-remote-write
1836
```
1937

20-
Switch to the Charmed MySQLRouter VM model, find offers and integrate (relate) with them:
38+
## Consume offers via the MySQL Router model
39+
40+
Next, we will switch to the Charmed MySQL Router model, find offers, and consume them.
41+
42+
We are currently on the Kubernetes controller for the COS model. To switch to the MySQL Router model, run
2143

2244
```shell
23-
# We are on the Kubernetes controller, for the COS model. Switch to the MySQLRouter model
2445
juju switch <machine_controller_name>:<mysql_router_model_name>
25-
46+
```
47+
Display a list of available interfaces with the following command:
48+
```
2649
juju find-offers <k8s_controller>: # Do not miss ':' here
2750
```
28-
29-
A similar output should appear, if `k8s` is the k8s controller name and `cos` is the model where cos-lite has been deployed:
51+
In the sample output below, `k8s` is the k8s controller name and `cos` is the model where `cos-lite` has been deployed:
3052

3153
```shell
3254
Store URL Access Interfaces
@@ -35,29 +57,33 @@ k8s admin/cos.loki admin loki_push_api:logging
3557
k8s admin/cos.prometheus admin prometheus_remote_write:receive-remote-write
3658
```
3759

38-
Consume offers to be reachable in the current model:
60+
To consume offers to be reachable in the current model, run
3961

4062
```shell
4163
juju consume k8s:admin/cos.grafana
4264
juju consume k8s:admin/cos.loki
4365
juju consume k8s:admin/cos.prometheus
4466
```
4567

46-
Now deploy ‘[grafana_agent](https://charmhub.io/grafana-agent)’ (subordinate charm) alongside the Charmed MySQL Router application (also subordinate) and integrate (relate) it with Charmed MySQLRouter, then later integrate (relate) `grafana-agent `with the consumed COS offers:
68+
## Deploy and integrate Grafana
4769

70+
First, deploy [grafana-agent](https://charmhub.io/grafana-agent) and integrate it with the principal application for the subordinate MySQL Router app `<client_application>`: <!--TODO: Why not just use MySQL as example of principal? -->
4871
```shell
49-
# Assume <client_application> is the principal application for the subordinate mysql router application
5072
juju deploy grafana-agent
5173
juju integrate <client_application> grafana-agent
74+
```
75+
76+
Integrate (previously known as "[relate](https://juju.is/docs/juju/integration)") `grafana-agent` with the COS interfaces:
77+
```shell
5278
juju integrate grafana-agent mysql-router:cos-agent
5379
juju integrate grafana-agent grafana
5480
juju integrate grafana-agent loki
5581
juju integrate grafana-agent prometheus
5682
```
5783

58-
After this is complete, Grafana will show the new dashboards `MySQLRouter Exporter` and allows access for Charmed MySQLRouter logs on Loki.
84+
After this is complete, Grafana will show the new dashboards `MySQLRouter Exporter` and allows access for Charmed MySQL Router logs on Loki.
5985

60-
An example of `juju status` on the Charmed MySQLRouter VM model:
86+
Example of `juju status` on the Charmed MySQL Router VM model:
6187

6288
```shell
6389
ubuntu@localhost:~$ juju status
@@ -100,8 +126,9 @@ grafana 9.5.3 active 1 grafana-k8s stable 106 10.152.183.238 no
100126
loki 2.9.4 active 1 loki-k8s stable 124 10.152.183.84 no
101127
prometheus 2.49.1 active 1 prometheus-k8s stable 171 10.152.183.182 no
102128
```
129+
## Connect to Grafana web interface
103130

104-
To connect to the Grafana WEB interface, follow the COS section “[Browse dashboards](https://charmhub.io/topics/canonical-observability-stack/tutorials/install-microk8s#heading--browse-dashboards)”:
131+
To connect to the Grafana web interface, follow the [Browse dashboards](https://charmhub.io/topics/canonical-observability-stack/tutorials/install-microk8s?_ga=2.201254254.1948444620.1704703837-757109492.1701777558#heading--browse-dashboards) section of the MicroK8s "Getting started" guide.
105132

106133
```shell
107134
juju run grafana/leader get-admin-password --model <k8s_controller>:<cos_model_name>
File renamed without changes.

docs/how-to/h-external-access.md

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# Optimal MySQL Router Setup
2+
3+
For optimal performance, it is recommended that [MySQL Router](https://dev.mysql.com/doc/mysql-router/8.0/en/) is run alongside your application and that your application uses a Unix domain socket to connect to and execute queries against MySQL Router. The usage of a Unix domain socket here results in increased network performance due to the reduced network hops and in increased security due to the lack of exposed ports.
4+
5+
When your application implements the modern (preferred) interface in [MySQL Router's supported interfaces](https://discourse.charmhub.io/t/mysql-router-how-to-manage-app/12339) , the MySQL Router charm is deployed as a subordinate of your application charm and your application will be presented with a Unix domain socket, over the interface, to connect to MySQL Router.
6+
7+
## Accessing MySQL Router outside of Juju
8+
9+
A known limitation of relating with MySQL Router (a subordinate charm) is that your application would need to be deployed as a Juju application. However, if your application exists outside of the Juju ecosystem, you can access MySQL Router externally with the [Data Integrator](https://charmhub.io/data-integrator) charm.
10+
11+
### Example setup
12+
The steps below show you how to deploy and set up MySQL, MySQL Router, and Data Integrator for access outside of Juju.
13+
14+
First, deploy all the charms:
15+
```shell
16+
juju deploy mysql --channel 8.0/edge --trust
17+
juju deploy data-integrator --config database-name=test_database
18+
juju deploy mysql-router --channel dpe/edge
19+
```
20+
> Feel free to change `test_database` to your name of choice
21+
22+
Integrate:
23+
* `mysql` with `mysql-router`
24+
* `data-integrator` with `mysql-router`, since in this case we want to generate the credentials to access MySQL Router
25+
26+
```shell
27+
juju integrate mysql mysql-router
28+
juju integrate data-integrator mysql-router
29+
```
30+
31+
The following is a sample output of the `get-credentials` action run on a `data-integrator` unit:
32+
```shell
33+
juju run data-integrator/leader get-credentials
34+
```
35+
36+
```shell
37+
Running operation 1 with 1 task
38+
- task 2 on unit-data-integrator-0
39+
40+
Waiting for task 2...
41+
mysql:
42+
data: '{"database": "test_database", "external-node-connectivity": "true", "requested-secrets":
43+
"[\"username\", \"password\", \"tls\", \"tls-ca\", \"uris\"]"}'
44+
database: test_database
45+
endpoints: 10.205.193.235:6446
46+
password: mysupersecuredatabasepassword
47+
read-only-endpoints: 10.205.193.235:6447
48+
username: relation-9-8
49+
ok: "True"
50+
```
51+
52+
You can then connect to MySQL Router with the provided `endpoints` from your application that resides outside of Juju.
53+
54+
## Using a Virtual IP to connect to MySQL Router
55+
56+
If the MySQL Router charm is related to the Data Integrator charm, it is possible for a user to configure MySQL Router to use a certain Virtual IP. This assumes that the user has somehow ensured that the Virtual IP resolves to the node on which the MySQL Router charm is deployed.
57+
58+
To configure the MySQL Router charm with a virtual IP, run
59+
```shell
60+
juju config mysql-router/0 vip=<your_virtual_ip>
61+
```
62+
63+
### Integrate with HACluster
64+
65+
Alternatively, you can integrate with the [HACluster charm](https://charmhub.io/hacluster) if you would like a Virtual IP that is generated and maintained for you.
66+
67+
HACluster is a collection of solutions by [ClusterLabs](https://clusterlabs.org/) designed to create and manage resources. The creation of resources like Virtual IPs is handled by [Pacemaker](https://clusterlabs.org/pacemaker/), whereas the management of these resources is handled by [Corosync](https://clusterlabs.org/corosync.html).
68+
69+
Pacemaker will create and attach a Virtual IP to one of your Data Integrator nodes (that is related to MySQL Router), while Corosync will ensure automatic failover if the node with the Virtual IP faces connectivity or other issues. **This setup requires at least 3 Data Integrator nodes, each related to both MySQL Router and HACluster.**
70+
71+
[note type="warning"]
72+
**Warning**: The Virtual IP supplied to MySQL Router should be in the same subnet as the nodes on which the MySQL Router charm is running. Else, you may encounter unexpected behavior from the HACluster charm when it tries to create the Virtual IP.
73+
[/note]
74+
75+
#### Example setup
76+
The steps below show you how to deploy and set up MySQL, MySQL Router, Data Integrator, and HACluster.
77+
78+
First, deploy all the charms
79+
```shell
80+
juju deploy mysql --channel 8.0/edge --trust
81+
juju deploy -n 3 data-integrator --config database-name=test_database
82+
juju deploy mysql-router --channel dpe/edge
83+
juju deploy hacluster
84+
```
85+
> Note that the `data-integrator` requires a minimum of 3 nodes for this HACluster setup to work
86+
87+
Configure the VIP on `mysql-router`. Please ensure that the VIP is in an accessible subnet:
88+
```shell
89+
juju config mysql-router vip=10.205.193.35
90+
```
91+
92+
Then, integrate:
93+
* `mysql-router` with `mysql`
94+
* `mysql-router` and `hacluster` with `data-integrator`
95+
* `mysql-router` with `hacluster`
96+
97+
```
98+
juju integrate mysql-router mysql
99+
100+
juju integrate data-integrator mysql-router
101+
juju integrate data-integrator:juju-info hacluster:juju-info
102+
103+
juju integrate mysql-router hacluster
104+
```
105+
106+
The following is a sample output of the `get-credentials` action run on a `data-integrator` unit:
107+
```shell
108+
juju run data-integrator/leader get-credentials
109+
```
110+
```shell
111+
Running operation 1 with 1 task
112+
- task 2 on unit-data-integrator-0
113+
114+
Waiting for task 2...
115+
mysql:
116+
data: '{"database": "test_database", "external-node-connectivity": "true", "requested-secrets":
117+
"[\"username\", \"password\", \"tls\", \"tls-ca\", \"uris\"]"}'
118+
database: test_database
119+
endpoints: 10.205.193.35:6446
120+
password: mysupersecuredatabasepassword
121+
read-only-endpoints: 10.205.193.35:6447
122+
username: relation-12_cf668cc3521149-9
123+
ok: "True"
124+
125+
```
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)