My scrapbook about anything which I learned or want to remember, Sometime about tech tips, thoughts and rambling. If you find anything useful don't forget to give thumbs-up :)

Breaking

Thursday, February 25, 2021

Expose OCP internal image registry

Openshift Platform comes with its internal image registry which is used by Openshift to store images whether those are base builder image or application images. You can access this registry as any other image registry after tweaking it a little bit. In this post, we will take a look on that. 

1. Check If Internal image registry is exposed or not - 

# Check If Internal Registry is installed or not
oc get route -n openshift-image-registry -o jsonpath='{.items[*].spec.host}{"\n"}'


2. Above command will show the default route for Images, this means, Internal registry is exposed to access, if not, we can expose it by running below command, which will be requiring "cluster-admin" role. So, Either you or OCP admin can run the below command - 

# Double check the python image location in internal by below command - 
oc get is/python -n openshift -o jsonpath='{.status.publicDockerImageRepository}{"\n"}'


# Expose Internal Image registry 
oc patch config cluster -n openshift-image-registry --type merge -p '{"spec":{"defaultRoute":true}}'

3. Login with Podman or Docker 

# Once exposed, You can access the image registry by below commands - 
OCPUSER=$(oc whoami)
TOKEN=$(oc whoami -t)

INTERNAL_REGISTRY=$(oc get route -n openshift-image-registry -o jsonpath='{.items[*].spec.host}{"\n"}')
podman login ${INTERNAL_REGISTRY} -u ${OCPUSER} -p ${TOKEN}

4. Test the connection by pulling or pushing any image to OCP registry

# To Test
podman pull ${INTERNAL_REGISTRY}/openshift/python:latest

Now, you can use internal registry like any other image registry. 




Like the below page to get the update  
Facebook Page      Facebook Group      Twitter Feed      Telegram Group


No comments:

Post a Comment

Disclaimer

The postings on this site are my own and don't necessarily represent IBM's or other companies positions, strategies or opinions. All content provided on this blog is for informational purposes and knowledge sharing only.
The owner of this blog makes no representations as to the accuracy or completeness of any information on this site or found by following any link on this site. The owner will not be liable for any errors or omissions in this information nor for the availability of this information. The owner will not be liable for any losses, injuries, or damages from the display or use of his information.