KubeSphere learning---Mysql middleware installation and deployment actual combat

insert image description here

foreword

The previous article explained the multi-tenant system of KubeSphere, and created many users and many projects. Among them, we selected: "dev-zhao" user and "his" project to deploy and learn middleware.

Elements that need attention in application deployment

Because here my KubeSphere is deployed based on Kubernetes. Then when we deploy middleware, it is the same as on Kubernetes, for example:
1. Application deployment method: Are you using stateless workloads? Or stateful loads? Or is it a daemon-style load? Make
stateless load: suitable for deploying Nginx, Httpd, etc. that do not require backend data storage.
Stateful load: for deploying Mysql and Redis, it needs to be suitable for connecting to the storage behind it. For example, if a mysql Pod is down, the data stored behind it is still there, and then we create a Mysql in the transmission, which can automatically connect to the back data storage.
Daemon process set: suitable for log collection tools, which need to be deployed on each node Pod, and then multiple log collection Pods merge data and send it to the back-end xxx platform.

2. Application data mounting: We know that it is necessary to store volumes on Kubernetes, so we can implement it through KubeSphere

3. Accessibility of the application: After deploying the workload, we need to create a Service for many Pods to achieve user access, or access to the internal components of the cluster, or, if you want to create a total traffic entrance for the entire Kubernetes, You can also create Ingress

The above three are the three major elements of deploying middleware on KubeSphere. In fact, it is the same as Kubernetes deployment, and it is more convenient to operate on KubeSphere.

The above relationship is as follows:
insert image description here

Illustrate the elements of KubeSphere deployment components

First use dev-zhao (you can create an account at will), enter the his project:
insert image description here

Deploy MySQL

Before deploying, let's think about it first: How many of the above three elements need to be met when deploying Mysql? (1), first of all, Mysql stores data, we need to hang the data
there
.
(3) We need a load. Since Mysql needs a place to store data, we implement it with a stateful workload.

docker run -p 3306:3306 --name mysql-01 \
-v /mydata/mysql/log:/var/log/mysql \
-v /mydata/mysql/data:/var/lib/mysql \
-v /mydata/mysql/conf:/etc/mysql/conf.d \
-e MYSQL_ROOT_PASSWORD=root \
--restart=always \
-d mysql:5.7 

insert image description here
1. Implement ConfigMap, enter his project, find "Configuration Center------>Configuration" in the list on the left, and click "Create".
insert image description here
insert image description here

In this way, the ConfigMap is configured.

2. Create a PVC, and the user stores Mysql data.
Enter the his project, find "Storage Management------>Storage Volume" in the list on the left, and click "Create".
insert image description here
insert image description here
The advanced options do not need to be set
, so that the Mysql persistent storage PVC is created.

3. Create a stateful load
Enter the his project, in the list on the left, find "Application Load ------> Workload ------> Stateful Replica Set", and then click "Create".
insert image description here
The following configuration is more important:
insert image description here

insert image description here
Set the Pod to the key PVC volume just now, and associate the ConfigMap just created
insert image description here

and click "Create":
insert image description here

Detection effect

1. Enter into the Mysql Pod and log in to Mysql
-h is used with DNS resolution provided by the Service
insert image description here

2. Enter the terminal of this container and view the my.cnf file
insert image description here

insert image description here
If you want to modify it later, just find the "Edit" option to modify it, and it will automatically synchronize the modified configuration information.
Of course, we can also check it on the Kubernetes platform

[root@k8s-master ~]# kubectl get pods -A | grep mysql
his                            his-mysql-0                                                       1/1     Running     0          9m30s

Now, the Mysql Pod is created, but we cannot access the Mysql service outside the cluster, so we need to set up the Mysql network—Service.

Deploy Mysql load balancing network

Create in "Service"
1. Let's first create a Service within the cluster.
insert image description here
insert image description here
At this time, the DNS domain name becomes our own designation.

2. To create a Service for external access to the cluster
insert image description here

Summarize

In this way, the related operations on Mysql are completed, and the steps are the same when deploying other middleware in the future.

Guess you like

Origin blog.csdn.net/m0_57776598/article/details/124063782