Portworx Guided Hands On-Labs. Register Now

mysql

Deploying MySQL on Kubernetes with Portworx Data Services

In this post, we will walk you through a simple way to deploy a highly available MySQL cluster on your Amazon EKS using Portworx Data Services.

MySQL is one of the most popular Relational Database Management Systems (RDBMS), an open-source database that enables you to store, manage, and query colossal amounts of data using a Structured Query Language (SQL).

Portworx Data Services (PDS) allows organizations to deploy not only MySQL, but also many other modern data services like PostgreSQL, Cassandra, Redis, Kafka, Zookeeper and RabbitMQ on any Kubernetes cluster that is registered to the PDS control plane. Using PDS, developers and DevOps administrators can deploy a highly available MySQL instance on their Kubernetes cluster. PDS also automates Day-2 operations on your data services layer, such as scale up, scale out and backup.

The diagram below shows a simple sample MySQL deployment on an AWS EKS cluster using PDS.

  • The Portworx is installed on the EKS cluster.
  • The EKS cluster is registered to Portworx Data Services.
    • The PDS Agent is installed during the setup
    • The PDS Agent communicates with PDS using reverse-proxy. This means you don’t need to open any firewall ports.
  • DevOp Administrator defines application configuration, such as environment variables if needed, and resource settings with different T-Shirt sizes.
  • Users – developers or SREs follow the simple procedure as shown in this post to deploy MySQL instance on their EKS
  • Developers use connection strings provided by PDS to start using MySQL instances. In this example we used phpMyAdmin client.

image
To quickly deploy your first MySQL instances, click the MySQL button under the Deploy Data Service heading in the PDS console. Enter the following details:

  • Name: Enter the deployment name for your MySQL cluster.
  • Target Cluster and Namespace: Select the Kubernetes cluster and namespace where you want to deploy your MySQL cluster.
  • Application Configuration: This can include environment variables or application settings for your MySQL deployment. In this example, we use “default.”
  • Resource Settings: Select a T-shirt size setting for individual MySQL pod resource quotas and limits.
  • Number of Nodes: This is the number of MySQL pods to deploy. For this example, we are deploying a 3-node HA MySQL cluster.

pic pds mysql1

Once you hit the Deploy button, PDS will initiate the deployment of a MySQL cluster, and once it completes successfully, it will share the connection strings and credentials that you can start using in your application.

You can monitor real-time application activities within PDS by entering the Metrics page. It shows the list of commonly used performance metrics for your application.

pic pds

To validate MySQL deployment, we deployed a popular MySQL client application called phpMyAdmin. You can use the YAML file below to try it out by yourself.

apiVersion: v1
kind: Secret
metadata:
 name: mysql-secrets
 namespace: demo-ns
type: Opaque
data:
 ROOT_PASSWORD: cG9ydHdvcngK
---
apiVersion: apps/v1
kind: Deployment
metadata:
 name: phpmyadmin-deployment
 namespace: demo-ns
 labels:
   app: phpmyadmin
spec:
 replicas: 1
 selector:
   matchLabels:
     app: phpmyadmin
 template:
   metadata:
     labels:
       app: phpmyadmin
   spec:
     containers:
       - name: phpmyadmin
         image: phpmyadmin/phpmyadmin
         ports:
           - containerPort: 80
         env:
           - name: PMA_HOST
             value: <put_mysql_router_FQDN_from_connection_page>
           - name: PMA_PORT
             value: "6446"
           - name: MYSQL_ROOT_PASSWORD
             valueFrom:
               secretKeyRef:
                 name: mysql-secrets
                 key: ROOT_PASSWORD
           - name: MYSQL_USER
             value: pds
           - name: MYSQL_PASSWORD
             value: "enter_password_on_the_web_gui"
---
apiVersion: v1
kind: Service
metadata:
 name: phpmyadmin-service
 namespace: demo-ns
spec:
 type: LoadBalancer
 selector:
   app: phpmyadmin
 ports:
 - protocol: TCP
   port: 80
   targetPort: 80

 

Once phpMyAdmin pod is deployed, run the following command to get the URL to access its web page. Enter the username and password provided by the PDS MySQL connection page and you should be able to log into the phpMyAdmin console as below.

kubectl get service -n <your_namespace> 

pic pds mysql

From this phpMyAdmin client, we can create a database and some sample data. In the demo video below, we have created an “employee” table, and inserted a couple of names from this web console. We have also validated that the newly created data in MySQL cluster is properly replicated among the MySQL pods. Check out the demo below to see this in action.

Day-2 Operations

Once you have tested your MySQL deployment, optionally, the following are some of the day-2 operations that you can perform from PDS.

  • Scale-up your MySQL instances by changing the resource setting from Small to Medium or Large with more CPU, memory and storage.
  • Scale-out your MySQL cluster by adding more nodes if your database query demand increases.
  • Add or modify the scheduled backup.
  • Perform the one-time backup independently from your scheduled backup.
  • Update MySQL version directly from the PDS console.

If you want to learn more about Portworx Data Services, click here!

pds mysql

Share
Subscribe for Updates

About Us
Portworx is the leader in cloud native storage for containers.

jeff

Jeff Chen

Technical Marketing | Cloud Native BU, Portworx by Pure Storage
link
hamburg gaeda
July 26, 2022 How To
Deploy Redis on Kubernetes with Portworx
Jon Owings
Jon Owings
link
Kafka 101 image
June 17, 2022 How To
Deploying Kafka on Kubernetes with Portworx
Bhavin Shah
Bhavin Shah
link
fisk
May 11, 2022 How To
Accelerate data services deployment on Kubernetes using Portworx Data Services
Bhavin Shah
Bhavin Shah