Accessing and Using the Internal OpenShift Registry

The following is how to enable the OpenShift Internal Registry on the IBM Cloud’s hosted OpenShift.

  1. Login to ibmcloud using the commandline tool
$ ibmcloud login --sso    
  1. Select your account

  2. Setup OpenShift Cluster access

$ ibmcloud oc cluster config -c rdr-ocp-base-lon06-pdb --admin
  1. Type oc login (it’ll tell you where to request the oauth token)

  2. Get a token at https://XYZ.com:31344/oauth/token/request

$ oc login --token=sha256~aaa --server=https://XYZ.com:31609
Logged into "https://XYZ.com:31609" as "IAM#xyz@us.ibm.com" using the token provided.

You have access to 63 projects, the list has been suppressed. You can list all projects with 'oc projects'

Using project "default".
  1. Setup the external route for the Image Registry
$ oc patch configs.imageregistry.operator.openshift.io/cluster --patch '{"spec":{"defaultRoute":true}}' --type=merge
config.imageregistry.operator.openshift.io/cluster patched
  1. Check the OpenShift Image registry host and you see the hostname printed.
$ oc get route default-route -n openshift-image-registry --template='{{.spec.host }}'
default-route-openshift-image-registry.xyz.cloud
  1. Make the local registry lookup use relative names
$ oc set image-lookup  --all
  1. Login to the Docker Registry
$ docker login -u $(oc whoami) -p $(oc whoami -t) default-route-openshift-image-registry.xyz.cloud
Login Succeeded
  1. Pull Nginx
$ docker pull nginx
  1. Tag the Image for the Image Registry
$ docker tag nginx:latest default-route-openshift-image-registry.xyz.cloud/$(oc project --short=true)/nginx-int:latest
  1. Push the Image into the OpenShift Image Registry
$ docker push default-route-openshift-image-registry.xyz.cloud/$(oc project --short=true)/nginx-int:latest 
  1. Use image-registry.openshift-image-registry.svc:5000/default/nginx-int:latest as the image name in your deployment
$ oc run test-a --image image-registry.openshift-image-registry.svc:5000/default/nginx-int:latest
pod/test-a created

Reference

  1. OpenShift 4.10: Exposing the Image Registry

Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.