helm 国内镜像源配置

Repository(仓库) 是用来存放和共享 charts 的地方, 供 Kubernetes 包使用。

Helm 自带一个强大的搜索命令,可以用来从两种来源中进行搜索:

  • helm search hub 从 Artifact Hub 中查找并列出 helm charts。 Artifact Hub中存放了大量不同的仓库。

  • helm search repo 从你添加(使用 helm repo add)到本地 helm 客户端中的仓库中进行查找。该命令基于本地数据进行搜索,无需连接互联网。

Helm repo

helm repo 添加、列出、删除、更新和索引chart仓库

helm repo 添加仓库

1
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx

ingress-nginx 拉取的是google的镜像源,在国内网络环境常常会pull失败,

这时可以尝试替换为国内镜像源,或自建私有镜像源解决。

添加微软镜像源:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# 添加之前
helm repo list
NAME    URL
piaohua https://piaohua.github.io/helm-charts/
bitnami https://charts.bitnami.com/bitnami

# 添加之前搜索
helm search repo nginx
NAME                                    CHART VERSION   APP VERSION     DESCRIPTION
bitnami/nginx                           16.0.6          1.25.5          NGINX Open Source is a web server that can be a...
bitnami/nginx-ingress-controller        11.1.1          1.10.1          NGINX Ingress Controller is an Ingress controll...
bitnami/nginx-intel                     2.1.15          0.4.9           DEPRECATED NGINX Open Source for Intel is a lig...

# 添加源
helm repo add stable http://mirror.azure.cn/kubernetes/charts/

# 添加后搜索
helm search repo nginx
NAME                                    CHART VERSION   APP VERSION     DESCRIPTION
bitnami/nginx                           16.0.6          1.25.5          NGINX Open Source is a web server that can be a...
bitnami/nginx-ingress-controller        11.1.1          1.10.1          NGINX Ingress Controller is an Ingress controll...
bitnami/nginx-intel                     2.1.15          0.4.9           DEPRECATED NGINX Open Source for Intel is a lig...
stable/nginx-ingress                    1.41.3          v0.34.1         DEPRECATED! An nginx Ingress controller that us...
stable/nginx-ldapauth-proxy             0.1.6           1.13.5          DEPRECATED - nginx proxy with ldapauth
stable/nginx-lego                       0.3.1                           Chart for nginx-ingress-controller and kube-lego
stable/gcloud-endpoints                 0.1.2           1               DEPRECATED Develop, deploy, protect and monitor...

可以看到添加源后搜索镜像列表变化。

阿里云镜像源

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
helm repo add aliyun https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts/

# 添加后搜索
helm search repo nginx
NAME                                    CHART VERSION   APP VERSION     DESCRIPTION
aliyun/nginx-ingress                    0.9.5           0.10.2          An nginx Ingress controller that uses ConfigMap...
aliyun/nginx-lego                       0.3.1                           Chart for nginx-ingress-controller and kube-lego
bitnami/nginx                           16.0.6          1.25.5          NGINX Open Source is a web server that can be a...
bitnami/nginx-ingress-controller        11.1.1          1.10.1          NGINX Ingress Controller is an Ingress controll...
bitnami/nginx-intel                     2.1.15          0.4.9           DEPRECATED NGINX Open Source for Intel is a lig...
stable/nginx-ingress                    1.41.3          v0.34.1         DEPRECATED! An nginx Ingress controller that us...
stable/nginx-ldapauth-proxy             0.1.6           1.13.5          DEPRECATED - nginx proxy with ldapauth
stable/nginx-lego                       0.3.1                           Chart for nginx-ingress-controller and kube-lego
aliyun/gcloud-endpoints                 0.1.0                           Develop, deploy, protect and monitor your APIs ...
stable/gcloud-endpoints                 0.1.2           1               DEPRECATED Develop, deploy, protect and monitor...

docker 镜像源代理

docker proxy 使用文档

Google Kubernetes 常规镜像代理

    官方命令:docker pull k8s.gcr.io/username/image:tag 

    官方命令:docker pull registry.k8s.io/username/image:tag 

    代理命令:docker pull k8s.dockerproxy.com/username/image:tag

docker 通过配置文件使用镜像源代理,配置示例如下:

1
2
3
cat ~/.docker/daemon.json
{"registry-mirrors":["https://bmtdpkoz.mirror.aliyuncs.com","https://docker.mirrors.ustc.edu.cn"],"experimental":true,"debug":true,"features":{"buildkit":false}}%