Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Google Cloud Platform icon
Labs

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.

Google Cloud Platform icon
Labs

Path Info

Level
Clock icon Beginner
Duration
Clock icon 30m
Published
Clock icon Nov 26, 2019

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Start Minikube Using the Correct Driver

    Run the command:

    sudo minikube start --vm-driver none
    
  2. Challenge

    Create the Persistent Volume Claim Taking Note of the Claim Name

    Make sure that the name of the claim matches the claimName 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
    
  3. 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.

  4. 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>
    
  5. 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
    

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

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.

Start learning by doing today

View Plans