Image Registery

assume you already have a private image registery

and want build a POD use image in this private image registery.

here is how

kubectl create secret docker-registry aliyun181 --docker-server=registry.cn-hangzhou.aliyuncs.com/andydemo/test001 --docker-username=email@com --docker-password=somepassword --docker-email=email@com

this is to create k8s secret for image to use. then in your POD yaml file , specify the imagePullSecrets.

apiVersion: v1
kind: Pod
metadata:
name: busybox1
labels:
app: busybox1
namespace: default
spec:
containers:
- name: web
image: registry.cn-hangzhou.aliyuncs.com/andydemo/test001:latest
imagePullSecrets:
- name: aliyun181

--

--

when try to pull image from k8s.gcr.io. it always failed with error messages like below although I have http_proxy configured.

failed to pull image “k8s.gcr.io/kube-apiserver:v1.17.17”: output: Error response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
, error: exit status 1

Couple things need to be fixed to solve this issue.

i@master-node:/etc/systemd/system$ sudo mkdir -p /etc/systemd/system/docker.service.d
i@master-node:/etc/systemd/system$ sudo touch /etc/systemd/system/docker.service.d/proxy.conf
i@master-node:/etc/systemd/system$ sudo chmod 777 /etc/systemd/system/docker.service.d/proxy.conf
i@master-node:/etc/systemd/system$ sudo vi
/etc/systemd/system/docker.service.d/proxy.conf
i@master-node:/etc/systemd/system/docker.service.d$ cat proxy.conf
[Service]
Environment="HTTP_PROXY=http://127.0.0.1:8123/"
Environment="HTTPS_PROXY=http://127.0.0.1:8123/"
i@master-node:/etc/systemd/system$ sudo systemctl daemon-reload
i@master-node:/etc/systemd/system$ sudo systemctl restart docker
i@master-node:/etc/systemd/system$ sudo systemctl show — property=Environment docker
Environment=HTTP_PROXY=http://127.0.0.1:8123/ HTTPS_PROXY=http://127.0.0.1:8123/

2. DNS name

--

--