Prompt: What to do if I want to add an insecure private registry on OpenShift?
[ link: https://chatgpt.com/share/694cb775-4a94-800f-83d6-41b362672d88 ]
To use an insecure private registry (one without valid TLS or HTTPS) from an OpenShift cluster, you need to tell OpenShift’s image subsystem to treat that registry as insecure. In OpenShift 4.x this is done by editing the cluster-wide image configuration so that container runtimes (CRI-O) on all nodes will allow pulling/pushing from that registry without valid certificates.
Here’s how you can do it:
🛠️ 1. Add the insecure registry to the cluster configuration
OpenShift provides a custom resource image.config.openshift.io/cluster that controls registry behavior.
Run this command:
oc edit image.config.openshift.io/cluster
This will open an editor. In the spec section, add your registry under registrySources.insecureRegistries and include it in allowedRegistries so it’s permitted for image pulls/pushes:
Example snippet:
apiVersion: config.openshift.io/v1
kind: Image
metadata:
name: cluster
spec:
registrySources:
insecureRegistries:
- my.insecure.registry:5000
allowedRegistries:
- my.insecure.registry:5000
- quay.io
- registry.redhat.io
- image-registry.openshift-image-registry.svc:5000
⚠️ Important: If you use allowedRegistries, add all the registries you need (including default Red Hat and internal) because any not listed will be blocked.
🧠 What this does
insecureRegistries tells CRI-O and the cluster that this registry doesn’t enforce TLS and should be permitted.
allowedRegistries lists registries the cluster is allowed to pull/push images from.
The Machine Config Operator (MCO) watches this CR, updates every node’s /etc/containers/registries.conf, and restarts the container runtime accordingly.
🧪 2. Verify the configuration
After saving the edit, check that the insecure registry has been applied on a node:
oc debug node/<node-name> -- chroot /host cat /etc/containers/registries.conf
You should see your registry under something like:
[registries.insecure]
registries = ["my.insecure.registry:5000"]
🚀 3. (Optional) Use patches instead of editing
You can also apply the setting with a patch:
oc patch image.config.openshift.io/cluster --type=merge -p '{
"spec": {
"registrySources": {
"insecureRegistries": [
"my.insecure.registry:5000"
]
},
"allowedRegistries": [
"my.insecure.registry:5000",
"quay.io",
"registry.redhat.io",
"image-registry.openshift-image-registry.svc:5000"
]
}
}'
⚙️ Notes
Security: Insecure registries are a security risk and should be used only in controlled environments (e.g., dev).
In older OpenShift/OKD versions there were alternate methods (MachineConfig edits), but in OCP 4.x the image.config.openshift.io/cluster CR is the recommended way.
After changes, pods pulling from the insecure registry should now work without TLS errors.
If you want, I can also show how to create pull secrets or how to expose your private registry securely!
About the author
I’m Aiman, and I see the world through prompts. IBM by day, prompt tinkerer by night. Here I share experiments, failures, wins, and the random magic that happens when curiosity meets AI. Welcome to my lens of ideas {<●>}.
Comments
Join the discussionNo comments yet. Be the first to comment.