yury@u2004s01:~$ kubectl apply -f sample-cluster.yaml
The InnoDBCluster "mycluster" is invalid: spec.edition: Invalid value: "community": spec.edition in body should match '^(commercial|enterprise)$'
Oracle MYSQL Operator Summary
they wrote: The MySQL Operator for Kubernetes currently is in a preview state. DO NOT USE IN PRODUCTION.
(
set -x; cd "$(mktemp -d)" &&
OS="$(uname | tr '[:upper:]' '[:lower:]')" &&
ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')" &&
KREW="krew-${OS}_${ARCH}" &&
curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/${KREW}.tar.gz" &&
tar zxvf "${KREW}.tar.gz" &&
./"${KREW}" install krew
)
export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
Installing kubectl-moco using Krew
for u2004s01
kubectl krew update
kubectl krew install moco
Test kubectl-moco
yury@u2004s01:~$ kubectl moco
the utility command for MOCO.
Usage:
kubectl-moco [command]
Available Commands:
credential Fetch the credential of a specified user
help Help about any command
...
kubectl apply -f- <<EOF
apiVersion: moco.cybozu.com/v1beta2
kind: MySQLCluster
metadata:
namespace: default
name: test
spec:
# replicas is the number of mysqld Pods. The default is 1.
replicas: 3
podTemplate:
spec:
# Make the data directory writable. If moco-init fails with "Permission denied", uncomment the following settings.
# securityContext:
# fsGroup: 10000
# fsGroupChangePolicy: "OnRootMismatch" # available since k8s 1.20
# affinity:
# podAntiAffinity:
# requiredDuringSchedulingIgnoredDuringExecution:
# - labelSelector:
# matchExpressions:
# - key: app.kubernetes.io/name
# operator: In
# values:
# - mysql
# - key: app.kubernetes.io/instance
# operator: In
# values:
# - test
# topologyKey: "kubernetes.io/hostname"
containers:
# At least a container named "mysqld" must be defined.
- name: mysqld
image: quay.io/cybozu/mysql:8.0.27
# By limiting CPU and memory, Pods will have Guaranteed QoS class.
# requests can be omitted; it will be set to the same value as limits.
resources:
limits:
cpu: "2"
memory: "3Gi"
volumeClaimTemplates:
# At least a PVC named "mysql-data" must be defined.
- metadata:
name: mysql-data
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 3Gi
EOF
Here is a responce
error: unable to recognize "STDIN": no matches for kind "MySQLCluster" in version "moco.cybozu.com/v1beta2"
mysqlcluster.moco.cybozu.com/test created
yury@u2004s01:~$ kubectl get pods -n default -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
moco-test-0 3/3 Running 0 9m28s 10.32.105.6 u2004s03 <none> <none>
moco-test-1 3/3 Running 0 9m28s 10.32.121.133 u2004s04 <none> <none>
moco-test-2 3/3 Running 0 9m28s 10.32.27.204 u2004s02 <none> <none>
Test MOCO
Create Databse
for u2004s01
yury@u2004s01:~$ kubectl moco -n default mysql -it -u moco-writable test
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 261
Server version: 8.0.27 Source distribution
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> CREATE DATABASE MyTestDb;
Query OK, 1 row affected (0.28 sec)
mysql> quit
Bye
Show Databses
for u2004s01
yury@u2004s01:~$ kubectl moco -n default mysql -it --index 1 test
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 254
Server version: 8.0.27 Source distribution
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| MyTestDb |
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.05 sec)
mysql> quit
Bye
yury@u2004s01:~$ kubectl moco -n default mysql -it --index 3 test
Error: index should be smaller than replicas