Container Service with Persistent Volume
Objective
In this lab, you will learn how to deploy a MySQL server using Cloudplex integrated Docker-Hub which will be used to pull pre-build MySQL image and use Persistent Volume to store data.
Prerequisite
If you want to deploy this lab, you need to deploy at least one infrastructure. We have labs on infrastructure as well, you can follow them to deploy infrastructure
Add Application Info
Give name to your application and specify the version, you can also give tags to your application of your choice.
Click on the next button on the top right corner.
Add Secret Service
CloudPlex platform provides a secret management service that provides the ability to store sensitive data such as passwords, tokens, and certificates in Cloudplex. Any data entered in this service is stored in a secure vault with at-rest encryption. This eventually becomes a Kubernetes Secret in a deployed application.
To configure the service, Drag-n-drop Secret service from pallet to the canvas.
Click on the service to open the configuration panel on the right side.
The platform will populate the default values of service (Service Id, Service Name, Namespace)
Click on Add secret string and type MYSQL_ROOT_PASSWORD in key and the Password in the value field. For this lab, type (the password as shown) 5dzo2MsriVJNYTTtud8gOyDc3A in the value field.
key : MYSQL_ROOT_PASSWORD
value : 5dzo2MsriVJNYTTtud8gOyDc3A
Click on save button to save service
Configure the MySQL Container
Drag-n-drop the Docker Hub service from pallet to the canvas.
Drag the arrow from Secret service to Container service.
Click on the service to open the configuration panel on the right side.
Type MySQL in the search bar and click on the search button.
Select MySQL service.
CloudPlex automatically pulls all the tags and metadata of the image and populates default values of service (Service Id, Service Name, Namespace, Type)
Add Environment Variables
Click on the Environment variables section to add a new environment variable.
Cloudplex provides two types of variables (Static, Dynamic). We are going to use Dynamic variable in this lab to use the Secret key in our container
Select the secret service from the service drop-down and type MYSQL_ROOT_PASSWORD in the key field.
Expand Service Attributes and Secrets Data and select MYSQL_ROOT_PASSWORD. Cloudplex automatically generates dynamic parameters for you.
Click on the save button to save the parameters.
A new environment variable with the key MYSQL_ROOT_PASSWORD will be added in the list of Environment Variables.
Click on the back button on top of the configurations.
Add new Port
Ports are required to access your applications. Click on the Port section to add a new port
Cloudplex automatically discovers ports from Docker images and populates them in the ports section of the service.
Click on the save button to save the service.
Add Volume Service
A PersistentVolume (PV) is a piece of storage in the cluster that has been dynamically provisioned by Kubernetes using a StorageClass.
MySQL service used this block of storage to store its data.
To add a persistent storage to your MySQL Service, Click on the MySQL service to open the service configurations on the right side and click on Advanced Configurations
Select container volumes. CloudPlex has integrated with all the volumes and provides an easy to use interface for all of them.
For this lab, let's select persistent volume. Select Volume from service dropdown. If you don't have any volume available on canvas, you can create a new volume config by providing simple configurations.
Click on new from the service dropdown and CloudPlex will take you to the volume configurations panel.
CloudPlex automatically populates default values of service (Service Id, Service Name, Namespace)
Enter desired capacity 10Gi and Reclaim policy Delete from dropdown. The reclaim policy for a PersistentVolume tells the cluster what to do with the volume after it has been released of its claim
Click on the save button to save the configuration
Now you are back to your container service where you left it, Click on the label of the attached volume and provide mount path.
Click on the save button to save the service.
All the Kubernetes manifest required to create a persistent volume (persistent volume claim, storageclass) is automatically created by the platform.
A PersistentVolumeClaim (PVC) is a request for storage by a user and a StorageClass provides a way for administrators to describe the "classes" of storage they offer
Deploy Application
Click on the Deploy button at the top right corner and select the Infrastruture from the drop down list of your deployed infrastructures, your deployment will start right after saving the application and it will redirect you to the logs tabs or you can save it by clicking on the Save button to deploy it later.
In the log window, you can see the logs of your application.
!! Deployment will take around 2 minutes!!
You can see the status of the application you just deployed by clicking on the app tab and click on Table view to see the realtime status of the services.
Cleanup
To avoid unnecessary costs, don’t forget to terminate your application when you are done. Click on the Terminate button to terminate your application and dont forget to Terminate the infrastrusture(s) that you used to deploy this lab.
Conclusion
Congratulations! you just completed this lab and learned how to run a My-SQL server with Persistent Volume on Kubernetes using Cloudplex platform.