X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=installers%2Fcharm%2Fmariadb-k8s%2FREADME.md;h=5c89de184d438e521b5178adb39a083bb9d934a0;hb=d40d1434334bccc62d8cf1c375298d7cb653ffd5;hp=a427fd4e6e7415c3288310c8e9062e4a00a98a20;hpb=90d10f5dc85d577c7cec2d608b19a23120df1281;p=osm%2Fdevops.git 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/).