Bookmark this page

Guided Exercise: Setting up the Developer Environment

Set up the classroom and developer environment for the hands-on labs in the course.

Outcomes

  • Familiarize with the GitLab classroom instance.

  • Familiarize with the classroom image registry.

  • Access the classroom cluster by using the oc CLI and the Red Hat OpenShift web console.

  • Verify the odo CLI setup by building and deploying a sample application.

  • Verify the setup of the OpenShift Toolkit extension for VSCode.

As the student user on the workstation machine, use the lab start command to prepare your system for this exercise.

This command copies the exercise files to the course directory and creates a architecture-setup project in the cluster as the developer user.

[student@workstation ~]$ lab start architecture-setup

Instructions

  1. Log in to the classroom GitLab instance.

    1. Navigate to https://git.ocp4.example.com.

    2. Log in to GitLab by using the developer user with the developer password.

    3. Explore the repositories available to the developer user.

  2. Verify that the classroom image registry is accessible and log in by using Podman.

    1. Navigate to the https://registry.ocp4.example.com:8443 URL.

    2. Log in to the registry by using the developer user with the developer password. Then, click Sign in to Red Hat Quay to log in.

    3. Navigate to developerAccount Settings and click Generate Encrypted password.

    4. Enter the developer password and click Verify to validate the form.

    5. To log in to the image registry, click Podman Login, and copy the podman login command with the ENCRYPTED_PASSWORD.

    6. Paste the command to the terminal to log in.

      [student@workstation ~]$ podman login -u="developer" -p="ENCRYPTED_PASSWORD" \
      registry.ocp4.example.com:8443
      Login Succeeded!
  3. Log in to the classroom cluster by using the oc CLI and the Red Hat OpenShift web console.

    1. Run the oc login command with the developer user with the developer password.

      [student@workstation ~]$ oc login -u developer -p developer \
        https://api.ocp4.example.com:6443
      Login successful.
      
      ...output omitted...
    2. To get the web console URL, run the oc whoami command with the --show-console option.

      [student@workstation ~]$ oc whoami --show-console
      https://console-openshift-console.apps.ocp4.example.com
    3. To log in to the web console, navigate to the https://console-openshift-console.apps.ocp4.example.com URL, click htpasswd_provider, and use the developer user with the developer password.

  4. Validate that the odo CLI is properly configured by deploying the hello-flask sample application.

    1. Change to the ~/DO288/labs/architecture-setup/hello-flask directory.

      [student@workstation ~]$ cd ~/DO288/labs/architecture-setup/hello-flask
    2. Run odo deploy to build the hello-flask container image and deploy it to the cluster. Note that this command requires you to be logged in to the image registry and the cluster.

      [student@workstation hello-flask]$ odo deploy
        __
       /  \__     Running the application in Deploy mode using hello-flask Devfile
       \__/  \    Namespace: architecture-setup
       /  \__/    odo version: v3.10.0
       \__/
      
      ↪ Building & Pushing Image: registry.ocp4.example.com:8443/developer/hello-flask
       •  Building image locally  ...
      
      ...output omitted...
      
       ✓  Building image locally [2s]
       •  Pushing image to container registry  ...
      
      ...output omitted...
      
      Writing manifest to image destination
      Storing signatures
       ✓  Pushing image to container registry [1s]
      
      ↪ Deploying Kubernetes Component: hello-flask
       ✓  Creating resource Route/hello-flask
      
      ↪ Deploying Kubernetes Component: hello-flask
       ✓  Creating resource Service/hello-flask
      
      ↪ Deploying Kubernetes Component: hello-flask
       ✓  Creating resource Deployment/hello-flask
      
      Your Devfile has been successfully deployed
    3. Verify that odo deploys the application by running the curl command to query the http://hello-flask-architecture-setup.apps.ocp4.example.com URL.

      [student@workstation hello-flask]$ curl \
        http://hello-flask-architecture-setup.apps.ocp4.example.com; echo
      Hello World!
  5. Open the hello-flask application in VSCodium to verify that the Red Hat OpenShift Toolkit VSCode extension recognizes that the hello-flask application is running in the cluster.

    1. Open VSCodium by running the codium command with the . path from the hello-flask directory.

      [student@workstation hello-flask]$ codium .

      Click Yes, I trust the authors to close the modal window that shows the first time you open the project.

    2. Click the OpenShift icon to open the OpenShift Toolkit side panel.

      The APPLICATION EXPLORERhttps://api.ocp4.example.com:6443architecture-setup item shows the hello-flask application running in the cluster. Also, the COMPONENTS section shows that the OpenShift Toolkit recognizes the hello-flask source code in the current directory.

Finish

On the workstation machine, use the lab command to complete this exercise. This step is important to ensure that resources from previous exercises do not impact upcoming exercises.

[student@workstation ~]$ lab finish architecture-setup

Revision: do288-4.12-0d49506