镜像加速服务
基本使用方式
对于学术训练常用的开源镜像仓库,英博云在每个可用区内部署了镜像加速服务,将原始镜像镜像地址替换为加速地址,可以实现镜像拉取加速,具体规则如下:
GCR
Google Container Registry
替换规则:将gcr.io
替换为:registry-{region-label}-internal.ebcloud.com/gcr.io
示例(以华北一区为例):
# 原始命令:
docker pull gcr.io/cadvisor/cadvisor:v0.39.3
# 替换为:
docker pull registry-cn-huabei1-internal.ebcloud.com/gcr.io/cadvisor/cadvisor:v0.39.3
GHCR
Github Container Registry
替换规则:将ghcr.io
替换为:registry-{region-label}-internal.ebcloud.com/ghcr.io
示例(以华北一区为例):
# 原始命令:
docker pull ghcr.io/github/super-linter:latest
# 替换为:
docker pull registry-cn-huabei1-internal.ebcloud.com/ghcr.io/github/super-linter:latest
Quay
Quay Container Registry
替换规则:将quay.io
替换为:registry-{region-label}-internal.ebcloud.com/quay.io
示例(以华北一区为例):
# 原始命令:
docker pull quay.io/prometheus/prometheus:latest
# 替换为:
docker pull registry-cn-huabei1-internal.ebcloud.com/quay.io/prometheus/prometheus:latest
K8S
Kubernetes's container image registry
替换规则:将registry.k8s.io
替换为:registry-{region-label}-internal.ebcloud.com/registry.k8s.io
示例(以华北一区为例):
# 原始命令:
docker pull registry.k8s.io/pause:3.10
# 替换为:
docker pull registry-cn-huabei1-internal.ebcloud.com/registry.k8s.io/pause:3.10
NGC
NVIDIA NGC Catalog
替换规则:将nvcr.io
替换为:registry-{region-label}-internal.ebcloud.com/nvcr.io
示例(以华北一区为例):
# 原始命令:
docker pull nvcr.io/nvidia/cuda
# 替换为:
docker pull registry-cn-huabei1-internal.ebcloud.com/nvcr.io/nvidia/cuda
提交K8S工作负载自动加速
用yaml文件提交工作负载时,若命中了上述开源加速镜像,英博云会自动进行镜像地址替换,用户无需关注。
例如,若用户在华北一区提交如下工作负载:
# distroless.yaml
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: distroless-demo
spec:
replicas: 1
selector:
matchLabels:
app: distroless-demo
template:
metadata:
labels:
app: distroless-demo
spec:
containers:
- name: demo
image: gcr.io/distroless/static-debian12:debug-nonroot
command: ["/busybox/sleep", "3600"]
英博云会自动将镜像地址:gcr.io/distroless/static-debian12:debug-nonroot
,替换为:registry-cn-huabei1-internal.ebcloud.com/gcr.io/distroless/static-debian12:debug-nonroot
部署上述deployment后,kubectl describe pod
查看pod事件,可以看到如下输出:
kubectl apply -f distroless.yaml
kubectl get pods
NAME READY STATUS RESTARTS AGE
distroless-demo-5cff56ffbb-d7tp8 1/1 Running 0 6s
kubectl describe pod distroless-demo-5cff56ffbb-d7tp8
···
Normal Pulling 3m25s kubelet Pulling image "registry-cn-huabei1-internal.ebcloud.com/gcr.io/distroless/static-debian12:debug-nonroot"
Normal Pulled 3m18s kubelet Successfully pulled image "registry-cn-huabei1-internal.ebcloud.com/gcr.io/distroless/static-debian12:debug-nonroot" in 7.192s (7.192s including waiting). Image size: 3254726 bytes.
Normal Created 3m18s kubelet Created container demo
Normal Started 3m18s kubelet Started container demo
可以看到镜像地址:gcr.io已经完成了加速替换。