- Ensure you're logged in with
oc
- By default, a registry does not have an external route; if this is
required, the registry must be exposed:
- Follow the instructions to expose
the registry for your cluster version.
- Then, allow a user to push to the registry
oc policy add-role-to-user registry-editor $(oc whoami | sed 's/://g')
- Finally, allow a user to pull from the registry:
oc policy add-role-to-user registry-viewer $(oc whoami | sed 's/://g')
- Get the registry route and save to a variable:
REGISTRY=$(oc get route default-route -n openshift-image-registry --template='{{ .spec.host }}')
- Make sure it looks okay:
echo ${REGISTRY}
- Log into the registry:
podman login -u $(oc whoami | sed 's/://g') -p $(oc whoami -t) ${REGISTRY}
- For self-signed certificates, add
--tls-verify=false to
podman login
- After you've built some local container, list that image:
$ podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
localhost/perfcontainer latest b967130f1c6c About an hour ago 630 MB
- Tag the image for pushing to your registry (replace
$IMAGEID, $PROJECT, and $IMAGE)
podman tag $IMAGEID $REGISTRY/$PROJECT/$IMAGE
- Push the image to your registry:
podman push $REGISTRY/$PROJECT/$IMAGE
- List the image stream within the cluster (an image stream is an
indirect pointer to an image that allows updating the pointer without
re-building):
oc get imagestreams $IMAGE -n $PROJECT
- The image may now be referenced internally with
image-registry.openshift-image-registry.svc:5000/$PROJECT/$IMAGE
- Registry does not get exposed:
oc get route default-route -n openshift-image-registry is
returning
Error from server (NotFound): routes.route.openshift.io "default-route" not found
- Check if
oc get configs.imageregistry.operator.openshift.io/cluster -o jsonpath='{.spec.managementState}'
is set to Removed and if so, set it to
Managed:
oc patch configs.imageregistry.operator.openshift.io/cluster --patch '{"spec":{"managementState":"Managed"}}' --type=merge
- If
oc get configs.imageregistry.operator.openshift.io/cluster -o yaml
shows Error: storage backend not configured, then configure
some storage (e.g. PVC), or, for testing:
oc patch configs.imageregistry.operator.openshift.io/cluster --patch '{"spec":{"storage":{"emptyDir":{}}}}' --type=merge
- Example command combining all the common issues:
oc patch configs.imageregistry.operator.openshift.io/cluster --patch '{"spec":{"defaultRoute":true,"managementState":"Managed","storage":{"emptyDir":{}}}}' --type=merge
Previous Section (OpenShift General Troubleshooting Recipe) |
Next Section (OpenShift Remote into Container Recipe) |
Back to Table of Contents