Operator Lifecycle Manager: Creating and using an Operator-managed database server

Deploy a MariaDB Server *operand* by creating the MariaDB manifest.

cat > mariadb-cr.yaml <<EOF
apiVersion: mariadb.persistentsys/v1alpha1
kind: MariaDB
metadata:
  name: mariadb
spec:
  database: test-db
  username: db-user
  password: db-user
  rootpwd: password
  size: 1
  image: 'mariadb/server:10.3'
  dataStoragePath: /mnt/data
  dataStorageSize: 1Gi
EOF

Create the MariaDB Custom Resource:

kubectl create -f mariadb-cr.yaml

The MariaDB Operator should now begin to generate the MariaDB resources:

kubectl get deployments
kubectl get secrets
kubectl get services

Run a mysql client pod, from which you can connect to the mariadb service:

kubectl run mycli -i -t --rm --restart=Never --image=mysql -- /bin/bash

You'll be presented with the shell prompt of a new container with mysql tools installed. Run the mysql client to connect to your Operator-managed MariaDB server:

mysql -h mariadb-service --port 80 -u db-user --password=db-user

Now you're presented with the MariaDB/MySQL Monitor command prompt. You can run the usual SQL queries here:

show databases;
use test-db;
show tables;
CREATE TABLE t1 (
    c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    c2 VARCHAR(100),
    c3 VARCHAR(100) );
show status;