- Lab
- A Cloud Guru
Minikube: Persistent Storage
In this hands-on lab, we will be dynamically creating storage and using it with our application. This is useful when the data that an application (e.g. a database) requires does not need to be pre-staged, or it is inserted via the application.
Path Info
Table of Contents
-
Challenge
Start Minikube Using the Correct Driver
Run the command:
sudo minikube start --vm-driver none
-
Challenge
Create the Persistent Volume Claim Taking Note of the Claim Name
Make sure that the
name
of the claim matches theclaimName
in the pod file:cd ~/dynamic cat ./mysql-volume.yaml
While still in the dynamic directory Create the volume:
sudo kubectl apply -f ./mysql-volume.yaml
-
Challenge
Create the MySQL Container
Verify that the volume target name in the mysql-pod.yaml matches the claim name from the previous step
cd ~/dynamic cat ./mysql-pod.yaml
Run the command:
sudo kubectl apply -f ~/dynamic/mysql-pod.yaml
Ensure the container is started (it might take a couple of minutes to show (READY):
sudo kubectl get po
We'll need the IP of the container, so let's run that same command, but with an extra option:
sudo kubectl get po -o wide
Make a note of that IP, because we'll need it in a minute.
-
Challenge
Install the MySQL Client and Connect to the Service Using the root Password for MySQL
This will install the latest version of the database client:
sudo apt install -y mysql-client
Before we can log into the database though, we'll need the
root
password. Look for it in the pod YAML using this:cat ~/dynamic/mysql-pod.yaml
Look beneath the line that says
MYSQL_ROOT_PASSWORD
.Now, with that password and the IP from a minute ago, let's log in:
mysql -h <IP_ADDRESS> -u root -p<MYSQL_ROOT_PASSWORD>
-
Challenge
Create a Database Once Logged into MySQL
From the
mysql
command prompt get a list of the default databases:show databases;
Create a new database, to ensure things are working correctly:
create database example;
Show the databases again to see if our new one is there:
show databases;
Now exit MySQL:
exit
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.