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.
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.
The database must be in the same region as that of the cluster. Otherwise, you will unable to connect to the database.
After creating the database, you can view it in the MySQL instance list.
Initialize the database. For more information, see Initializing MySQL Instance.
Creating a WordPress service that uses Tencent DB
Log in to the TKE console and select Clusters in the left sidebar.
On the Cluster Management page, click the ID of the cluster for which the service is to create to go to the Deployment page of the cluster and click Create, as shown in the figure below.
On the Create Workload page, specify basic information of the workload as instructed in the figure below.
- Workload Name: the name of the workload to create. Here,
wordpress is used as an example.
- Description: specify related workload information.
- Tag: specify the key-value pair. The default value is k8s-app = wordpress here.
- Namespace: select a namespace based on your requirements.
- Type: select a type 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 in the figure below.
The main parameters are as follows. Retain the default settings for other parameters.
- Name: enter the custom container name. In this example,
test is used.
- Image: enter
- Image Tag: enter
- Image Pull Policy: three policies are available. Select a policy as required. In this example, the default policy is used.
If you do not specify an image pull policy, the "Always" policy is used when the image tag is empty or "latest". Otherwise, the IfNotPresent policy is used.
- Always: always pull the image from the remote end.
- IfNotPresent: a local image is used by default. If no local image is available, the image is pulled remotely.
- Never: only use a local image. If no local image is available, an exception occurs.
- 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
Set the number of pods for the service as instructed in the figure below.
- Manual adjustment: set the number of pods. The number of pods in this example is set to 1. You can click "+" or "-" to change the number of pods.
- Auto Adjustment: the number of pods is automatically adjusted if any of the setting conditions are met. For more information, see Automatic Scaling Basic Operations.
Configure Access Settings (Service) for the workload as instructed in the figure below.
- Service: select Enable.
- Service Access: select Via Internet.
- Load Balancer: create or select a load balancer as needed.
- Port Mapping: select TCP, and set both the container port and service port to 80.
The security group of the cluster to which the service belongs 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, TKE may be unavailable. For more information, see TKE Security Group Settings.
Click Create workload.
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 Clusters to go to the "Cluster Management" page.
- Click the ID of the cluster to which the WordPress service belongs and choose Service > Service.
- On the service management page, copy the CLB IP address of the WordPress service, as shown in the figure below.
- Paste the CLB IP address in the browser address box 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.