# Setup image registry

:::info
This article is partially written by ChatGPT !

:::


# Preparation

## Connect to your server with ssh

```bash
 ssh core@<ip>
```

## Create registry folder

```bash
mkdir /opt/registry-data
```

# Configuration

Now all steps must be executed on your computer.

## Create TLS certs

```bash
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

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

## Create definition

```bash
vim config.yaml
```

Add the following content:

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

## Import config

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

## Patch registry deployment

```bash
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

```bash
oc get pods -n openshift-image-registry
```


:::info
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**.

---

**Documents**

- [AS205126](https://docs.legodard.fr/s/bc661677-ac7d-4fe7-984e-e1f43ddf6287/doc/as205126-UD37o91h51)
- [Kubernetes](https://docs.legodard.fr/s/bc661677-ac7d-4fe7-984e-e1f43ddf6287/doc/kubernetes-AYsNjQV7SW)
- [Proxmox](https://docs.legodard.fr/s/bc661677-ac7d-4fe7-984e-e1f43ddf6287/doc/proxmox-TnNEgoRFwj)
- [DN42](https://docs.legodard.fr/s/bc661677-ac7d-4fe7-984e-e1f43ddf6287/doc/dn42-oTEE68Qn7n)
- [Openshift](https://docs.legodard.fr/s/bc661677-ac7d-4fe7-984e-e1f43ddf6287/doc/openshift-428FG3kMtg)
- [Openstack](https://docs.legodard.fr/s/bc661677-ac7d-4fe7-984e-e1f43ddf6287/doc/openstack-KJmz0J0klm)