Skip to main content

Create an OpenShift ImageStream

Hands-On Lab

 

Photo of

Training Architect

Length

01:00:00

Difficulty

Advanced

Create an OpenShift Imagestream

Arlen High has decided to consolidate their OpenShift project with Tom Landry high school, but they need your help importing the Docker container that hosts the website. Import the image into the OpenShift container registry so that it is available to users under the arlen-high project.

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.

Edit Create an OpenShift ImageStream

Introduction

Arlen High has decided to consolidate their OpenShift project with Tom Landry high school, but they need your help importing the Docker container that hosts the website. Import the image into the OpenShift container registry so that it is available to the users under the arlen-high project.

Solution

  • Log in to the OpenShift cluster (Master node) using the credentials provided on the hands-on lab page. Note that the bootstrap scropt may take a while to complete so be patient and tray again every 10 seconds if you get 'Conneciton refused':

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

    sudo -i
  • Check the health of the cluster:

    oc get nodes
  • Create the project that they will use for their application:

    oc new-project arlen-high --description="Arlen Tx Engineering project"
  • Create the user account for the administrator of the project:

    htpasswd -b /etc/origin/master/htpasswd peggy propanerules
  • Grant peggy admin privileges to the arlen-high project:

    oc adm policy add-role-to-user admin peggy -n arlen-high
  • Add registry-viewer clusterrole to peggy:

    oc adm policy add-role-to-user registry-viewer peggy
  • Add registry-editor clusterrole to peggy:

    oc adm policy add-role-to-user registry-editor peggy
  • Switch to the arlen-high project:

    oc project arlen-high
  • Since the docker file will try to run this image as root and OpenShift will not allow this, we will need to add an exception:

    oc adm policy add-scc-to-user anyuid -z default
  • Check the loaded images before we begin:

    docker images

A number of students have reported problems downloading the lab Docker image from GitHub (opton A below). While we sort this out we are offering a work around (option B). Feel free to use either one. Take time to note the differences and consider why they are different. Sincerly, your cloud team.

  • Download Arlen High's Application image tomlandy:

    • Option A - Download the tomlandry.tar image from Git hub and 'load' it into into docker.

      wget -O tomlandry.tar.xz https://github.com/linuxacademy/content-openshift-ex280/raw/release-3.9/docker-images/tomlandry.tar.xz
      docker load -i tomlandry.tar.xz
    • Option B - Pull the image from Docker Hub.

      docker pull amunix/tomlandry:latest1
  • Option A & B - Check to see if the image is there and it's full name and tag:

    docker images
  • Option A & B - Find the registry URL on infra node:

    oc get routes -n default
  • Option A & B - Login as peggy:

    oc login https://okd.10.0.2.203.xip.io:8443 -u peggy -p propanerules -n arlen-high
  • Option A & B - Login to the docker registry as peggy:

    docker login docker-registry-default.apps.okd.10.0.2.204.xip.io -u $(oc whoami) -p $(oc whoami -t)
  • Update Tag for the tomlandry:v1 image in the following format:

    • Option A

      docker tag tomlandry:v1 docker-registry-default.apps.okd.10.0.2.204.xip.io/arlen-high/tomlandry:latest
    • Option B

      docker tag docker.io/amunix/tomlandry:latest1 docker-registry-default.apps.okd.10.0.2.204.xip.io/arlen-high/tomlandry:latest
  • Option A & B - Check the loaded images after tagging:

    docker images
  • Option A & B - Push the tagged image into the container registry:

    docker push 
    docker-registry-default.apps.okd.10.0.2.204.xip.io/arlen-high/tomlandry:latest
  • Option A & B - Check your imageStream:

    oc get is
  • Option A & B - As Peggy, create an application using the docker image you just imported:

    oc new-app --image-stream=tomlandry --name="tomlandry-high"
  • Option A & B - Check the pods.

    oc get pods

Conclusion

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