Install docker-registry in openshift

there are a lot of docs regarding installation. I will post only commands here with very small comments.

  1.  if not exist:
    echo '{"kind":"ServiceAccount","apiVersion":"v1","metadata":{"name":"registry"}}' | oc create -n default -f -
  2. Add a line under users with the user name system:serviceaccount:default:registry in:
    oc edit scc privileged
  3. Create the registry and specify that it use the new registry service account:
    oadm registry --service-account=registry --config=/etc/origin/master/admin.kubeconfig --credentials=/etc/origin/master/openshift-registry.kubeconfig --latest-images
  4. in case you will use gluster storage (as me) to store registry. Create gluster endpoint file:
    apiVersion: v1
    kind: Endpoints
    metadata:
      name: gluster
    subsets:
    - addresses:
      - ip: 
      ports:
      - port: 1

    oc create -f gluster_endpoint.yml

  5. Attach GlusterFS volume to the registry:
    oc volume dc/docker-registry --add --overwrite --name=registry-storage --mount-path=/registry --source='{"glusterfs": { "endpoints": "gluster", "path": "/gluster/volume/name"}}'
  6. Update dc to run privileged container by updating tag privileged: true in deploymentconfig docker-registry:
    oc edit dc docker-registry
  7. Making it visible from outside by adding tag hostNetwork: true in deploymentconfig docker-registry (after dnsPolicy: ClusterFirst):
    oc edit dc docker-registry
  8. once new pod created checking repository content:
    oc login
    oc whoami -t
    docker login -u username -e any_email_address -p token_value docker_registry_host:5000
    docker pull docker.io/ubuntu
    docker tag docker.io/ubuntu docker_registry_host:5000/current_namespace/ubuntu
    docker push docker_registry_host:5000/current_namespace/ubuntu

PS. Used links:
Openshift – v1.GlusterfsVolumeSource
Openshift – volume source type
Openshift – Managing Volumes
Openshift – Deploying a Docker Registry

Leave a Reply