1. Release Notes
    1. Release Notes - 2.0.2Latest
    1. Release Notes - 2.0.1
    1. Release Notes - 2.0.0
  1. Introduction
    1. Introduction
    1. Features
    1. Architecture
    1. Advantages
    1. Glossary
  1. Installation
    1. Intruction
      1. Intro
      2. Port Requirements
    1. Install on Linux
      1. All-in-One Installation
      2. Multi-Node Installation
      3. Installing HA Master and Etcd Cluster
      4. Storage Configuration Instruction
    1. Install on Kubernetes
      1. Prerequisites
      2. Online Installation
      3. Offline Installation
    1. Related Tools
      1. Integrating Harbor Registry
    1. Cluster Operation
      1. Adding New Nodes
      2. High Risk Operation
      3. Uninstalling KubeSphere
  1. Quick Start
    1. Getting Started with Multitenancy
    1. Exposing your APP using Ingress
    1. Deploying a MySQL Application
    1. Deploying a Wordpress Website
    1. Job to compute π to 2000 places
    1. Deploying Grafana using APP Template
    1. Creating Horizontal Pod Autoscaler
    1. S2i: Publish your app without Dockerfile
    1. Canary Release of Microservice APP
    1. CI/CD based on Spring Boot Project
    1. Building a Pipeline in a Graphical Panel
    1. CI/CD based on GitLab and Harbor
    1. Ingress-Nginx for Grayscale Release
  1. Cluster Admin Guide
    1. Multi-tenant Management
      1. Overview of Multi-tenant Management
      2. Overview of Role Management
    1. Platform Management
      1. Account Management
      2. Platform Roles Management
    1. Infrastructure
      1. Service Components
      2. Nodes
      3. Storage Classes
    1. Monitoring Center
      1. Physical Resources
      2. Application Resources
    1. Application Repository
    1. Jenkins System Settings
  1. User Guide
    1. Application Template
    1. Workloads
      1. Deployments
      2. StatefulSets
      3. DaemonSets
      4. Jobs
      5. CronJobs
    1. Storage
      1. Volumes
    1. Network & Services
      1. Services
      2. Routes
    1. Configuration Center
      1. Secret
      2. ConfigMap
      3. Image Registry
    1. Project Settings
      1. Basic Information
      2. Member Roles
      3. Project Members
      4. Internet Access
    1. DevOps Project
      1. DevOps Project Management
      2. DevOps Project Management
      3. DevOps Project Management
      4. DevOps Project Management
      5. DevOps Project Management
  1. Development Guide
    1. Preparing the Development Environment
    1. Development Workflow
  1. API Documentation
    1. API Guide
    1. How to invoke KubeSphere API
KubeSphere®️ 2020 All Rights Reserved.

Deploying a MySQL Stateful Application


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


Estimated Time

  • About 10 minutes

Hands-on Lab

Deploy MySQL

Step 1: Create the Password

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 mysql-secret.

  • Nickname: Nickname can be a mix of characters for you to differenciate resources, such as MySQL Secret.

  • 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.

  • Type: Select default(Opaque).

  • Data: Fill in MYSQL_ROOT_PASSWORD and 123456for the data key-value pair.

Step 2: Create a StatefulSet

Navigate to Workload → StatefulSets, then click Create StatefulSet.

Step 3: Fill in Basic Information

Fill in the following information and then click Next.

  • Name:(Necessary) A simple name can help with user brpwsing and researching, such as wordpress-mysql.
  • Nickname: (Optional) Chinese can help with better resource differentiation, such as MySQL Database.
  • Information description: Simply introduce the workload for users' understanding.

Step 4: Container Group Template

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.

  • Port: It can be named as Port. Select TCP protocol. Fill in 3306 at MySQL's container port.
  • Environmental Variables: Check the box and click Reference Configuration Center. Key in MYSQL_ROOT_PASSWORDfor name and select the secret set in the first step mysql-secret and MYSQL_ROOT_PASSWORD.

4.3. Click Save and then click Next.

Step 5: Add Storage Volume Template

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.

  • Volume Name: mysql-pvc
  • Storage Type: Select existing storage type, such as Local.
  • Capacity: Set 10 Gi by default and set access mode as ReadWriteOnce by default.
  • Mount Path: Find the storage volume's mount path in the container. Select Read and Write and set pasth as /var/lib/mysql.

Click Save when you're done. Then click Next.

Step 6. Service Configuration

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.

  • Service Name: mysql-service (Attention: The Service Name will be associated with Wordpress so use this name when you add environmental variables.)
  • Conversation affinity: None by default
  • Ports: The name is customizable. Select TCP protocol. Fill 3306 for 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.

Step 7: Tag Setting

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.

Inspect the MySQL Application

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.

Resource Status

Monitoring Data

Events List

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.