Skip to main content

Build an OpenShift Application

Hands-On Lab

 

Photo of

Training Architect

Length

01:00:00

Difficulty

Beginner

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Build an OpenShift Application

Introduction

Before Mega-lo Mart fully migrates to OpenShift, they first want to see a demo on how pod management works. Use the hello-openshift Docker image to create a pod in the megalomart project, then scale the app up from 1-5 pods using origin clients.

Solution

  • Log in to the OpenShift cluster using the credentials provided on the hands-on lab page:

    ssh cloud_user@<IP_ADDRESS>
  • Become the root user:

    sudo -i
  • Create projects associated with the labs:

    for i in strickland-propane arlen-high megalomart
        do
        oc new-project $i --description="Arlen Tx Engineering project"
    done
  • Switch to the megalomart project:

    oc project megalomart
  • In the megalomart project, create a new app named howdy using the hello-openshift image:

    oc new-app openshift/hello-openshift --name="howdy"
  • Create a route to the howdy app:

    • Get the name of the service:
      oc get svc
    • Create the route:
      oc expose svc/howdy
    • Check the route you created:
      oc get routes
  • Scale the howdy app up from one to five pods, using origin clients:

    • View the number of current pods:
    oc get pods
    • Get the name of the deployment config:

      oc get dc
    • Scale the app to five pods:

    oc scale --replicas=5 dc/howdy
    • View the number of pods after scaling to 5:
    oc get pods
  • Now scale the howdy app back down to one pod:

    oc scale --replicas=1 dc/howdy

    View the number of pods and see the difference after the change:

    oc get pods

Conclusion

Congratulations, you've completed this hands-on lab!