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 using the credentials provided on the hands-on lab page:

    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
  • Download Arlen High's image tomlandy

    wget -O tomlandry.tar.xz https://github.com/linuxacademy/content-openshift-ex280/raw/release-3.9/docker-images/tomlandry.tar.xz
  • Load the tomlandry.tar image into docker

    docker load -i tomlandry.tar.xz
  • Check to see if the image is there.

    docker images
  • Find the registry URL on infra node

    oc get routes -n default
  • Login as peggy

    oc login https://okd.10.0.2.203.xip.io:8443 -u peggy -p propanerules -n arlen-high
  • 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)
  • Tag the tomlandry:v1 image in the following format:

    docker tag tomlandry:v1 
    docker-registry-default.apps.okd.10.0.2.204.xip.io/arlen-high/tomlandry:latest
  • 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
  • Check your imageStream

    oc get is
  • As Peggy, create an application using the docker image you just imported.

    oc new-app --image-stream=tomlandry --name="tomlandry-high"

Conclusion

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