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: Deploying Microservices

In this hands-on lab we will be deploying microservices to our Minikube cluster. We will deploy the robot-shop example application into its own name space, and then ensure that all of the services are started and running. Once that is done, we will access the robot-shop application via proxy and ensure that it is working as expected.

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 the Minikube Cluster Using the Correct Driver

    Run the command:

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

    Deploy Robot-Shop in Its Own Namespace

    In the user's home directory, there is a robot-shop directory, and within it a K8s subdirectory. Let's get into it:

    cd ~/robot-shop/K8s
    

    Now that we're there, we can create a namespace for the resources:

    sudo kubectl create namespace robot-shop
    

    Then we can create the resources in the namespace:

    sudo kubectl -n robot-shop apply -f ./descriptors/
    

    Let's monitor the pods to ensure that they come up:

    sudo kubectl -n robot-shop get po -w
    

    Once all of the pods have come up this task is complete.

  3. Challenge

    Edit the Web Service, Configure the Proxy, and Test the Application

    Let's take a closer look at the web service:

    sudo kubectl -n robot-shop get svc web
    

    Its TYPE is currently LoadBalancer, and that's not what we want here. We need to edit the web service and change its type to NodePort:

    sudo kubectl -n robot-shop edit svc web
    

    We'll land in a vim session. The spec section should look like this (minus the comments) when we're done:

    spec:
     ports:
     - name: "8080"
       port: 8080
       protocol: TCP
       targetPort: 8080
       nodePort: 30080    <-- ensure that the nodePort it set to this value
     selector:
       service: web
     sessionAffinity: None
     type: NodePort    <---- change from LoadBalancer
    

    Now let's take another look at the web service:

    sudo kubectl -n robot-shop get svc web
    

    Its TYPE should be NodePort now.

    Now let's get the URL of the web service:

    sudo minikube service list
    

    We need the TARGET_PORT of the web service for this next step. We've got to edit the Nginx configuration and set the port forwarding to the NodePort URL:

    sudo vim /etc/nginx/sites-enabled/default
    
    
        location / {
                   # First attempt to serve request as file, then
                   # as directory, then fall back to displaying a 404.
                   proxy_pass http://<minikube IP>:<svc port>;
    

    Once that's done, we can restart Nginx:

    sudo systemctl restart nginx
    

    Finally, we can test in a web browser. If we exit in the terminal, we'll get the server's public IP. We can also get it from the hands-on lab overview page. But browse to it, and we should see the robot-shop application up and running. Feel free to tool around and look at the different robots. If you can, it means we're through setting things up.

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