Take the setting up of a Statefulset for an example. Here is a presentation of how to use the mirroring deployment,
mysql:5.6, to set up a stateful MySQL app as the Wordpress website's backend. It will show you how to use Statefulset. The MySQL initial password for this example will be created and saved as Secret. For presenting, here will only demonstrate processes. For relevant parameters and fields' detailed explanation, please refer to the Secret and StatefulSets
project-regularshould be created. If not, please refer to Quick Start Guide of Multi-tenant Management
project regularto the project and grant it with the role of
operator. Please refer to Quick Start Guide of Multi-tenant Management-Inviting Members
MySQL's Enviromental variable
MYSQL_ROOT_PASSWORD, namely the root user's password, is private informsation. It's inappropriate to show the password in steps. Therefore, here we use the password creation to replace the environmental variable. The created password will be keyed in as the environmental variable when setting up the MySQL container group.
1.1. Log in KubeSphere as the
project-regular. Select Secret in the Configuration Center → Secrets, then click Create.
1.2. Fill in the password's basic information,then click Next.
Name: The environmenal variables in the MySQL container can have customized names, such as
Nickname: Nickname can be a mix of characters for you to differenciate resources, such as
Information Description: Simply introduce the password, such as
MySQL Initial password.
1.3. Fill in the following information into the secret setting page. Then click Create.
Data: Fill in
123456for the data key-value pair.
Navigate to Workload → StatefulSets, then click Create StatefulSet.
Fill in the following information and then click Next.
4.1. Click Add Container to fill in the container group seeing. The name is customizable. Fill in the mirror with
mysql:5.6 (specific mirror edition number is needed). There is no limitation for CPU and storage. They will be used as the default reqest value when creating the project.
4.2 Set up the Service Setting and the Environmental Variable. Leave others unchanged. Then click Save.
TCPprotocol. Fill in
3306at MySQL's container port.
MYSQL_ROOT_PASSWORDfor name and select the secret set in the first step
4.3. Click Save and then click Next.
Complete the container group template then click Next. Lick Add Storage Volume Template in the template. Stateful data should be saved in persistent storage volume. Thus, you need to add storage volume to realize the data persistency. Please refer to the storage volume information as follows.
10 Giby default and set access mode as
Read and Writeand set pasth as
Click Save when you're done. Then click Next.
If you need to reveal the MySQL application to other applications and servers, you need to create the service. Complete the parameter setting by refering the picture below. Then click Next.
mysql-service(Attention: The Service Name will be associated with Wordpress so use this name when you add environmental variables.)
3306for both of the MySQL service port and the target port. The first port the service port that needs to be exposed. The second port (target port) is the container port.
Note: If there is a requirement for conversation affinity, you can select "ClientIP" in the drop-down box or set the value of service.spec.sessionAffinity as "ClientIP" ("None" by default) in the code mode. This configuration can forward access request from the same IP address to the same rear end Pod.
Keep the tag as default setting
app: wordpress-mysql. You can use the specific container group adjust the next node selector to the expected node. Do not set it for now. Click Create.
You can see the MySQL StatefulSet displays "updating" since this process requires a series of operations, such as pulling a Docker image creating a container, and initializing the database. It will show
ContainerCreating. Normally, it will change to "running" at around 1 min. Click this you can access to the StateSet page including the Resource Status, Version Control, Monitoring, Environmental Variable and Events.
So far, MySQL Stateful application has been created successfully, it will be served as the backend database of the WordPress application.
It's recommended to follow with Quick Start - Wordpress Deployment Guide to deploy the blog website, then you will be able to access the web service.