Setup image registry

This article is partially written by ChatGPT !


Preparation

Connect to your server with ssh

 ssh core@<ip>

Create registry folder

mkdir /opt/registry-data

Configuration

Now all steps must be executed on your computer.

Create TLS certs

openssl req -newkey rsa:4096 -nodes -sha256 -keyout registry.key -x509 -days 2090 -out registry.crt

OpenSSL ask some information, you can fill fields but it’s optional.

Import TLS to secrets

oc create secret tls registry-certs --cert=registry.crt --key=registry.key -n openshift-image-registry

Create definition

vim config.yaml

Add the following content:

version: 0.1
storage:
  filesystem:
    rootdirectory: /opt/registry-data
http:
  tls:
    certificate:
      secretName: registry-certs

Import config

oc create configmap registry-config --from-file=config.yaml=config.yaml -n openshift-image-registry

Patch registry deployment

oc patch configs.imageregistry.operator.openshift.io/cluster --patch '{"spec":{"storage":{"emptyDir":{}},"managementState":"Managed","proxy":{},"registry":{"config":{"configMap": {"name": "registry-config","namespace": "openshift-image-registry"},"storage":{"pvc":{}}},"version":"v1"}}}' --type=merge

Verify if it works

oc get pods -n openshift-image-registry

Wait for the image-registry-xxx pod to be in the Running state.

You should now be able to push and pull images to/from your local registry using the URL image-registry.openshift-image-registry.svc:5000.