Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 4. Accessing the registry
Use the following sections for instructions on accessing the registry, including viewing logs and metrics, as well as securing and exposing the registry.
You can access the registry directly to invoke podman commands. This allows you to push images to or pull them from the integrated registry directly using operations like podman push or podman pull. To do so, you must be logged in to the registry using the podman login command. The operations you can perform depend on your user permissions, as described in the following sections.
4.1. Prerequisites Copier lienLien copié sur presse-papiers!
-
You have access to the cluster as a user with the
cluster-adminrole. - You must have configured an identity provider (IDP).
For pulling images, for example when using the
podman pullcommand, the user must have theregistry-viewerrole. To add this role, run the following command:oc policy add-role-to-user registry-viewer <user_name>
$ oc policy add-role-to-user registry-viewer <user_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow For writing or pushing images, such as using
podman pushcommand, complete the following steps:Your account has the
registry-editorrole. To add this role, run the following command:oc policy add-role-to-user registry-editor <user_name>
$ oc policy add-role-to-user registry-editor <user_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Your cluster must have an existing project where the images can be pushed to.
4.2. Accessing the registry directly from the cluster Copier lienLien copié sur presse-papiers!
You can access the registry from inside the cluster by using internal routes.
Procedure
Access the node by getting its name:
oc get nodes
$ oc get nodesCopy to Clipboard Copied! Toggle word wrap Toggle overflow oc debug nodes/<node_name>
$ oc debug nodes/<node_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow To enable access to tools such as
ocandpodmanon the node, change your root directory to/host. Successful output on running the commands statesLogin Succeeded!.chroot /host
sh-4.2# chroot /hostCopy to Clipboard Copied! Toggle word wrap Toggle overflow Log in to the container image registry by using your access token:
oc login -u kubeadmin -p <password_from_install_log> https://api-int.<cluster_name>.<base_domain>:6443
sh-4.2# oc login -u kubeadmin -p <password_from_install_log> https://api-int.<cluster_name>.<base_domain>:6443Copy to Clipboard Copied! Toggle word wrap Toggle overflow podman login -u kubeadmin -p $(oc whoami -t) image-registry.openshift-image-registry.svc:5000
sh-4.2# podman login -u kubeadmin -p $(oc whoami -t) image-registry.openshift-image-registry.svc:5000Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteYou can pass almost any value for the user name. The token contains all necessary information. Passing a user name that contains colons results in a login failure.
The Image Registry Operator creates the route, such as
default-route-openshift-image-registry.<cluster_name>.Perform
podman pullandpodman pushoperations against your registry. The following example commands demonstrate these operations.Pull an arbitrary image:
podman pull <name.io>/<image>
sh-4.2# podman pull <name.io>/<image>Copy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantYou can pull arbitrary images, but if you have the system:registry role added, you can only push images to the registry in your project.
Tag the new image with the form
<registry_ip>:<port>/<project>/<image>. For example,172.30.124.220:5000/openshift/image. The project name must show in the pull specification for OpenShift Container Platform to correctly place and later access the image in the registry.podman tag <name.io>/<image> image-registry.openshift-image-registry.svc:5000/openshift/<image>
sh-4.2# podman tag <name.io>/<image> image-registry.openshift-image-registry.svc:5000/openshift/<image>Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteYou must have the
system:image-builderrole for the specified project, which allows the user to write or push an image. Otherwise, thepodman pushin the next step will fail. To test, you can create a new project to push the image.Push the newly tagged image to your registry:
podman push image-registry.openshift-image-registry.svc:5000/openshift/<image>
sh-4.2# podman push image-registry.openshift-image-registry.svc:5000/openshift/<image>Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteWhen pushing images to the internal registry, the repository name must use the
<project>/<name>format. Using multiple project levels in the repository name results in an authentication error.
4.3. Checking the status of the registry pods Copier lienLien copié sur presse-papiers!
As a cluster administrator, you can list the image registry pods running in the openshift-image-registry project and check their status.
Prerequisites
-
You have access to the cluster as a user with the
cluster-adminrole.
Procedure
List the pods in the
openshift-image-registryproject and view their status. Example output provided for demonstrative purposes.oc get pods -n openshift-image-registry
$ oc get pods -n openshift-image-registryCopy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow
4.4. Viewing registry logs Copier lienLien copié sur presse-papiers!
You can view the logs for the registry by using the oc logs command.
Procedure
Use the
oc logscommand with deployments to view the logs for the container image registry. Example output provided for demonstrative purposes.oc logs deployments/image-registry -n openshift-image-registry
$ oc logs deployments/image-registry -n openshift-image-registryCopy to Clipboard Copied! Toggle word wrap Toggle overflow 2015-05-01T19:48:36.300593110Z time="2015-05-01T19:48:36Z" level=info msg="version=v2.0.0+unknown" 2015-05-01T19:48:36.303294724Z time="2015-05-01T19:48:36Z" level=info msg="redis not configured" instance.id=9ed6c43d-23ee-453f-9a4b-031fea646002 2015-05-01T19:48:36.303422845Z time="2015-05-01T19:48:36Z" level=info msg="using inmemory layerinfo cache" instance.id=9ed6c43d-23ee-453f-9a4b-031fea646002 2015-05-01T19:48:36.303433991Z time="2015-05-01T19:48:36Z" level=info msg="Using OpenShift Auth handler" 2015-05-01T19:48:36.303439084Z time="2015-05-01T19:48:36Z" level=info msg="listening on :5000" instance.id=9ed6c43d-23ee-453f-9a4b-031fea646002
2015-05-01T19:48:36.300593110Z time="2015-05-01T19:48:36Z" level=info msg="version=v2.0.0+unknown" 2015-05-01T19:48:36.303294724Z time="2015-05-01T19:48:36Z" level=info msg="redis not configured" instance.id=9ed6c43d-23ee-453f-9a4b-031fea646002 2015-05-01T19:48:36.303422845Z time="2015-05-01T19:48:36Z" level=info msg="using inmemory layerinfo cache" instance.id=9ed6c43d-23ee-453f-9a4b-031fea646002 2015-05-01T19:48:36.303433991Z time="2015-05-01T19:48:36Z" level=info msg="Using OpenShift Auth handler" 2015-05-01T19:48:36.303439084Z time="2015-05-01T19:48:36Z" level=info msg="listening on :5000" instance.id=9ed6c43d-23ee-453f-9a4b-031fea646002Copy to Clipboard Copied! Toggle word wrap Toggle overflow
4.5. Accessing registry metrics Copier lienLien copié sur presse-papiers!
The OpenShift Container Registry provides an endpoint for Prometheus metrics. Prometheus is a stand-alone, open source systems monitoring and alerting toolkit. The metrics get exposed at the /extensions/v2/metrics path of the registry endpoint. You can access the metrics by running a metrics query that includes a cluster role.
Procedure
Create a cluster role if you do not already have one to access the metrics:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the cluster role to a user account by entering the following command:
oc adm policy add-cluster-role-to-user prometheus-scraper <username>
$ oc adm policy add-cluster-role-to-user prometheus-scraper <username>Copy to Clipboard Copied! Toggle word wrap Toggle overflow For the metrics query, get the user token.
openshift: $ oc whoami -t
openshift: $ oc whoami -tCopy to Clipboard Copied! Toggle word wrap Toggle overflow Run a metrics query in node or inside a pod. The following example command and output demonstrate this task.
curl --insecure -s -u <user>:<secret> \ https://image-registry.openshift-image-registry.svc:5000/extensions/v2/metrics | grep imageregistry | head -n 20$ curl --insecure -s -u <user>:<secret> \1 https://image-registry.openshift-image-registry.svc:5000/extensions/v2/metrics | grep imageregistry | head -n 20Copy to Clipboard Copied! Toggle word wrap Toggle overflow <user>:<secret>: The<user>object can be arbitrary, but<secret>tag must use the user token.Copy to Clipboard Copied! Toggle word wrap Toggle overflow