How to retain or manually set the service IP address for docker-registry in Openshift 3
Issue
- I deleted the registry how do I recreate one with the original service IP address.
- My registry got recreated with the wrong service IP address.
- How to I manually configure the docker registry with a service IP address of my choosing using an IP in the service ClusterIP subnet.
Resolution
- Follow the steps below to recreate the docker-regsitry with the a manually set service ClusterIP value:
-
Make note of the original IP address and back up the original deployment configuration.
# oc get service -n default NAME CLUSTER_IP PORT(S) SELECTOR docker-registry 172.30.222.215 5000/TCP docker-registry=default kubernetes 172.30.0.1 443/TCP,53/UDP,53/TCP <none> router 172.30.10.230 80/TCP router=router # oc export dc docker-registry -n default > registry-dc.yaml.bak -
Delete old docker-registry.
# oc delete all -l docker-registry -n default deploymentconfig "docker-registry" deleted route "docker-registry" deleted service "docker-registry" deleted pod "docker-registry-5-pajc3" deleted -
Create a new docker-registry template using the appropriate command from the documentation that matches your version (This page is not included, but the link has been rewritten to point to the nearest parent document.3.0, This page is not included, but the link has been rewritten to point to the nearest parent document.3.1, This page is not included, but the link has been rewritten to point to the nearest parent document.3.2, or 3.3) and then putting the output into a file.
# oadm registry --config=/etc/origin/master/admin.kubeconfig --credentials=/etc/origin/master/openshift-registry.kubeconfig --images='registry.access.redhat.com/openshift3/ose-${component}:${version}' -o yaml > registry.yaml -
Add
spec.clusterIPandspec.portalPwith the value of the ClusterIP of the old docker-registry to the docker-registry template created.# vim registry.yaml - apiVersion: v1 kind: Service metadata: creationTimestamp: null labels: docker-registry: default name: docker-registry spec: clusterIP: 172.30.222.215 portalIP: 172.30.222.215 ports: - name: 5000-tcp port: 5000 targetPort: 5000 -
Run
oc createadd the modified docker registry back to your environment# oc create -f registry.yaml deploymentconfig "docker-registry" created service "docker-registry" created -
Continue configuring your docker registry up to your specifications.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.