From: David Garcia Date: Fri, 12 Feb 2021 16:32:45 +0000 (+0100) Subject: Changes to mariadb charm X-Git-Tag: branch-sol006v331-start~47 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F09%2F10309%2F3;p=osm%2Fdevops.git Changes to mariadb charm - Modify metadata to fit the requirements of CharmHub - Improve the description of the actions - Change SVG icon - Improve the README Credit goes to Tom Haddon, that actually did the commit in lp, in a repo that is no longer maintained and will be soon removed Change-Id: Ic011d6b4d9cf07e5ef02a0e1ecead3ffdfbc3a45 Signed-off-by: David Garcia --- diff --git a/installers/charm/mariadb-k8s/README.md b/installers/charm/mariadb-k8s/README.md index a427fd4e..5c89de18 100755 --- a/installers/charm/mariadb-k8s/README.md +++ b/installers/charm/mariadb-k8s/README.md @@ -18,147 +18,61 @@ contact: legal@canonical.com To get in touch with the maintainers, please contact: osm-charmers@lists.launchpad.net --> -# Overview - -mysql for Kubernetes - -# Usage - -You must specify key configuration attributes when deploying, -or else arbitary defaults will be used. The attributes which -should be set are: -- user -- password -- database -- root_password - -eg - -$ juju deploy mysql \ -    --config user=fred \ -    --config password=secret \ -    --config database=test \ -    --config root_password=admin - -These values may also be in a config.yaml file, eg - -$ juju deploy mysql --config config.yaml - - -## Actions - -### Backup - -Execute the following steps to do a backup. - -```bash -$ juju run-action mariadb-k8s/0 backup --wait -unit-mariadb-k8s-0: - UnitId: mariadb-k8s/0 - id: "1" - results: - copy: - cmd: kubectl cp zaza-9769f2bf245e/mariadb-k8s-0:/var/lib/mysql/backup.sql.gz - backup.sql.gz - restore: - cmd: kubectl cp backup.sql.gz zaza-9769f2bf245e/mariadb-k8s-0:/var/lib/mysql/backup.sql.gz - juju: juju run-action mariadb-k8s/0 restore --wait - status: completed - timing: - completed: 2020-02-27 14:16:09 +0000 UTC - enqueued: 2020-02-27 14:16:08 +0000 UTC - started: 2020-02-27 14:16:09 +0000 UTC -$ kubectl cp zaza-9769f2bf245e/mariadb-k8s-0:/var/lib/mysql/backup.sql.gz backup.sql.gz -``` - -> Additional note: You can add `--string-args target=PRIMARY|SECONDARY` if you want this action to be run in a specific mongo unit. If `SECONDARY` is set, but the mongo unit isn't the `SECONDARY`, the action will fail. - -### Restore - -When the backup function is executed, you will see the commands you need to execute for restoring from a backup. - -```bash -$ kubectl cp backup.sql.gz zaza-9769f2bf245e/mariadb-k8s-0:/var/lib/mysql/backup.sql.gz -$ juju run-action mariadb-k8s/0 restore --wait -unit-mariadb-k8s-0: - UnitId: mariadb-k8s/0 - id: "2" - results: - message: Backup restored successfully - status: completed - timing: - completed: 2020-02-27 14:18:17 +0000 UTC - enqueued: 2020-02-27 14:18:07 +0000 UTC - started: 2020-02-27 14:18:11 +0000 UTC -``` - -### Remove backup - -When a backup is made, it is stored in the unit. To easily remove the backup, execute this action: - -```bash -$ juju run-action mariadb-k8s/0 remove-backup --wait -unit-mariadb-k8s-0: - UnitId: mariadb-k8s/0 - id: "3" - results: - Stdout: | - Backup successfully removed! - status: completed - timing: - completed: 2020-02-27 14:18:41 +0000 UTC - enqueued: 2020-02-27 14:18:36 +0000 UTC - started: 2020-02-27 14:18:41 +0000 UTC -``` - -## Backup remotely - -If we want to perform a backup remotely, follow the next steps: - -```bash -$ sudo apt install mariadb-client-10.1 -y -$ juju status mariadb-k8s -Model Controller Cloud/Region Version SLA Timestamp -zaza-9769f2bf245e microk8s-localhost microk8s/localhost 2.7.2 unsupported 15:20:42+01:00 - -App Version Status Scale Charm Store Rev OS Address Notes -mariadb-k8s rocks.canonical... active 2 mariadb-k8s local 0 kubernetes 10.152.183.109 - -Unit Workload Agent Address Ports Message -mariadb-k8s/0* active idle 10.1.31.185 3306/TCP,4444/TCP,4567/TCP,4568/TCP ready -mariadb-k8s/1 active idle 10.1.31.186 3306/TCP,4444/TCP,4567/TCP,4568/TCP ready -$ mysqldump -uroot -posm4u --single-transaction \ - --databases database \ - --host 10.152.183.109 \ - --port 3306 | gzip > backup.sql.gz -$ gunzip -c backup.sql.gz | mysql -uroot -posm4u --host 10.152.183.109 --port 3306 -``` - -> Note: The remote backups should be done for each database. If `--all-databases` is step, when restoring from a database, you will see this error: `ERROR 1556 (HY000) at line 825: You can't use locks with log tables` - -## Testing - -The tests of this charm are done using tox and Zaza. - -### Prepare environment - -The machine in which the tests are run needs access to a juju k8s controller. The easiest way to approach this is by executing the following commands: - -```bash -sudo apt install tox -y -sudo snap install microk8s --classic -sudo snap install juju - -microk8s.status --wait-ready -microk8s.enable storage dns - -juju bootstrap microk8s k8s-cloud -``` - -### Test charm with Tox - -```bash -tox -e black # Check syntax -tox -e build # Build the charm -tox -e func # Test charm -``` +# MariaDB Operator + +A Juju charm deploying and managing MariaDB on Kubernetes. + +## Overview + +MariaDB turns data into structured information in a wide array of +applications, ranging from banking to websites. Originally designed as +enhanced, drop-in replacement for MySQL, MariaDB is used because it is fast, +scalable and robust, with a rich ecosystem of storage engines, plugins and +many other tools make it very versatile for a wide variety of use cases. + +MariaDB is developed as open source software and as a relational database it +provides an SQL interface for accessing data. The latest versions of MariaDB +also include GIS and JSON features. + +More information can be found in [the MariaDB Knowledge Base](https://mariadb.com/kb/en/documentation/). + +## Usage + +For details on using Kubernetes with Juju [see here](https://juju.is/docs/kubernetes), and for +details on using Juju with MicroK8s for easy local testing [see here](https://juju.is/docs/microk8s-cloud). + +To deploy the charm into a Juju Kubernetes model: + + juju deploy cs:~charmed-osm/mariadb + +The charm can then be easily related to an application that supports the mysql +relation, such as: + + juju deploy cs:~charmed-osm/keystone + juju relate keystone mariadb-k8s + +Once the "Workload" status of both mariadb-k8s and keystone is "active", using +the "Application" IP of keystone (from `juju status`): + + # Change as appropriate for you juju model + KEYSTONE_APPLICATION_IP=10.152.183.222 + curl -i -H "Content-Type: application/json" -d ' + { "auth": { + "identity": { + "methods": ["password"], + "password": { + "user": { + "name": "admin", + "domain": { "id": "default" }, + "password": "admin" + } + } + } + } + ' "http://${KEYSTONE_APPLICATION_IP}:5000/v3/auth/tokens" ; echo + +This will create a token that you could use to query Keystone. + +--- + +For more details, [see here](https://charmhub.io/mariadb/docs/). diff --git a/installers/charm/mariadb-k8s/actions.yaml b/installers/charm/mariadb-k8s/actions.yaml index 0f11a292..0b33b6ab 100644 --- a/installers/charm/mariadb-k8s/actions.yaml +++ b/installers/charm/mariadb-k8s/actions.yaml @@ -20,14 +20,14 @@ ## backup: - description: "Do a mongodb backup" + description: "Perform a backup" params: path: description: "Path for the backup inside the unit" type: string default: "/var/lib/mysql" restore: - description: "Restore from a MongoDB Backup" + description: "Restore from a backup" params: path: description: "Path for the backup inside the unit" diff --git a/installers/charm/mariadb-k8s/icon.svg b/installers/charm/mariadb-k8s/icon.svg index 286fa17f..69b42ee0 100644 --- a/installers/charm/mariadb-k8s/icon.svg +++ b/installers/charm/mariadb-k8s/icon.svg @@ -10,220 +10,15 @@ xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="96" - height="96" - id="svg6517" version="1.1" - inkscape:version="0.48+devel r12304" - sodipodi:docname="MySQL.svg"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + id="svg3767" + width="640" + height="578" + viewBox="0 0 640 578" + sodipodi:docname="icon.svg" + inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)"> + id="metadata3773"> @@ -234,102 +29,317 @@ - - - - - - - + + + diff --git a/installers/charm/mariadb-k8s/metadata.yaml b/installers/charm/mariadb-k8s/metadata.yaml index 1b263a46..2823c61b 100755 --- a/installers/charm/mariadb-k8s/metadata.yaml +++ b/installers/charm/mariadb-k8s/metadata.yaml @@ -20,14 +20,15 @@ ## name: mariadb-k8s -summary: MySQL is a fast, stable and multi-user, multi-threaded SQL database +summary: MariaDB is a popular database server made by the developers of MySQL. +docs: https://discourse.charmhub.io/t/mariadb-documentation-overview/4116 maintainers: - - Juju Developers -description: | - MySQL is a fast, stable and true multi-user, multi-threaded SQL database - server. SQL (Structured Query Language) is the most popular database query - language in the world. The main goals of MySQL are speed, robustness and - ease of use. + - OSM Charmers +description: > + MariaDB Server is one of the most popular database servers in the world. + It's made by the original developers of MySQL and guaranteed to stay open + source. Notable users include Wikipedia, WordPress.com and Google. + https://mariadb.org/ tags: - database - openstack