Skip to content

Commit d9ee39c

Browse files
github-actions[bot]discourse-gatekeeper-docs-bot
andauthored
[discourse-gatekeeper] Migrate charm docs (#262)
This pull request was autogenerated by discourse-gatekeeper to migrate existing documentation from server to the git repository. Co-authored-by: discourse-gatekeeper-docs-bot <[email protected]>
1 parent a0ef676 commit d9ee39c

23 files changed

+1026
-0
lines changed

docs/explanation/e-interfaces.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Interfaces/endpoints
2+
3+
MySQL Router K8s supports modern ['mysql_client'](https://github.com/canonical/charm-relation-interfaces) interface. Applications can easily connect MySQL using ['data_interfaces'](https://charmhub.io/data-platform-libs/libraries/data_interfaces) library from ['data-platform-libs'](https://github.com/canonical/data-platform-libs/).
4+
5+
### Modern `mysql_client` interface (`database` endpoint):
6+
7+
Adding a relation is accomplished with `juju relate` (or `juju integrate` for Juju 3.x) via endpoint `database`. Read more about [Juju relations (integrations)](https://juju.is/docs/olm/relations). Example:
8+
9+
```shell
10+
# Deploy Charmed MySQL K8s and MySQL Router K8s clusters with 3 nodes each
11+
juju deploy mysql-k8s -n 3 --trust
12+
juju deploy mysql-router-k8s -n 3 --trust --channel 8.0
13+
14+
# Deploy the relevant charms, e.g. mysql-test-app
15+
juju deploy mysql-test-app
16+
17+
# Relate all applications
18+
juju integrate mysql-k8s mysql-router-k8s
19+
juju integrate mysql-router-k8s:database mysql-test-app
20+
21+
# Check established relation (using mysql_client interface):
22+
juju status --relations
23+
24+
# Example of the properly established relation:
25+
# > Integration provider Requirer Interface Type Message
26+
# > mysql-k8s:database mysql-router-k8s:backend-database mysql_client regular
27+
# > mysql-router-k8s:database mysql-test-app:database mysql_client regular
28+
# > ...
29+
```
30+
31+
**Note:** In order to relate with Charmed MySQL K8s, every table created by the client application must have a primary key. This is required by the [group replication plugin](https://dev.mysql.com/doc/refman/8.0/en/group-replication-requirements.html) enabled in this charm.
32+
33+
See all the charm interfaces [here](https://charmhub.io/mysql-router-k8s/integrations).

docs/explanation/e-juju-details.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Juju tech details
2+
3+
[Juju](https://juju.is/) is an open source orchestration engine for software operators that enables the deployment, integration and lifecycle management of applications at any scale, on any infrastructure using charms.
4+
5+
This [charm](https://charmhub.io/mysql-router-k8s) is an operator - business logic encapsulated in reusable software packages that automate every aspect of an application's life. Charms are shared via [CharmHub](https://charmhub.io/).
6+
7+
See also:
8+
9+
* [Juju Documentation](https://juju.is/docs/juju) and [Blog](https://ubuntu.com/blog/tag/juju)
10+
* [Charm SDK](https://juju.is/docs/sdk)
11+
12+
## Breaking changes between Juju 2.9.x and 3.x
13+
14+
As this charm documentation is written for Juju 3.x, users of 2.9.x will encounter noteworthy changes when following the instructions. This section explains those changes.
15+
16+
Breaking changes have been introduced in the Juju client between versions 2.9.x and 3.x. These are caused by the renaming and re-purposing of several commands - functionality and command options remain unchanged.
17+
18+
In the context of this guide, the pertinent changes are shown here:
19+
20+
|2.9.x|3.x|
21+
| --- | --- |
22+
|**add-relation**|**integrate**|
23+
|**relate**|**integrate**|
24+
|**run**|**exec**|
25+
|**run-action --wait**|**run**|
26+
27+
See the [Juju 3.0 release notes](https://juju.is/docs/juju/roadmap#heading--juju-3-0-0---22-oct-2022) for the comprehensive list of changes.
28+
29+
The response is to therefore substitute the documented command with the equivalent 2.9.x command. For example:
30+
31+
### Juju 3.x:
32+
```shell
33+
juju integrate mysql-router-k8s:database mysql-test-app
34+
35+
juju run mysql-k8s/leader get-password
36+
```
37+
### Juju 2.9.x:
38+
```shell
39+
juju relate mysql-router-k8s:database mysql-test-app
40+
41+
juju run-action --wait mysql-k8s/leader get-password
42+
```
43+
> :tipping_hand_man: [The document based on OpenStack guide.](https://docs.openstack.org/charm-guide/latest/project/support-notes.html#breaking-changes-between-juju-2-9-x-and-3-x)

docs/explanation/e-statuses.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Charm Statuses
2+
3+
> :warning: **WARNING** : it is an work-in-progress article. Do NOT use it in production! Contact [Canonical Data Platform team](https://chat.charmhub.io/charmhub/channels/data-platform) if you are interested in the topic.
4+
5+
The charm follows [standard Juju applications statuses](https://juju.is/docs/olm/status-values#heading--application-status). Here you can find the expected end-users reaction on different statuses:
6+
7+
| Juju Status | Message | Expectations | Actions |
8+
|-------|-------|-------|-------|
9+
| **active** | any | Normal charm operations | No actions required |
10+
| **waiting** | any | Charm is waiting for relations to be finished | No actions required |
11+
| **maintenance** | any | Charm is performing the internal maintenance (e.g. re-configuration) | No actions required |
12+
| **blocked** | any | The manual user activity is required! | Follow the message hints (see below) |
13+
| **blocked** | Missing relation: ... | Normal behavior, charm needs all relations to work. | Follow the hint to establish a proper relation. |
14+
| **blocked** | Router was manually removed from MySQL ClusterSet. Remove & re-deploy unit | Scale-down temporary message OR split-brain for the unknown reason. | Wait to finish scale-down or remove and re-deploy unit if the message is persistent.|
15+
| **blocked** | ... app requested unsupported extra user role on database endpoint | Unsupported [role](https://charmhub.io/data-integrator/configure#extra-user-roles) requested. | Use supported extra-user-role. |
16+
| **blocked** | Upgrade incompatible. Rollback to previous revision with `juju refresh` | Incompatible charm channel/revision chosen. | [Rollback](/t/12239) the charm. |
17+
| **blocked** | Upgrading. Verify highest unit is healthy & run `resume-upgrade ` action. To rollback, `juju refresh` to last revision | Normal behavior, application is being upgraded and waiting for user confirmation to continue or rollback | [Continue upgrade](/t/12238) or [rollback](/t/12239). |
18+
| **error** | any | An unhanded internal error happened | Read the message hint and check the debug log to see the exception. Execute `juju resolve <error_unit/0>` after addressing the root of the error state |
19+
| **terminated** | any | The unit is gone and will be cleaned by Juju soon | No actions possible |
20+
| **unknown** | any | Juju doesn't know the charm app/unit status. Possible reason: K8s charm termination in progress. | Manual investigation required if status is permanent |
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Deploy MySQL Router K8s
2+
3+
Please follow the [MySQL Router K8s Tutorial](/t/12176) for technical details and explanations.
4+
5+
Short story for your Ubuntu 22.04 LTS (`Wordpress` used as an client example for `MySQL Router`:
6+
```shell
7+
sudo snap install multipass
8+
multipass launch --cpus 4 --memory 8G --disk 30G --name my-vm charm-dev # tune CPU/RAM/HDD accordingly to your needs
9+
multipass shell my-vm
10+
11+
juju add-model wordpress-demo
12+
juju deploy mysql-k8s --channel 8.0/stable --trust # --config profile=testing
13+
juju deploy mysql-router-k8s --channel 8.0/stable --trust
14+
15+
juju integrate mysql-k8s mysql-router-k8s
16+
17+
juju status --watch 1s
18+
```
19+
20+
The expected result:
21+
```shell
22+
Model Controller Cloud/Region Version SLA Timestamp
23+
wordpress-demo microk8s microk8s/localhost 3.1.6 unsupported 14:39:27+02:00
24+
25+
App Version Status Scale Charm Channel Rev Address Exposed Message
26+
mysql-k8s 8.0.34-0ubuntu0.22.04.1 active 1 mysql-k8s 8.0/stable 99 10.152.183.189 no
27+
mysql-router-k8s 8.0.34-0ubuntu0.22.04.1 blocked 1 mysql-router-k8s 8.0/stable 69 10.152.183.81 no Missing relation: database
28+
29+
Unit Workload Agent Address Ports Message
30+
mysql-k8s/0* active idle 10.1.12.61 Primary
31+
mysql-router-k8s/0* active idle 10.1.12.16
32+
```
33+
The charm MySQL Router K8s is now waiting for relations with a client application, e.g. [mysql-test-app](https://charmhub.io/mysql-test-app), [wordpress](https://charmhub.io/wordpress-k8s), ...
34+
35+
Check the [Testing](/t/12234) reference to test your deployment.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
[note]
2+
**Note**: All commands are written for `juju >= v.3.1`
3+
4+
If you're using `juju 2.9`, check the [`juju 3.0` Release Notes](https://juju.is/docs/juju/roadmap#heading--juju-3-0-0---22-oct-2022).
5+
[/note]
6+
7+
# How to enable TLS encryption
8+
9+
<!---[Update and add to explanation]
10+
MySQL Router will enable encrypted connections by default with self generated certificates. Though also by default, connecting clients can disable encryption by setting the connection ssl-mode as disabled.
11+
When related with the `tls-certificates-operator` the charmed operator for MySQL Router will require that every client connection (new and running connections) use encryption, rendering an error when attempting to establish an unencrypted connection.-->
12+
13+
This guide will show how to enable TLS using the [`self-signed-certificates` operator](https://github.com/canonical/self-signed-certificates-operator) as an example.
14+
15+
[note type="caution"]
16+
**[Self-signed certificates](https://en.wikipedia.org/wiki/Self-signed_certificate) are not recommended for a production environment.**
17+
18+
Check [this guide](/t/11664) for an overview of the TLS certificates charms available.
19+
[/note]
20+
21+
---
22+
23+
## Enable TLS
24+
25+
First, deploy the TLS charm:
26+
```shell
27+
juju deploy self-signed-certificates
28+
```
29+
To enable TLS, integrate the two applications:
30+
```shell
31+
juju integrate self-signed-certificates mysql-router-k8s
32+
```
33+
34+
## Manage keys
35+
36+
Updates to private keys for certificate signing requests (CSR) can be made via the `set-tls-private-key` action. Note that passing keys to external/internal keys should *only be done with* `base64 -w0`, *not* `cat`.
37+
38+
With three replicas, this schema should be followed:
39+
40+
Generate a shared internal (private) key:
41+
```shell
42+
openssl genrsa -out internal-key.pem 3072
43+
```
44+
45+
Apply the newly generated internal key on each `juju` unit:
46+
```shell
47+
juju run mysql-router-k8s/0 set-tls-private-key "internal-key=$(base64 -w0 internal-key.pem)"
48+
juju run mysql-router-k8s/1 set-tls-private-key "internal-key=$(base64 -w0 internal-key.pem)"
49+
juju run mysql-router-k8s/2 set-tls-private-key "internal-key=$(base64 -w0 internal-key.pem)"
50+
```
51+
52+
Updates can also be done with auto-generated keys with:
53+
54+
```shell
55+
juju run mysql-router-k8s/0 set-tls-private-key
56+
juju run mysql-router-k8s/1 set-tls-private-key
57+
juju run mysql-router-k8s/2 set-tls-private-key
58+
```
59+
60+
## Disable TLS
61+
Disable TLS by removing the integration:
62+
```shell
63+
juju remove-relation self-signed-certificates mysql-router-k8s
64+
```

docs/how-to/h-setup/h-manage-app.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# How to manage related applications
2+
3+
## Modern `mysql_client` interface:
4+
5+
Relations to new applications are supported via the "[mysql_client](https://github.com/canonical/charm-relation-interfaces/blob/main/interfaces/mysql_client/v0/README.md)" interface. To create a relation:
6+
7+
```shell
8+
juju relate mysql-router-k8s application
9+
```
10+
11+
To remove a relation:
12+
13+
```shell
14+
juju remove-relation mysql-router-k8s application
15+
```
16+
17+
All listed on CharmHub applications are available [here](https://charmhub.io/mysql-router-k8s/integrations), e.g.:
18+
* [mysql-test-app](https://charmhub.io/mysql-test-app)
19+
* [wordpress-k8s](https://charmhub.io/wordpress-k8s)
20+
* [slurmdbd](https://charmhub.io/slurmdbd)
21+
22+
## Legacy `mysql` interface:
23+
24+
This charm does NOT support legacy `mysql` interface.
25+
26+
## Internal operator user
27+
28+
To rotate the internal router passwords, the relation with backend-database should be removed and related again. That process will generate a new user and password for the application, while retaining the requested database and data.
29+
30+
```shell
31+
juju remove-relation mysql-k8s mysql-router-k8s
32+
33+
juju integrate mysql-k8s mysql-router-k8s
34+
```

docs/how-to/h-setup/h-manage-units.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# How to deploy and manage units
2+
3+
## Basic Usage
4+
5+
To deploy a single unit of MySQL Router using its default configuration
6+
```shell
7+
juju deploy mysql-router-k8s --channel 8.0 --trust
8+
```
9+
10+
To deploy MySQL Router in high-availability mode, specify the number of desired units with the `-n` option.
11+
```shell
12+
juju deploy mysql-router-k8s --channel 8.0 --trust -n <number_of_replicas>
13+
```
14+
15+
## Scaling
16+
17+
Both scaling-up and scaling-down operations are performed using `juju scale-application`:
18+
```shell
19+
juju scale-application mysql-router-k8s <desired_num_of_units>
20+
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Major Rollback
2+
3+
> :information_source: **Example**: MySQL Router 9.0 -> MySQL Router 8.0
4+
5+
Currently, the charm supports MySQL Router 8.0 only; therefore, minor rollbacks are only possible. Canonical is NOT planning to support in-place rollbacks for the major MySQL Router version change as the old MySQL cluster installation with old MySQL Router will stay nearby and can be reused for the rollback.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Minor Rollback
2+
3+
> :information_source: **Example**: MySQL Router 8.0.34 -> MySQL Router 8.0.33<br/>
4+
(including simple charm revision bump: from revision 43 to revision 42)
5+
6+
> **:warning: WARNING**: do NOT trigger `rollback` during the **running** `upgrade` action! It may cause unpredictable MySQL Cluster and/or MySQL Router state!
7+
8+
## Minor rollback steps
9+
1. **Rollback**. Perform the charm rollback using `juju refresh`. The unit with the maximal ordinal will be rolled back first, and the rollback will continue for the entire application.
10+
2. **Check**. Make sure the charm and cluster are in healthy state again.
11+
12+
## Manual Rollback
13+
14+
After a `juju refresh`, case there any version incompatibilities in charm revisions or it dependencies, or any other unexpected failure in the upgrade process, the upgrade process will be halted an enter a failure state.
15+
16+
Although the underlying MySQL Cluster and MySQL Router continue to work, it’s important to rollback the charm to previous revision so an update can be later attempted after a further inspection of the failure.
17+
18+
To execute a rollback we take the same procedure as the upgrade, the difference being the charm revision to upgrade to. In case of this tutorial example, one would refresh the charm back to revision `88`, the steps being:
19+
20+
## Step 1: Rollback
21+
22+
When using the charm from charmhub:
23+
24+
```shell
25+
juju refresh mysql-router-k8s --revision=88 --trust
26+
```
27+
28+
When deploying from a local charm file, you need to have the previous revision's `.charm` file and the `mysql-image` resource. Then, run:
29+
30+
```shell
31+
juju refresh mysql-router-k8s --trust --path=<path_to_charm_file> \
32+
--resource mysql-router-image=<image>
33+
```
34+
The resource reference can be found under the `upstream-source` key in the charm's `metadata.yaml` file. You can access this file by:
35+
* Simply unpacking the `.charm` file
36+
* Finding the corresponding [release](https://github.com/canonical/mysql-router-k8s-operator/releases) in the charm's GitHub repository and navigating to `metadata.yaml`.
37+
38+
After the refresh command, the `juju` controller revision for the application will be back in sync with the running MySQL Router K8s revision.
39+
40+
## Step 2: Check
41+
42+
Future [improvement are planned](https://warthogs.atlassian.net/browse/DPE-2620) to check the state on pod/cluster on a low level.
43+
44+
For now, use `juju status` to check the cluster [state](/t/11866).
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# MySQL Router K8s Upgrade
2+
3+
Please choose the appropriate upgrade/rollback tutorial.
4+
5+
Migration:
6+
7+
* [Major upgrade](/t/12236), e.g. MySQL Router 8.0 -> MySQL Router 9.0.
8+
9+
* [Major rollback](/t/12237), e.g. MySQL Router 9.0 -> MySQL Router 8.0.
10+
11+
In-place minor upgrade:
12+
13+
* [Minor upgrade](/t/12238), e.g. MySQL Router 8.0.33 -> MySQL Router 8.0.34<br/>
14+
(including charm revision bump 99 -> 102).
15+
16+
* [Minor rollback](/t/12239), e.g. MySQL Router 8.0.34 -> MySQL Router 8.0.33<br/>
17+
(including charm revision return 102 -> 99).

0 commit comments

Comments
 (0)