These are the steps you can follow to access the internal OpenShift container registry.
Prerequisites
- You need to have an account and project on the Container Platform.
- You need to have Docker / Podman / Buildah installed locally to be able to tag and push images
- You need to have the OpenShift client tools installed.
- You need to have at least edit rights on your project / projects, which all developers should have.
In this example, we use a local build custom httpd container to push to OpenShift (localhost/custom-httpd:v4)
Steps
-
Login to the OpenShift GUI.
go to OpenShift Console
2. Login to the registry.
Enter your UU credentials and MFA token.
For more information about logging in visit: openshift Login
Click your username and the top right, followed by copy login command.
Press display token, copy login with this token. Such as:You can use your username and token to log in to the internal registry:
-
We now will tag the locally build http container.
The tag should have 4 fields:
REGISTRY / PROJECT / IMAGE_NAME / TAG in this case:
REGISTRY: registry.cp.its.uu.nl
here replace OPENSHIFT_PROJECT with the project you have access too, such as your own project (uu-xxxx) or a project for your team.
PROJECT: OPENSHIFT_PROJECT
IMAGE_NAME: custom-httpd
TAG: v3
-
Push the image.
$ docker push registry.cp.its.uu.nl/OPENSHIFT_PROJECT/custom-httpd:v4 The push refers to repository [registry.cp.its.uu.nl/OPENSHIFT_PROJECT/custom-httpd] ffef929ba8dc: Pushed 3dc4a1e9704d: Pushed b995345c8e67: Pushed ..... v4: digest: sha256:577fbe83f56331c1859a015127694a3e66cddc37abc0f01edafd153f226cdccc size: 2198 -
Show image
$ oc describe is/custom-httpd Name: custom-httpd Namespace: OPENSHIFT_PROJECT Created: 7 days ago Labels: <none> Annotations: <none> Image Repository: registry.cp.its.uu.nl/OPENSHIFT_PROJECT/custom-httpd Image Lookup: local=false Unique Images: 1 Tags: 1 v4 no spec tag * image-registry.openshift-image-registry.svc:5000/OPENSHIFT_PROJECT/custom-httpd@sha256:577fbe83f56331c1859a015127694a3e66cddc37abc0f01edafd153f226cdccc 5 minutes ago -
Create deployment with Container Image.
Deploying applications to OpenShift can be done on several ways, here as example the oc new-app command is used to create a deployment.
7. Remarks$ oc new-app --image=registry.cp.its.uu.nl/OPENSHIFT_PROJECT/custom-httpd:v4 --> Found container image 4b6c1e6 (6 weeks old) from registry.cp.its.uu.nl for "registry.cp.its.uu.nl/OPENSHIFT_PROJECT/custom-httpd:v4" * An image stream tag will be created as "custom-httpd:v4" that will track this image --> Creating resources ... deployment.apps "custom-httpd" created service "custom-httpd" created --> Success Application is not exposed. You can expose services to the outside world by executing one or more of the commands below: 'oc expose service/custom-httpd' Run 'oc status' to view your app.Note that by default, you can't access container images from other users, even if you have access to several projects.
Sometimes it can be desirable to have a project that holds all the container images and other acc / prd project that use those containers.
In such a setup, service accounts should be used which have the system:image-puller role attached.
If that is required, the Linux team can be contacted to create the service account / rolebinding.