Does kubernetes support alternative repository when pull or applying a deployment?

To minimize network problems, I created a local repository, mirroring Docker Hub. When applying a deployment, my local registry goes down. Is it possible to automatically change repository source to Docker Hub instead of my local repository? Applying then, redundancy.

Like:

...
containers:
- name: webserver
  image-1: registry.mydomain/nginx:latest
  image-2: nginx:latest
  imagePullPolicy: Always
...

Upvotes: 1

Views: 163

Answers (1)

Matt
Matt

Reputation: 74720

The kubernetes pod spec doesn't include the functionality to specify multiple container images, but the underlying container runtime can often be configured to do that.

Docker

When a specific prefix domain is not provided for an image, The docker.io registry is the first place Docker looks for an unscoped image. This is why docker pull mysql works. Docker has a registry-mirrors setting to modify this behaviour.

In daemon.json add:

{
  "registry-mirrors": [ "something.local" ],
}

This will cause Docker to look for non scoped images on something.local first, then docker.io.

Upvotes: 2

Related Questions