운영 고가용성 및 인프라 확장성을 고민해본 Database 인프라 구성 

 - 인프라 구성 (Terraform)

 - Kubernetes (EKS & Kubeadm K8S)

 - CA 및 HPA  적용 고민

 - Cloud Native Storage 반영

 - 추가예정....

 

 

Kubernetes 의 MySQL Operator 의 대표적인 Operator 둘중 하나인 Percona 에서 개발한 Operator 이다. 

 

System Requitrements

 

Officially Supported Platforms

 

Percona XtraDB Cluster (PXC) 5.7 및 8.0 을 지원함

8.0의 Default 값인 "caching_sha2_password" 인증 플러그인은 ProxySQL 호환성 이유로 지원하지 않음

PXC 5.7 및 8.0 모두 "Default_authentication_plugin = mysql_native_password" 를 사용

 

PXC Operator 1.10.0

Openshift : 4.7 - 4.9

GKE : 1.19 - 1.22

EKS : 1.17 - 1.21

Minikube(kubeadm base) : 1.22 

 

위의 k8s platform 외 다른 platform 을 테스트가 되지 않았음

 

Resource Limits

 

officially platform 에서 3개의 node 가 필요함

 

2GB RAM

2 CPU threads per Node for Pods provisioning

영구 볼륨을 위한 60GB 공간의 Storage

 

 

Design Overview

 

Percona XtraDB Cluster 는 XtraDB Storage Engine 과 함께 실행되는 Pecona Server for MySQL 과 Pecona XtraBackup 을 Galera library 와 통합하여서 Multi-primary Sync 를 가능하게함

권장 구성은 최소 3개 노드를 갖는것, Percona XtraDB Cluster 는 고가용성을 제공한다. 

노드 하나가 중지되어도 계속 작동을 한다. 

ProxySQL 을 통해서 Client 에서 Server 로 Loadbalancer 를 제공함

 

ProxySQL 를 사용하지 않아도 가능하지만, ProxySQL 이 CSP 의 내장 LB 나 Nginx Ingress Controller 를 포함한 SQL 을 인지하지 못하는 다른 LB 와 비교하여서 더 효율적인 Database Workload 관리가 가능하다. 

 

고가용성 (High Availability) 을 제공하기 위하여서 node affinity 를 사용한다.  Node 가 Fails 되면 다른 Node 에 Pod 이 re-createed 된다. 

Stateful Application 을 제공하기 위해서 Kubernetes 는 영구볼륨을 제공하기 위해서  (PersistentVolumeClaim[PVC]) 를 사용하며, PVC 는 Pod 에 대해 Automatic Storage Provisioning 을 제공한다. 

장애가 발생하면, CSI 가 다른 노드에 Storage 를 다시 탑재할수 있어야함 PVC StorageClass 는 이기능을 지원해야함 (Kubernetes 1.9 이상, Openshift 3.9 이상)

 

Operator 기능은 PerconaXtraDBCluster Object로 Kubernetes API 를 확장하며, Golang Application 으로 구현을 함

PerconaXtraDBCluster Object 는 하나의 개별 Percona XtraDB Cluster 설정에 매핑됨(CRD, CR)

 

 

INSTALL

Minikube 설치 (최소 기능구현 용)

https://www.percona.com/doc/kubernetes-operator-for-pxc/minikube.html

 

[Operator 의 구성요소]

CRD

 - perconaxtradbclusters.pxc.percona.com

 - perconaxtradbclusterbackups.pxc.percona.com

 - perconaxtradbclusterrestores.pxc.percona.com

 - perconaxtradbbackups.pxc.percona.com

Role

 - percona-xtradb-cluster-operator

ServiceAccount

 - percona-xtradb-cluster-operator

RoleBinding

 - service-account-percona-xtradb-cluster-operator

Deployment

 - percona-xtradb-cluster-operator

 

[Operator 설치]

$ kubectl apply -f https://raw.githubusercontent.com/percona/percona-xtradb-cluster-operator/v1.10.0/deploy/bundle.yaml
customresourcedefinition.apiextensions.k8s.io/perconaxtradbclusters.pxc.percona.com created
customresourcedefinition.apiextensions.k8s.io/perconaxtradbclusterbackups.pxc.percona.com created
customresourcedefinition.apiextensions.k8s.io/perconaxtradbclusterrestores.pxc.percona.com created
customresourcedefinition.apiextensions.k8s.io/perconaxtradbbackups.pxc.percona.com created
role.rbac.authorization.k8s.io/percona-xtradb-cluster-operator created
serviceaccount/percona-xtradb-cluster-operator created
rolebinding.rbac.authorization.k8s.io/service-account-percona-xtradb-cluster-operator created
deployment.apps/percona-xtradb-cluster-operator created

 

$ kubectl get all -l app.kubernetes.io/name=percona-xtradb-cluster-operator
NAME                                                   READY   STATUS    RESTARTS   AGE
pod/percona-xtradb-cluster-operator-5ffc5b4fc5-cdfs5   1/1     Running   0          2m29s

NAME                                                         DESIRED   CURRENT   READY   AGE
replicaset.apps/percona-xtradb-cluster-operator-5ffc5b4fc5   1         1         1       2m29s

 

[Operator 를 통한 CR 설치]

$ kubectl apply -f https://raw.githubusercontent.com/percona/percona-xtradb-cluster-operator/v1.10.0/deploy/cr-minimal.yaml
perconaxtradbcluster.pxc.percona.com/minimal-cluster created

 

### Cluster initializing

$ kubectl get perconaxtradbcluster.pxc.percona.com/minimal-cluster
NAME              ENDPOINT                          STATUS         PXC   PROXYSQL   HAPROXY   AGE
minimal-cluster   minimal-cluster-haproxy.default   initializing                              54s

 

### Cluster 구성 완료

$ kubectl get perconaxtradbcluster.pxc.percona.com/minimal-cluster
NAME              ENDPOINT                          STATUS   PXC   PROXYSQL   HAPROXY   AGE
minimal-cluster   minimal-cluster-haproxy.default   ready    1                1         2m37s

 

### 특정 Label 로 생성된 리소스 확인

$ kubectl get all,pvc,pv -l app.kubernetes.io/managed-by=percona-xtradb-cluster-operator
NAME                            READY   STATUS    RESTARTS   AGE
pod/minimal-cluster-haproxy-0   2/2     Running   0          4m43s
pod/minimal-cluster-pxc-0       3/3     Running   0          4m43s

NAME                                       TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)                                 AGE
service/minimal-cluster-haproxy            ClusterIP   10.200.1.213   <none>        3306/TCP,3309/TCP,33062/TCP,33060/TCP   4m43s
service/minimal-cluster-haproxy-replicas   ClusterIP   10.200.1.32    <none>        3306/TCP                                4m43s
service/minimal-cluster-pxc                ClusterIP   None           <none>        3306/TCP,33062/TCP,33060/TCP            4m43s
service/minimal-cluster-pxc-unready        ClusterIP   None           <none>        3306/TCP,33062/TCP,33060/TCP            4m43s

NAME                                                  STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
persistentvolumeclaim/datadir-minimal-cluster-pxc-0   Bound    pvc-12224952-03d9-4843-ad08-1c3967683dad   6G         RWO            nfs-client     4m43s

 

### 초기 비밀번호 확인

$ kubectl get secret minimal-cluster-secrets -o yaml
apiVersion: v1
data:
  clustercheck: UmJNUU15T3RNRmhSMU1NNUQ0bg==
  monitor: VkxzOHJIZ0tOVFF4cWpuQlNKRA==
  operator: S24yUEdyZ0FSZlM4SU9DaUdaRQ==
  proxyadmin: VVRudlN4OGJIdjMxeExIaQ==
  replication: Um8xV1FLSUs3dXo2Qm1nT1c=
  root: OVNkRlZ6TFFwREFzQVVQZlda
  xtrabackup: bmxZcDAyT3FLTnIzUkdpclk=
kind: Secret
metadata:
  creationTimestamp: "2022-05-31T06:32:44Z"
  name: minimal-cluster-secrets
  namespace: default
  resourceVersion: "1552132"
  uid: ffa0521d-6ce1-4b22-ba56-d36d01b09900
type: Opaque

 

$ echo "OVNkRlZ6TFFwREFzQVVQZlda" | base64 -d
9SdFVzLQpDAsAUPfWZ

 

### MySQL Client 를 통한 접속 Test

$ kubectl run -i --rm --tty percona-client --image=percona:8.0 --restart=Never -- bash -il

If you don't see a command prompt, try pressing enter.
[mysql@percona-client /]$

 

### MySQL 접속 및 테스트 Query 수행

mysql -h minimal-cluster-haproxy -uroot -p9SdFVzLQpDAsAUPfWZ
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 814
Server version: 8.0.23-14.1 Percona XtraDB Cluster (GPL), Release rel14, Revision d3b9a1d, WSREP version 26.4.3

Copyright (c) 2009-2022 Percona LLC and/or its affiliates
Copyright (c) 2000, 2022, 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           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql>

 

Kubernetes 표준 설치

https://www.percona.com/doc/kubernetes-operator-for-pxc/kubernetes.html

 

### Git clone 을 통해 설치할 Kubernetes manifest  Download

$ git clone -b v1.10.0 https://github.com/percona/percona-xtradb-cluster-operator
Cloning into 'percona-xtradb-cluster-operator'...
remote: Enumerating objects: 38571, done.
remote: Counting objects: 100% (611/611), done.
remote: Compressing objects: 100% (357/357), done.
remote: Total 38571 (delta 340), reused 470 (delta 243), pack-reused 37960
Receiving objects: 100% (38571/38571), 32.64 MiB | 10.50 MiB/s, done.
Resolving deltas: 100% (23168/23168), done.
Note: switching to 'eb22b7f9c2756cf0bd6e53fe276cf36cfe318817'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

$ ls
minimal  percona-xtradb-cluster-operator
$ cd percona-xtradb-cluster-operator/

 

### Percona MySQL Operator CRD 배포 

$ kubectl apply -f deploy/crd.yaml
customresourcedefinition.apiextensions.k8s.io/perconaxtradbclusters.pxc.percona.com created
customresourcedefinition.apiextensions.k8s.io/perconaxtradbclusterbackups.pxc.percona.com created
customresourcedefinition.apiextensions.k8s.io/perconaxtradbclusterrestores.pxc.percona.com created
customresourcedefinition.apiextensions.k8s.io/perconaxtradbbackups.pxc.percona.com created

 

### pxc namespace 생성

$ kubectl create namespace pxc
namespace/pxc created

 

PS. 공식문서에서는 pxc namespace 를 default namespace 로 할당 후 작업을 진행하라고 되어있으나, context namespace 정의를 하지않고, 설치 시 namespace 를 지정하는것을 추가해서 작업진행하겠음

 

current namespace 를 수정하는 명령어 예시

$ kubectl config set-context $(kubectl config current-context) --namespace=pxc

 

### Percona XtraDB 에서 사용할 RBAC 배포

$ kubectl apply -f deploy/rbac.yaml
role.rbac.authorization.k8s.io/percona-xtradb-cluster-operator created
serviceaccount/percona-xtradb-cluster-operator created
rolebinding.rbac.authorization.k8s.io/service-account-percona-xtradb-cluster-operator created

 

PS. RBAC 설정을 하려면, kubectl 사용자가 Cluster admin role 이 있어야 함

ex) GCP 의 GKE 에서 권한을 부여하는 방법

$ kubectl create clusterrolebinding cluster-admin-binding --clusterrole=cluster-admin --user=$(gcloud config get-value core/account)

 

### Percona MySQL Operator 설치

$ kubectl apply -f deploy/operator.yaml -n pxc
deployment.apps/percona-xtradb-cluster-operator created

 

$ kubectl get pod -A -l app.kubernetes.io/name=percona-xtradb-cluster-operator -n pxc
NAMESPACE   NAME                                               READY   STATUS    RESTARTS   AGE
pxc     percona-xtradb-cluster-operator-5ffc5b4fc5-6clmq   1/1     Running   0          2m2s

 

### Percona MySQL 비밀번호 세팅 및 설치 (secret)

cat deploy/secrets.yaml
apiVersion: v1
kind: Secret
metadata:
  name: my-cluster-secrets
type: Opaque
stringData:
  root: root_password
  xtrabackup: backup_password
  monitor: monitory
  clustercheck: clustercheckpassword
  proxyadmin: admin_password
  pmmserver: admin
  operator: operatoradmin
  replication: repl_password

kubectl create -f deploy/secrets.yaml -n pxc
secret/my-cluster-secrets created

 

### Percona CRD 로 정의되어있는 CR (Custom Resource) 생성

$ kubectl apply -f deploy/cr.yaml -n pxc
perconaxtradbcluster.pxc.percona.com/cluster1 created

 

$ kubectl get all -A -l app.kubernetes.io/name=percona-xtradb-cluster
NAMESPACE   NAME                     READY   STATUS    RESTARTS   AGE
pxc         pod/cluster1-haproxy-0   2/2     Running   0          8m53s
pxc         pod/cluster1-haproxy-1   2/2     Running   0          6m28s
pxc         pod/cluster1-haproxy-2   2/2     Running   0          2m3s
pxc         pod/cluster1-pxc-0       3/3     Running   0          8m53s
pxc         pod/cluster1-pxc-1       3/3     Running   0          6m52s
pxc         pod/cluster1-pxc-2       3/3     Running   0          5m20s

NAMESPACE   NAME                                TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)                                 AGE
pxc         service/cluster1-haproxy            ClusterIP   10.200.1.30    <none>        3306/TCP,3309/TCP,33062/TCP,33060/TCP   8m53s
pxc         service/cluster1-haproxy-replicas   ClusterIP   10.200.1.223   <none>        3306/TCP                                8m53s
pxc         service/cluster1-pxc                ClusterIP   None           <none>        3306/TCP,33062/TCP,33060/TCP            8m53s
pxc         service/cluster1-pxc-unready        ClusterIP   None           <none>        3306/TCP,33062/TCP,33060/TCP            8m53s

 

$ kubectl get pod -n pxc
NAME                                               READY   STATUS    RESTARTS   AGE
cluster1-haproxy-0                                 2/2     Running   0          10m
cluster1-haproxy-1                                 2/2     Running   0          7m46s
cluster1-haproxy-2                                 2/2     Running   0          3m21s
cluster1-pxc-0                                     3/3     Running   0          10m
cluster1-pxc-1                                     3/3     Running   0          8m10s
cluster1-pxc-2                                     3/3     Running   0          6m38s
percona-xtradb-cluster-operator-5ffc5b4fc5-tds2s   1/1     Running   0          14m

 

### mysql-clent pod 를 통해 mysql 상태 확인

$ kubectl run -i --rm --tty percona-client --image=percona:8.0 --restart=Never -- bash -il

If you don't see a command prompt, try pressing enter.
[mysql@percona-client /]$ mysql -h cluster1-haproxy.pxc -uroot -proot_password

mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1493
Server version: 8.0.25-15.1 Percona XtraDB Cluster (GPL), Release rel15, Revision 8638bb0, WSREP version 26.4.3

Copyright (c) 2009-2022 Percona LLC and/or its affiliates
Copyright (c) 2000, 2022, 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           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.01 sec)

mysql>

 

 

Helm 설치

https://www.percona.com/doc/kubernetes-operator-for-pxc/helm.html

 

### Helm REPO 등록

$ helm repo add percona https://percona.github.io/percona-helm-charts/
$ helm repo update
"percona" has been added to your repositories
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "percona" chart repository
...Successfully got an update from the "nfs-subdir-external-provisioner" chart repository
Update Complete. ⎈Happy Helming!⎈

 

$ helm repo list
NAME                            URL
nfs-subdir-external-provisioner https://kubernetes-sigs.github.io/nfs-subdir-external-provisioner
percona                         https://percona.github.io/percona-helm-charts/

 

### Percona MySQL Operator CRD 설치

$ helm install my-op percona/pxc-operator
NAME: my-op
LAST DEPLOYED: Thu Jun  2 11:11:08 2022
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
1. pxc-operator deployed.
  If you would like to deploy an pxc-cluster set cluster.enabled to true in values.yaml
  Check the pxc-operator logs
    export POD=$(kubectl get pods -l app.kubernetes.io/name=pxc-operator --namespace default --output name)
    kubectl logs $POD --namespace=default

 

$ export POD=$(kubectl get pods -l app.kubernetes.io/name=pxc-operator --namespace default --output name)
$ kubectl logs $POD --namespace=default
{"level":"info","ts":1654135870.9073238,"logger":"cmd","msg":"Runs on","platform":"kubernetes","version":"v1.23.6"}
{"level":"info","ts":1654135870.9074643,"logger":"cmd","msg":"Git commit: 038082365e4e94cfdda40a20ce1b53fc098e5efb Git branch: release-1-10-0 Build time: 2021-11-17T16:46:03Z"}
{"level":"info","ts":1654135870.9074957,"logger":"cmd","msg":"Go Version: go1.17.3"}
{"level":"info","ts":1654135870.907549,"logger":"cmd","msg":"Go OS/Arch: linux/amd64"}
{"level":"info","ts":1654135870.907603,"logger":"cmd","msg":"operator-sdk Version: v0.19.4"}
{"level":"info","ts":1654135870.9077961,"logger":"leader","msg":"Trying to become the leader."}
{"level":"info","ts":1654135871.752309,"logger":"leader","msg":"No pre-existing lock was found."}
{"level":"info","ts":1654135871.7690983,"logger":"leader","msg":"Became the leader."}
{"level":"info","ts":1654135872.5740485,"logger":"controller-runtime.metrics","msg":"metrics server is starting to listen","addr":":8080"}
{"level":"info","ts":1654135872.5745153,"logger":"cmd","msg":"Registering Components."}
{"level":"info","ts":1654135875.3557,"logger":"controller-runtime.webhook","msg":"registering webhook","path":"/validate-percona-xtradbcluster"}
{"level":"info","ts":1654135875.3557413,"logger":"cmd","msg":"Starting the Cmd."}
{"level":"info","ts":1654135875.3569176,"logger":"controller-runtime.manager","msg":"starting metrics server","path":"/metrics"}
{"level":"info","ts":1654135875.3571787,"logger":"controller-runtime.webhook.webhooks","msg":"starting webhook server"}
{"level":"info","ts":1654135875.358168,"logger":"controller-runtime.certwatcher","msg":"Updated current TLS certificate"}
{"level":"info","ts":1654135875.3582811,"logger":"controller-runtime.webhook","msg":"serving webhook server","host":"","port":9443}
{"level":"info","ts":1654135875.357379,"logger":"controller-runtime.manager.controller.perconaxtradbclusterbackup-controller","msg":"Starting EventSource","source":"kind source: /, Kind="}
{"level":"info","ts":1654135875.3574393,"logger":"controller-runtime.manager.controller.perconaxtradbcluster-controller","msg":"Starting EventSource","source":"kind source: /, Kind="}
{"level":"info","ts":1654135875.3602195,"logger":"controller-runtime.certwatcher","msg":"Starting certificate watcher"}
{"level":"info","ts":1654135875.357489,"logger":"controller-runtime.manager.controller.perconaxtradbclusterrestore-controller","msg":"Starting EventSource","source":"kind source: /, Kind="}
{"level":"info","ts":1654135875.4586177,"logger":"controller-runtime.manager.controller.perconaxtradbclusterbackup-controller","msg":"Starting Controller"}
{"level":"info","ts":1654135875.4587562,"logger":"controller-runtime.manager.controller.perconaxtradbcluster-controller","msg":"Starting Controller"}
{"level":"info","ts":1654135875.4605482,"logger":"controller-runtime.manager.controller.perconaxtradbclusterrestore-controller","msg":"Starting Controller"}
{"level":"info","ts":1654135875.5589018,"logger":"controller-runtime.manager.controller.perconaxtradbclusterbackup-controller","msg":"Starting workers","worker count":1}
{"level":"info","ts":1654135875.558974,"logger":"controller-runtime.manager.controller.perconaxtradbcluster-controller","msg":"Starting workers","worker count":1}
{"level":"info","ts":1654135875.5611134,"logger":"controller-runtime.manager.controller.perconaxtradbclusterrestore-controller","msg":"Starting workers","worker count":1}

 

$ kubectl get pod
NAME                                  READY   STATUS    RESTARTS   AGE
my-op-pxc-operator-7578776fd6-wsnx9   1/1     Running   0          97s

### 설치

PS. 공식문서에 나온 설치는 가장 기본 옵션으로설치가 되는 부분이라 Helm 에서 설치가능한 옵션값에 대한 분석을 추가 로 진행하겠음

 

### 아래의 둘중 하나의 명령으로 설치 진행, 개인적으로 helm upgrade 으로 --install 파라미터를 추가해서 설치하는걸 즐겨한다. 

$ helm install my-db percona/pxc-db
$ helm upgrade --install my-db percona/pxc-db

 

Release "my-db" does not exist. Installing it now.
NAME: my-db
LAST DEPLOYED: Thu Jun  2 11:17:26 2022
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
1. To get a MySQL prompt inside your new cluster you can run:

    ROOT_PASSWORD=`kubectl -n default get secrets my-db-pxc-db -o jsonpath="{.data.root}" | base64 --decode`
    kubectl -n default exec -ti \
      my-db-pxc-db-pxc-0 -- mysql -uroot -p"$ROOT_PASSWORD"

2. To connect an Application running in the same Kubernetes cluster you can connect with:


$ kubectl run -i --tty --rm percona-client --image=percona --restart=Never \
  -- mysql -h my-db-pxc-db-proxysql.default.svc.cluster.local -uroot -p"$ROOT_PASSWORD"

 

### 설치 확인

$ kubectl get all -A -l app.kubernetes.io/name=percona-xtradb-cluster
NAMESPACE   NAME                         READY   STATUS    RESTARTS   AGE
default     pod/my-db-pxc-db-haproxy-0   2/2     Running   0          11m
default     pod/my-db-pxc-db-haproxy-1   2/2     Running   0          6m49s
default     pod/my-db-pxc-db-haproxy-2   2/2     Running   0          6m28s
default     pod/my-db-pxc-db-pxc-0       3/3     Running   0          11m
default     pod/my-db-pxc-db-pxc-1       3/3     Running   0          6m53s
default     pod/my-db-pxc-db-pxc-2       3/3     Running   0          2m45s

NAMESPACE   NAME                                    TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)                                 AGE
default     service/my-db-pxc-db-haproxy            ClusterIP   10.200.1.250   <none>        3306/TCP,3309/TCP,33062/TCP,33060/TCP   11m
default     service/my-db-pxc-db-haproxy-replicas   ClusterIP   10.200.1.62    <none>        3306/TCP                                11m
default     service/my-db-pxc-db-pxc                ClusterIP   None           <none>        3306/TCP,33062/TCP,33060/TCP            11m
default     service/my-db-pxc-db-pxc-unready        ClusterIP   None           <none>        3306/TCP,33062/TCP,33060/TCP            11m

 

### Root 비밀번호 Secret 에서 추출하여서 변수입력

$ ROOT_PASSWORD=`kubectl -n default get secrets my-db-pxc-db -o jsonpath="{.data.root}" | base64 --decode`

 

### pxc percona cluster 에 직접 접근 확인

$ kubectl exec -ti my-db-pxc-db-pxc-0 -c pxc -- mysql -uroot -p"$ROOT_PASSWORD"

mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8295
Server version: 8.0.25-15.1 Percona XtraDB Cluster (GPL), Release rel15, Revision 8638bb0, WSREP version 26.4.3

Copyright (c) 2009-2021 Percona LLC and/or its affiliates
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           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql> exit

 

 

### pxc haproxy service 를 통한 pxc cluster 접근 확인

$ kubectl run -i --tty --rm percona-client --image=percona --restart=Never -- mysql -h my-db-pxc-db-haproxy.default.svc.cluster.local -uroot -p"$ROOT_PASSWORD"
If you don't see a command prompt, try pressing enter.
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.01 sec)

mysql> exit
Bye
pod "percona-client" deleted

 

 

 

설치구성 및 여러가지 설정 분석

+ Recent posts