Overview
To learn about how to quickly create WordPress services, you can refer to Creating a WordPress Service. WordPress services created in this way have the following features:
- Data is written to the MySQL databases running on the same container.
- Services can be quickly launched.
- Databases and storage-type files will be lost if the container is stopped for certain reasons.
Using MySQL databases can ensure permanent storage of data. The databases will continue to run when the pod/container restarts. This document explains how to configure the MySQL database using TencentDB and how to create a WordPress service that uses TencentDB.
Prerequisites
Directions
Creating a WordPress service
Creating a TencentDB instance
- Log in to the TencentDB for MySQL console, and click Create in the database instance list, as shown in the figure below.
- Select the configuration to purchase. For more information, see Overview.
Note:
The database must be in the same region as that of the cluster. Otherwise, you will be unable to connect to the database.
- After creating the database, you can view it in the MySQL instance list.
- Initialize the database. For details, see Initializing MySQL database.
Creating a WordPress service that uses Tencent DB
- Log in to the TKE console and select Cluster in the left sidebar.
- On the Cluster Management page, click the ID of the target cluster to go to the cluster details page.
- On the Workload > Deployment page, click Create. For more information, see Creating a Deployment.
- On the Create Deployment page, specify basic information of the workload as instructed in the figure below.
- Workload Name: enter the name of the workload to create. In this example,
wordpress
is used.
- Description: specify related workload information.
- Labels: the default value is
k8s-app = wordpress
in this example.
- Namespace: select a namespace based on your requirements.
- Volume: set the volume to which the workload is mounted based on your requirements. For more information, see Volume Management.
- Configure "Containers in the Pod" as instructed. See the figure below:
The main parameters are described as follows:
- Name: enter the name of the container in the pod. Here, “test” is used as an example.
- Image: click Select Image, select DockerHub Image > wordpress in the pop-up window, and click OK.
- Image Tag: use the default value
latest
.
- Image Pull Policy: choose from Always, IfNotPresent and Never as needed. In this document, we use the default policy as an example.
- Environment variable: enter the following configuration information in sequence.
WORDPRESS_DB_HOST = Private IP address of TencentDB for MySQL
WORDPRESS_DB_PASSWORD = Password entered during initialization
- In Number of Instances, set the number of instances for the service according to the following information. In this document, we choose Manual Adjustment and set the instance number to one. See the figure below:
- Specify the access mode of the workload, as shown in the following figure.
- Service: select Enable.
- Service Access: select LoadBalancer (public network).
- Load Balancer: select according to your requirements.
- Port Mapping: select TCP, and set both the container port and service port to 80.
Note:
The security group of the service’s cluster must open the node network and container network to the Internet. It is also required to open ports 30000 to 32768 to the Internet. Otherwise, the problem of TKE being unusable could occur. For more details, see TKE Security Group Settings.
- Click Create Deployment.
Accessing the WordPress service
You can access the WordPress service using either of the following two methods.
Accessing the WordPress service using the CLB IP address
- In the left sidebar, click Cluster to go to the Cluster Management page.
- Click the ID of the cluster to which the WordPress service belongs and choose Services and Routes > Service.
- On the service list page, copy the CLB IP address of the WordPress service, as shown in the figure below.
- Paste the CLB IP address in the browser and press Enter to access the service.
Accessing the WordPress service using the service name
Other services or containers in the cluster can access the WordPress service using the service name.
Verifying the WordPress service
After the service is created, the WordPress server configuration page is displayed when you access the service, as shown in the figure below.
More WordPress settings
If the container fails to be created, you can view Event FAQs to locate the causes.
Was this page helpful?