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
KubeSphere®️ 2020 All Rights Reserved.

Publish WordPress App to Kubernetes

Edit

WordPress Introduction

WordPress is an online, open source website creation tool written in PHP, with a back-end MySQL database and a front-end component. We can deploy WordPress to Kubernetes using Kubernetes object resources.

WordPress

Objective

In this tutorial we will create a WordPress application as an example, demonstrating how to deploy application with multiple components to Kubernetes through KubeSphere console.

Estimated Time

About 15 minutes

Hands-on Lab

Step 1: Create Secrets

Create a MySQL Secret

The environment variable WORDPRESS_DB_PASSWORD is the password to connect the database in WordPress. In this step, we create a ConfigMap to store the environment variable that is used in MySQL Pod template.

1.1 Log in KubeSphere console using the account project-regular. Enter demo-project, navigate to Configuration Center → Secrets, then click Create.

Secrets List

1.2. Fill in the basic information, e.g. name it mysql-secret, then click Next. Click Add data and fill in the secret settings as shown in the following screenshot, save it and click Create.

  • Key: MYSQL_ROOT_PASSWORD
  • Value: 123456

Create MySQL Secret

Create a WordPress Secret

Same steps as above, create a WordPress secret wordpress-secret with Key WORDPRESS_DB_PASSWORD and Data 123456.

Create WordPress Secret

Step 2: Create a Volume

Choose Volumes and click Create, name it wordpress-pvc, click Next to Volume Settings where you need to choose an available Storage Class, ReadWriteOnce of access mode and 10G of storage size. Click Next to Advanced Settings. No configuration is for this page, so click Create to finish volume creation.

Create Volume

Step 3: Create an Application

Add MySQL back-end component

In this step, we will choose the way of composing app to create a complete microservice app.

3.1. Select Application Workloads → Applications → Deploy New Application, and choose Composing App.

New Application

3.2. Fill in the pop-up table as follows:

  • Application Name: wordpress
  • Then click Add Component
  • Name: mysql
  • Component Version: v1
  • Workload Type: Stateful service (StatefulSet)

Compose Application

3.3. Scroll down and click Add Container Image, enter mysql:5.6 into the Image edit box, press the return key and click Use Default Ports.

Fill Application Info

3.4. Scroll down to the Environment Variables, check Environment Variable and click Use ConfigMap or Secret, then input the name MYSQL_ROOT_PASSWORD and choose the resource mysql-secret and the key MYSQL_ROOT_PASSWORD we created in previous step.

Click to save it when you have finished.

Fill More Application Info

3.5. Continue scrolling down and click Add Volume Template to create a PVC for MySQL according to the following screenshot.

Add Volume to Application

3.6. Click to save it. At this point you have added the MySQL component.

Save Application info

Add WordPress front-end component

3.7. Click Add Component again, fill in the Name and Component Version refer to the following screenshot:

Add Front End

3.8. Click Add Container Image, enter wordpress:4.8-apache into the Image edit box, press the return key and click Use Default Ports.

Choose Container Image

3.9. Scroll down to the Environment Variables, check Environment Variable and click Use ConfigMap or Secret, then enter the values according to the following screenshot.

  • WORDPRESS_DB_PASSWORD, choose wordpress-secret and WORDPRESS_DB_PASSWORD
  • Click Add Environment Variable, then fill its key & value with WORDPRESS_DB_HOST and mysql.

Add Env Variables

3.10. Click to save it.

3.11. Continue scrolling down and click Add Volume to attach the existed volume to WordPress.

Add Volume

3.12. Select wordpress-pvc that we created in the previous step, and select ReadAndWrite, then input /var/www/html as its mount path. Click to save it.

Fill Volume Info

3.13. Again, click to save it. Ensure both mysql and wordpress application components have been added into the table, then you can click Create.

Save Application

Application List

Step 4: Verify the Resources

Deployment

WordPress Deployment

StatefulSet

WordPress StatefulSet

Services

WordPress Services

Step 5: Access the WordPress Application

5.1. Enter wordpress service, and click Edit Internet Access.

WordPress Internet Access

5.2. Choose NodePort as its service type.

Service Status

At this point, WordPress is exposed to outside through the service, thus we can access this application in browser via {$Node IP}:{$NodePort}, for example http://192.168.0.88:30048 since we selected http protocol previously.

WordPress Page