kubernetes生产实践之mysql

kubedb mysql 生命周期及特性

kubernetes生产实践之mysql

Supported MySQL Features Features Availability Clustering ✓ Persistent Volume ✓ Instant Backup ✓ Scheduled Backup ✓ Initialize using Snapshot ✓ Initialize using Script (*.sql, *sql.gz and/or *.sh) ✓ Custom Configuration ✓ Using Custom docker image ✓ Builtin Prometheus Discovery ✓ Using Prometheus operator ✓ 查看kubedb支持的mysql版本 [root@qd01-stop-k8s-master001 mysql]# kubectl get mysqlversions NAME VERSION DB_IMAGE DEPRECATED AGE 5.7.25-v1 5.7.25 kubedb/mysql:5.7.25-v1 17h 5.7.29 5.7.29 kubedb/mysql:5.7.29 17h 5.7.31 5.7.31 kubedb/mysql:5.7.31 17h 8.0.14-v1 8.0.14 kubedb/mysql:8.0.14-v1 17h 8.0.20 8.0.20 kubedb/mysql:8.0.20 17h 8.0.21 8.0.21 kubedb/mysql:8.0.21 17h 8.0.3-v1 8.0.3 kubedb/mysql:8.0.3-v1 17h 编写配置文件

mode: GroupReplication

kubernetes生产实践之mysql


group.name可以使用这个网站生成:https://www.uuidgenerator.net/version4

apiVersion: kubedb.com/v1alpha2 kind: MySQL metadata: name: mysql-group-test namespace: op spec: version: "8.0.21" replicas: 3 topology: mode: GroupReplication group: name: "d7f38430-d9ee-464b-af43-da9efa26fe02" baseServerID: 100 storageType: Durable storage: storageClassName: "rbd" accessModes: - ReadWriteOnce resources: requests: storage: 50Gi terminationPolicy: Halt 安装Mysql [root@qd01-stop-k8s-master001 mysql]# kubectl apply -f mysql-cluster-install.yaml mysql.kubedb.com/mysql-group-test created [root@qd01-stop-k8s-master001 mysql]# kubectl get po,ep,svc -n op NAME READY STATUS RESTARTS AGE pod/mysql-group-test-0 2/2 Running 0 14m pod/mysql-group-test-1 2/2 Running 0 9m41s pod/mysql-group-test-2 2/2 Running 0 4m19s NAME ENDPOINTS AGE endpoints/mysql-group-test 100.64.147.157:3306 14m endpoints/mysql-group-test-pods 100.64.122.198:3306,100.64.147.157:3306,100.98.174.219:3306 14m endpoints/mysql-group-test-standby 100.98.174.219:3306 14m NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/mysql-group-test ClusterIP 10.108.25.179 <none> 3306/TCP 14m service/mysql-group-test-pods ClusterIP None <none> 3306/TCP 14m service/mysql-group-test-standby ClusterIP 10.101.164.49 <none> 3306/TCP 14m

可以使用kubectl describe查看mysql集群详细信息

[root@qd01-stop-k8s-master001 mysql]# kubectl describe mysql mysql-group-test -n op Name: mysql-group-test Namespace: op Labels: <none> Annotations: <none> API Version: kubedb.com/v1alpha2 Kind: MySQL Metadata: Creation Timestamp: 2021-03-11T02:03:38Z Finalizers: kubedb.com Generation: 2 Managed Fields: API Version: kubedb.com/v1alpha2 Fields Type: FieldsV1 fieldsV1: f:metadata: f:annotations: .: f:kubectl.kubernetes.io/last-applied-configuration: f:spec: .: f:replicas: f:storage: .: f:accessModes: f:resources: .: f:requests: .: f:storage: f:storageClassName: f:storageType: f:terminationPolicy: f:topology: .: f:group: .: f:baseServerID: f:name: f:mode: f:version: Manager: kubectl-client-side-apply Operation: Update Time: 2021-03-11T02:03:38Z API Version: kubedb.com/v1alpha2 Fields Type: FieldsV1 fieldsV1: f:metadata: f:finalizers: f:spec: f:authSecret: .: f:name: f:status: .: f:conditions: f:observedGeneration: f:phase: Manager: operator Operation: Update Time: 2021-03-11T02:03:39Z Resource Version: 7283091 UID: 38d0b2c8-2d56-4fcf-ba3b-dff211d8a63d Spec: Auth Secret: Name: mysql-group-test-auth Pod Template: Controller: Metadata: Spec: Affinity: Pod Anti Affinity: Preferred During Scheduling Ignored During Execution: Pod Affinity Term: Label Selector: Match Labels: app.kubernetes.io/instance: mysql-group-test app.kubernetes.io/managed-by: kubedb.com app.kubernetes.io/name: mysqls.kubedb.com Namespaces: op Topology Key: kubernetes.io/hostname Weight: 100 Pod Affinity Term: Label Selector: Match Labels: app.kubernetes.io/instance: mysql-group-test app.kubernetes.io/managed-by: kubedb.com app.kubernetes.io/name: mysqls.kubedb.com Namespaces: op Topology Key: failure-domain.beta.kubernetes.io/zone Weight: 50 Resources: Limits: Cpu: 500m Memory: 1Gi Requests: Cpu: 500m Memory: 1Gi Service Account Name: mysql-group-test Replicas: 3 Storage: Access Modes: ReadWriteOnce Resources: Requests: Storage: 50Gi Storage Class Name: rbd Storage Type: Durable Termination Policy: Halt Topology: Group: Base Server ID: 100 Name: d7f38430-d9ee-464b-af43-da9efa26fe02 Mode: GroupReplication Version: 8.0.21 Status: Conditions: Last Transition Time: 2021-03-11T02:03:39Z Message: The KubeDB operator has started the provisioning of MySQL: op/mysql-group-test Reason: DatabaseProvisioningStartedSuccessfully Status: True Type: ProvisioningStarted Last Transition Time: 2021-03-11T02:21:17Z Message: All desired replicas are ready. Reason: AllReplicasReady Status: True Type: ReplicaReady Last Transition Time: 2021-03-11T02:03:49Z Message: The MySQL: op/mysql-group-test is accepting client requests. Observed Generation: 2 Reason: DatabaseAcceptingConnectionRequest Status: True Type: AcceptingConnection Last Transition Time: 2021-03-11T02:21:17Z Message: The MySQL: op/mysql-group-test is ready. Observed Generation: 2 Reason: ReadinessCheckSucceeded Status: True Type: Ready Last Transition Time: 2021-03-11T02:21:18Z Message: The MySQL: op/mysql-group-test is successfully provisioned. Observed Generation: 2 Reason: DatabaseSuccessfullyProvisioned Status: True Type: Provisioned Observed Generation: 2 Phase: Ready Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Successful 17m KubeDB Operator Successfully created governing service Normal Successful 17m KubeDB Operator Successfully created service for primary/standalone Normal Successful 17m KubeDB Operator Successfully created service for secondary replicas Normal Successful 17m KubeDB Operator Successfully created database auth secret Normal Successful 17m KubeDB Operator Successfully created StatefulSet Normal Successful 17m KubeDB Operator Successfully created appbinding Normal Successful 17m KubeDB Operator Successfully patched StatefulSet Normal Successful 17m KubeDB Operator Successfully patched StatefulSet Normal Successful 13m KubeDB Operator Successfully patched StatefulSet Normal Successful 11m KubeDB Operator Successfully patched StatefulSet Normal Successful 7m39s KubeDB Operator Successfully patched StatefulSet Normal Successful 102s KubeDB Operator Successfully patched StatefulSet Normal Successful 16s KubeDB Operator Successfully patched StatefulSet Normal Successful 16s KubeDB Operator Successfully patched StatefulSet Normal Successful 16s KubeDB Operator Successfully patched StatefulSet

从以上输出可以看到,集群部署完毕。

验证数据库

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wsfppz.html