v2.1
v2.0
v1.0
  1. Release Notes
    1. Release Notes - 2.1.1Latest
    1. Release Notes - 2.1.0
    1. Release Notes - 2.0.2
    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. Introduction
      1. Intro
      2. Port Requirements
      3. Kubernetes Cluster Configuration
    1. Install on Linux
      1. All-in-One Installation
      2. Multi-Node Installation
      3. High Availability Configuration
      4. Air Gapped Installation
      5. StorageClass Configuration
      6. Enable All Components
    1. Install on Kubernetes
      1. Prerequisites
      2. Install on K8s
      3. Air Gapped Installation
      4. Install on GKE
    1. Pluggable Components
      1. Pluggable Components
      2. Enable Application Store
      3. Enable DevOps System
      4. Enable Logging System
      5. Enable Service Mesh
      6. Enable Alerting and Notification
      7. Enable Metrics-server for HPA
      8. Verify Components Installation
    1. Upgrade
      1. Overview
      2. All-in-One
      3. Multi-node
    1. Third-Party Tools
      1. Configure Harbor
      2. Access Built-in SonarQube and Jenkins
      3. Enable built-in Grafana Installation
      4. Load Balancer plugin in Bare Metal - Porter
    1. Authentication Integration
      1. Configure LDAP/AD
    1. Cluster Operations
      1. Add or Cordon Nodes
      2. High Risk Operations
      3. Uninstall KubeSphere
  1. Quick Start
    1. 1. Getting Started with Multi-tenancy
    1. 2. Expose your App Using Ingress
    1. 3. Compose and Deploy Wordpress to K8s
    1. 4. Deploy Grafana Using App Template
    1. 5. Job to Compute π to 2000 Places
    1. 6. Create Horizontal Pod Autoscaler
    1. 7. S2I: Publish your App without Dockerfile
    1. 8. B2I: Publish Artifacts to Kubernete
    1. 9. CI/CD based on Spring Boot Project
    1. 10. Jenkinsfile-free Pipeline with Graphical Editing Panel
    1. 11. Canary Release of Bookinfo App
    1. 12. Canary Release based on Ingress-Nginx
    1. 13. Application Store
  1. DevOps
    1. Pipeline
    1. Create SonarQube Token
    1. Credentials
    1. Set CI Node for Dependency Cache
    1. Set Email Server for KubeSphere Pipeline
  1. User Guide
    1. Configration Center
      1. Secrets
      2. ConfigMap
      3. Configure Image Registry
  1. Logging
    1. Log Query
  1. Developer Guide
    1. Introduction to S2I
    1. Custom S2I Template
  1. API Documentation
    1. API Documentation
    1. How to Access KubeSphere API
  1. Troubleshooting
    1. Troubleshooting Guide for Installation
  1. FAQ
    1. Telemetry
KubeSphere®️ 2020 All Rights Reserved.

Deploying a MySQL Stateful Application

Edit

Objective

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

Prerequisites

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.