kawasaki@k8s-1:~$ kubectl apply -f https://raw.githubusercontent.com/mysql/mysql-operator/trunk/deploy/deploy-crds.yaml
customresourcedefinition.apiextensions.k8s.io/innodbclusters.mysql.oracle.com created
customresourcedefinition.apiextensions.k8s.io/mysqlbackups.mysql.oracle.com created
customresourcedefinition.apiextensions.k8s.io/clusterkopfpeerings.zalando.org created
customresourcedefinition.apiextensions.k8s.io/kopfpeerings.zalando.org created
kawasaki@k8s-1:~$ kubectl apply -f https://raw.githubusercontent.com/mysql/mysql-operator/trunk/deploy/deploy-operator.yaml
clusterrole.rbac.authorization.k8s.io/mysql-operator created
clusterrole.rbac.authorization.k8s.io/mysql-sidecar created
clusterrolebinding.rbac.authorization.k8s.io/mysql-operator-rolebinding created
clusterkopfpeering.zalando.org/mysql-operator created
namespace/mysql-operator created
serviceaccount/mysql-operator-sa created
deployment.apps/mysql-operator created
kawasaki@k8s-1:~$ kubectl get deployment mysql-operator --namespace mysql-operator
NAME READY UP-TO-DATE AVAILABLE AGE
mysql-operator 1/1 1 1 4m36s
kawasaki@k8s-1:~$ kubectl create secret generic mypwds \
--from-literal=rootUser=root \
--from-literal=rootHost=% \
--from-literal=rootPassword="sakila"
secret/mypwds created
kawasaki@k8s-1:~$ vim mycluster.yaml
---
apiVersion: mysql.oracle.com/v2
kind: InnoDBCluster
metadata:
name: mycluster
spec:
secretName: mypwds
tlsUseSelfSigned: true
instances: 3
router: instances: 1
---
kawasaki@k8s-1:~$ kubectl apply -f mycluster.yaml
innodbcluster.mysql.oracle.com/mycluster created
kawasaki@k8s-1:~$ kubectl get innodbcluster --watch
NAME STATUS ONLINE INSTANCES ROUTERS AGE
mycluster PENDING 0 3 1 3m9s
ここでしばらく応答がなくなり…
kawasaki@k8s-1:~$ kubectl get innodbcluster --watch
The connection to the server 127.0.0.1:6443 was refused - did you specify the right host or port?
http://k8s-1.fms-dev.com:8080/#/dashboard 等を見てみるとそちらも落ちていたりとしばらく様子見 10分くらいたって自動的に復帰が行われ
kawasaki@k8s-1:~$ kubectl get innodbcluster
NAME STATUS ONLINE INSTANCES ROUTERS AGE
mycluster ONLINE 3 3 1 12m
になった。(しかし不安定なのか ONLINE ステータスが ONLINE_PARTIAL に戻る時がある)
kawasaki@k8s-1:~$ kubectl run --rm -it myshell --image=container-registry.oracle.com/mysql/community-operator -- mysqlsh root@mycluster --sql
If you don't see a command prompt, try pressing enter.
Please provide the password for 'root@mycluster': ******
Save password for 'root@mycluster'? [Y]es/[N]o/Ne[v]er (default No): No
MySQL Shell 8.2.0
Copyright (c) 2016, 2023, 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 '\?' for help; '\quit' to exit.
Creating a session to 'root@mycluster'
Fetching global names for auto-completion... Press ^C to stop.
Your MySQL connection id is 512 (X protocol)
Server version: 8.2.0 MySQL Community Server - GPL
No default schema selected; type \use <schema> to set one.
MySQL mycluster:33060+ ssl SQL > SELECT @@hostname;
+-------------+
| @@hostname |
+-------------+
| mycluster-0 |
+-------------+
1 row in set (0.0048 sec)
kawasaki@k8s-1:~$ kubectl get pods --namespace default
NAME READY STATUS RESTARTS AGE
mycluster-0 2/2 Running 1 (12m ago) 17m
mycluster-1 2/2 Running 0 17m
mycluster-2 2/2 Running 0 17m
mycluster-router-66d4796679-4jvlz 1/1 Running 0 5m58s
kawasaki@k8s-1:~$ kubectl get deployments --namespace default
NAME READY UP-TO-DATE AVAILABLE AGE
mycluster-router 1/1 1 1 17m