change container image registry in containerd to nexus proxy repository

112 views Asked by At

I setup docker hub proxy on nexus http mode and I want to change the default image registry in containerd .I have kubernetes cluster version 1.27 up and running.how can I achieve this?

2

There are 2 answers

0
Ali farahzadi On BEST ANSWER

1.run the nexus on docker using this docker-compose config on a remote server :

version: "3.7"
services:
  nexus:
    image: sonatype/nexus3
    expose:
      - 8081
      - 8082
      - 8083
    ports:
      - "8082:8082"
      - "8083:8083"
      - "8081:8081"
    volumes:
      - nexus:/nexus-data
    restart: always
volumes:
  nexus: 

2.create docker repository with type proxy in nexus that runs on port 8082:
3.enable Allow anonymous docker pull ( Docker Bearer Token Realm required ).:
4.set https://registry-1.docker.io as proxy
5.add this config to containerd conf file

version = 2
enabled_plugins = ["cri"]
[plugins."io.containerd.grpc.v1.cri".registry]
  [plugins."io.containerd.grpc.v1.cri".registry.mirrors]
    [plugins."io.containerd.grpc.v1.cri".registry.mirrors."95.217.127.212:8082"]
      endpoint = ["http://95.217.127.212:8082"]
  [plugins."io.containerd.grpc.v1.cri".registry.configs]
    [plugins."io.containerd.grpc.v1.cri".registry.configs."95.217.127.212:8082".tls]
      insecure_skip_verify = true
1
Sai Chandini Routhu On

In order to use version 1.27 of Nexus as a proxy registry for Docker Hub in your K8S cluster follow below steps:

Utilizing the standard feature known as image registry mirroring, k8s enables you to set up one registry, such as nexus, to serve as a cache for another registry, like docker hub.

  1. You must first establish an image repository policy and provide an image repository policy resource that the nexus registry should be used as the docker hub mirror.

  2. You can use this command kubectl create object -f with a yaml file to define the policy.

  3. Replace the references to the images in your current deployments or pods with those from the Nexus repository rather than the Docker Hub. Immediately utilize the nexus repository url and image name to change the image field in the container specification.

For effective caching, make sure your Nexus repository is set up as a Docker proxy repository. For more details refer to Sonatype Nexus doc on how to set it up as a Proxy Repository for Docker.**