The following is how to enable the OpenShift Internal Registry on the IBM Cloud’s hosted OpenShift.
- Login to ibmcloud using the commandline tool
$ ibmcloud login --sso
-
Select your account
-
Setup OpenShift Cluster access
$ ibmcloud oc cluster config -c rdr-ocp-base-lon06-pdb --admin
-
Type oc login (it’ll tell you where to request the oauth token)
-
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".
- 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
- 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
- Make the local registry lookup use relative names
$ oc set image-lookup --all
- Login to the Docker Registry
$ docker login -u $(oc whoami) -p $(oc whoami -t) default-route-openshift-image-registry.xyz.cloud
Login Succeeded
- Pull Nginx
$ docker pull nginx
- 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
- Push the Image into the OpenShift Image Registry
$ docker push default-route-openshift-image-registry.xyz.cloud/$(oc project --short=true)/nginx-int:latest
- 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