Я думаю, вы можете использовать imagePullSecrets
.
Вы должны создать docker-registry
секрет с URL и всеми аутентификациями, необходимыми для каждого из этапов / сегментов.
kubectl create secret docker-registry dev-bucket --docker-server=https://hub.docker.com --docker-username=user --docker-email=user@example.com --docker-password=password
Затем при создании POD
вы должны сделать что-то какНиже:
apiVersion: v1
kind: Pod
metadata:
name: test-pod
spec:
containers:
- name: test-container
image: <registry_name>/<image_name>:<tagname>
imagePullSecrets:
- name: dev-bucket
Пожалуйста, проверьте Облачный реестр Google (GCR) с внешним руководством Kubernetes и как Получить изображение из частного реестра
Не забудьте о создании учетной записи службы в gcloud с разрешениями для GCR и ключами для учетной записи службы.
Вы должны добавить tags
к своим изображениям, чтобы вы могли толкатьтолько одно изображение на другой тег.
РЕДАКТИРОВАТЬ:
Вот пример:
$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
d1725b59e92d: Pull complete
Digest: sha256:0add3ace90ecb4adbf7777e9aacf18357296e799f81cabc9fde470971e499788
Status: Downloaded newer image for hello-world:latest
Теперь мы добавим новые теги к нему
$ docker tag hello-world gcr.io/project-for-x/hello-world:dev_latest
$ docker push gcr.io/project-for-x/hello-world:dev_latest
The push refers to repository [gcr.io/project-for-x/hello-world]
428c97da766c: Layer already exists
dev_latest: digest: sha256:1a6fd470b9ce10849be79e99529a88371dff60c60aab424c077007f6979b4812 size: 524
$ docker tag hello-world gcr.io/project-for-x/hello-world:stage_latest
$ docker push gcr.io/project-for-x/hello-world:stage_latest
The push refers to repository [gcr.io/project-for-x/hello-world]
428c97da766c: Layer already exists
stage_latest: digest: sha256:1a6fd470b9ce10849be79e99529a88371dff60c60aab424c077007f6979b4812 size: 524
$ docker tag hello-world gcr.io/project-for-x/hello-world:prod_latest
$ docker push gcr.io/project-for-x/hello-world:prod_latest
The push refers to repository [gcr.io/project-for-x/hello-world]
428c97da766c: Layer already exists
prod_latest: digest: sha256:1a6fd470b9ce10849be79e99529a88371dff60c60aab424c077007f6979b4812 size: 524
Это создало hello-world
файлы внутри GCR
General information
Image type Docker Manifest, Schema 2
Media type :application/vnd.docker.distribution.manifest.v2+json
Virtual size :977 B
Uploaded time :October 24, 2018 at 3:07:49 PM UTC+2
Build ID :—
Container classification
Digest: sha256:1a6fd470b9ce10849be79e99529a88371dff60c60aab424c077007f6979b4812
Tags: dev_latest prod_latest stage_latest
Repository: hello-world
Project: project-for-x
Таким образом, вы можете иметь только один yaml
файл для развертывания одного и того же образа в разных средах.