Deploy MySQL on KubeSphere

MySQL is an open-source relational database management system (RDBMS), which uses the most commonly used database management language - Structured Query Language (SQL) for database management. It provides a fully managed database service to deploy cloud-native applications using the world’s most popular open-source database.

This tutorial walks you through an example of deploying MySQL from the App Store of KubeSphere.

Prerequisites

  • Please make sure you enable the OpenPitrix system.
  • You need to create a workspace, a project, and a user account for this tutorial. The account needs to be a platform regular user and to be invited as the project operator with the operator role. In this tutorial, you log in as project-regular and work in the project demo-project in the workspace demo-workspace. For more information, see Create Workspaces, Projects, Accounts and Roles.

Hands-on Lab

Step 1: Deploy MySQL from the App Store

  1. On the Overview page of the project demo-project, click App Store in the top left corner.

    go-to-app-store

  2. Find MySQL and click Deploy on the App Info page.

    find-mysql

    click-deploy

  3. Set a name and select an app version. Make sure MySQL is deployed in demo-project and click Next.

    deploy-mysql

  4. In App Config, uncomment the mysqlRootPassword field and customize the password. Click Deploy to continue.

    uncomment-password

  5. Wait until MySQL is up and running.

    mysql-running

Step 2: Access the MySQL Terminal

  1. Go to Workloads and click the service name of MySQL.

    mysql-workload

  2. Under Pods, expand the menu to see container details, and then click the Terminal icon.

    mysql-teminal

  3. In the terminal, execute mysql -uroot -ptesting to log in to MySQL as the root user.

    log-in-mysql

Step 3: Access the MySQL Database outside the Cluster

To access MySQL outside the cluster, you need to expose the app through a NodePort first.

  1. Go to Services and click the service name of MySQL.

    mysql-service

  2. Click More and select Edit Internet Access from the drop-down menu.

    edit-internet-access

  3. Select NodePort for Access Method and click OK. For more information, see Project Gateway.

    nodeport-mysql

  4. Under Service Ports, you can see the port is exposed. The port and public IP will be used in the next step to access the MySQL database.

    mysql-port-number

  5. To access your MySQL database, you need to use the MySQL client or install a third-party application such as SQLPro Studio for the connection. The following example demonstrates how to access the MySQL database through SQLPro Studio.

    login

    access-mysql-success

    Note

    You may need to open the port in your security groups and configure related port forwarding rules depending on your where your Kubernetes cluster is deployed.

  6. For more information about MySQL, refer to the official documentation of MySQL.