前言:

 在部署Kubernetes的过程中,需要从k8s.grc.io仓库中拉取部署所需的镜像文件,但是由于国内对国外的防火墙问题导致无法正常拉取,下面介绍一个方法来解决此问题,完成Kubernetes的正常部署。

问题描述:

 使用Kubernetes V1.22.1版本部署Kubernetes集群,在进行kubeadm init初始化时,需要从k8s.grc.io仓库拉取所需的镜像:

......
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'
[preflight] Some fatal errors occurred:[ERROR ImagePull]: failed to pull image [k8s.gcr.io/kube-apiserver-amd64:v1.22.1]: exit status 1[ERROR ImagePull]: failed to pull image [k8s.gcr.io/kube-controller-manager-amd64:v1.22.1]: exit status 1[ERROR ImagePull]: failed to pull image [k8s.gcr.io/kube-scheduler-amd64:v1.22.1]: exit status 1[ERROR ImagePull]: failed to pull image [k8s.gcr.io/kube-proxy-amd64:v1.22.1]: exit status 1[ERROR ImagePull]: failed to pull image [k8s.gcr.io/pause:3.5]: exit status 1[ERROR ImagePull]: failed to pull image [k8s.gcr.io/etcd-amd64:3.5.0]: exit status 1[ERROR ImagePull]: failed to pull image [k8s.gcr.io/coredns:1.8.4]: exit status 1
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`

解决方案:

 报错案例(使用相同方法解决):https://blog.csdn.net/qq_44895681/article/details/119956767?spm=1001.2014.3001.5501

 docker.io仓库对google的容器做了镜像,可以通过下列命令下拉取相关镜像:

docker pull mirrorgooglecontainers/kube-apiserver-amd64:v1.22.1
docker pull mirrorgooglecontainers/kube-controller-manager-amd64:v1.22.1
docker pull mirrorgooglecontainers/kube-scheduler-amd64:v1.22.1
docker pull mirrorgooglecontainers/kube-proxy-amd64:v1.22.1
docker pull mirrorgooglecontainers/pause:3.5
docker pull mirrorgooglecontainers/etcd-amd64:3.5.0
docker pull coredns/coredns:1.8.4

 拉取的镜像版本信息需要根据部署Kubernetes V1.22.1版本所需的实际情况进行相应的修改(即将下载下来的镜像标签版本信息改成kubeadm init初始化要求的镜像版本标签信息)。通过docker tag命令来修改镜像的标签:

docker tag docker.io/mirrorgooglecontainers/kube-proxy-amd64:v1.22.1 k8s.gcr.io/kube-proxy-amd64:v1.22.1
docker tag docker.io/mirrorgooglecontainers/kube-scheduler-amd64:v1.22.1 k8s.gcr.io/kube-scheduler-amd64:v1.22.1
docker tag docker.io/mirrorgooglecontainers/kube-apiserver-amd64:v1.22.1k8s.gcr.io/kube-apiserver-amd64:v1.22.1
docker tag docker.io/mirrorgooglecontainers/kube-controller-manager-amd64:v1.22.1 k8s.gcr.io/kube-controller-manager-amd64:v1.22.1
docker tag docker.io/mirrorgooglecontainers/etcd-amd64:3.5.0  k8s.gcr.io/etcd-amd64:3.5.0
docker tag docker.io/mirrorgooglecontainers/pause:3.5  k8s.gcr.io/pause:3.5
docker tag docker.io/coredns/coredns:1.8.4  k8s.gcr.io/coredns:1.8.4

 使用docker rmi删除不用的镜像,通过docker images命令显示,已经有我们需要的镜像文件,可以继续部署工作了:

[root@k8s-master ~]#  docker images
REPOSITORY                                                               TAG                 IMAGE ID            CREATED             SIZE
k8s.gcr.io/kube-proxy-amd64                                              v1.22.1             bea694275d97        1 days ago         97.8 MB
k8s.gcr.io/kube-scheduler-amd64                                          v1.22.1             ca43b177bese        1 days ago         56.8 MB
k8s.gcr.io/kube-apiserver-amd64                                          v1.22.1             3de571b6587b        1 days ago         187 MB
coredns/coredns                                                          1.8.4               b3154sdrecfc        1 days ago        45.6 MB
k8s.gcr.io/coredns                                                       1.8.4               b3b94275d97c        1 days ago        45.6 MB
k8s.gcr.io/etcd-amd64                                                    3.5.0               b8d1f5sa24f7        1 days ago        219 MB
k8s.gcr.io/pause                                                         3.5                 d6csa23rdsa1        1 days ago        742 kB

 重新初始化Kubernetes

[root@k8s-master ~]# kubeadm init --kubernetes-version=v1.22.1 --apiserver-advertise-address=192.168.1.18 --image-repository registry.aliyuncs.com/google0.0/16
[init] Using Kubernetes version: v1.22.1
[preflight] Running pre-flight checks[WARNING Service-Docker]: docker service is not enabled, please run 'systemctl enable docker.service'[WARNING Hostname]: hostname "k8s-master" could not be reached[WARNING Hostname]: hostname "k8s-master": lookup k8s-master on 192.168.1.1:53: no such host
[preflight] Pulling images required for setting up a Kubernetes cluster
[preflight] This might take a minute or two, depending on the speed of your internet connection
[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'
[certs] Using certificateDir folder "/etc/kubernetes/pki"
[certs] Generating "ca" certificate and key
[certs] Generating "apiserver" certificate and key
[certs] apiserver serving cert is signed for DNS names [k8s-master kubernetes kubernetes.default kubernetes.default.svc kubernetes.defa
[certs] Generating "apiserver-kubelet-client" certificate and key
[certs] Generating "front-proxy-ca" certificate and key
[certs] Generating "front-proxy-client" certificate and key
[certs] Generating "etcd/ca" certificate and key
[certs] Generating "etcd/server" certificate and key
[certs] etcd/server serving cert is signed for DNS names [k8s-master localhost] and IPs [192.168.1.18 127.0.0.1 ::1]
[certs] Generating "etcd/peer" certificate and key
[certs] etcd/peer serving cert is signed for DNS names [k8s-master localhost] and IPs [192.168.1.18 127.0.0.1 ::1]
[certs] Generating "etcd/healthcheck-client" certificate and key
[certs] Generating "apiserver-etcd-client" certificate and key
[certs] Generating "sa" key and public key
[kubeconfig] Using kubeconfig folder "/etc/kubernetes"
[kubeconfig] Writing "admin.conf" kubeconfig file
[kubeconfig] Writing "kubelet.conf" kubeconfig file
[kubeconfig] Writing "controller-manager.conf" kubeconfig file
[kubeconfig] Writing "scheduler.conf" kubeconfig file
[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[kubelet-start] Starting the kubelet
[control-plane] Using manifest folder "/etc/kubernetes/manifests"
[control-plane] Creating static Pod manifest for "kube-apiserver"
[control-plane] Creating static Pod manifest for "kube-controller-manager"
[control-plane] Creating static Pod manifest for "kube-scheduler"
[etcd] Creating static Pod manifest for local etcd in "/etc/kubernetes/manifests"
[wait-control-plane] Waiting for the kubelet to boot up the control plane as static Pods from directory "/etc/kubernetes/manifests". Th
[apiclient] All control plane components are healthy after 6.002108 seconds
[upload-config] Storing the configuration used in ConfigMap "kubeadm-config" in the "kube-system" Namespace
[kubelet] Creating a ConfigMap "kubelet-config-1.22" in namespace kube-system with the configuration for the kubelets in the cluster
[upload-certs] Skipping phase. Please see --upload-certs
[mark-control-plane] Marking the node k8s-master as control-plane by adding the labels: [node-role.kubernetes.io/master(deprecated) nod
[mark-control-plane] Marking the node k8s-master as control-plane by adding the taints [node-role.kubernetes.io/master:NoSchedule]
[bootstrap-token] Using token: 9t2nu9.00ieyfqmc50dgub6
[bootstrap-token] Configuring bootstrap tokens, cluster-info ConfigMap, RBAC Roles
[bootstrap-token] configured RBAC rules to allow Node Bootstrap tokens to get nodes
[bootstrap-token] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate cre
[bootstrap-token] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token
[bootstrap-token] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster
[bootstrap-token] Creating the "cluster-info" ConfigMap in the "kube-public" namespace
[kubelet-finalize] Updating "/etc/kubernetes/kubelet.conf" to point to a rotatable kubelet client certificate and key
[addons] Applied essential addon: CoreDNS
[addons] Applied essential addon: kube-proxyYour Kubernetes control-plane has initialized successfully!To start using your cluster, you need to run the following as a regular user:mkdir -p $HOME/.kubesudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/configsudo chown $(id -u):$(id -g) $HOME/.kube/configAlternatively, if you are the root user, you can run:export KUBECONFIG=/etc/kubernetes/admin.confYou should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:https://kubernetes.io/docs/concepts/cluster-administration/addons/Then you can join any number of worker nodes by running the following on each as root:kubeadm join 192.168.1.18:6443 --token 9t2nu9.00ieyfqmc50dgub6 \--discovery-token-ca-cert-hash sha256:183b6c95b4e49f0bd4074c61aeefc56d70215240fbeb7a633afe3526006c4dc9

 初始化成功,问题解决!

↓↓↓↓↓↓

最近刚申请了个微信公众号,上面也会分享一些运维知识,大家点点发财手关注一波,感谢大家。 【原创公众号】:非著名运维 【福利】:公众号回复 “资料” 送运维自学资料大礼包哦!

快速解决Kubernetes从k8s.gcr.io仓库拉取镜像失败问题相关推荐

  1. K8S从私有仓库拉取镜像

    通常来讲,我们在通过公共镜像仓库拉取docker镜像的时候,不需要任何的认证操作,但我们在构建了企业的私有镜像以后,就不得不在拉取镜像之前通过用户名密码来完成认证. 在docker单机环境中,我们可以 ...

  2. linux 从仓库拉取镜像,k8s 从私有仓库拉取镜像

    k8s 从私有仓库摘取镜像报错 with ErrImagePull: "rpc error: code = Unknown desc = Error response from daemon ...

  3. 使用阿里云源解决k8s安装拉取镜像失败的问题

    项目场景: Kubernetes在安装部署中,需要从k8s.grc.io仓库中拉取所需镜像文件,然而由于某些原因,无法成功进行拉取(即使使用proxychains仍然失败)此时我们可以使用阿里的源来进 ...

  4. 解决从k8s.gcr.io/gcr.io/quay.io等地址拉取镜像失败问题(Kubernetes国内镜像仓库地址)

    解决从k8s.gcr.io/gcr.io/quay.io等地址拉取镜像失败问题(Kubernetes国内镜像仓库地址) 参考文章: (1)解决从k8s.gcr.io/gcr.io/quay.io等地址 ...

  5. k8s实战之从私有仓库拉取镜像 - kubernetes

    1.实战目的 从私有docker仓库拉取镜像,部署pod.上一篇中,我们搭建了私有的镜像仓库,这一篇我们将与k8s结合实战使用私有仓库. 2.登录docker 为了完成本次实战,需要登录docker, ...

  6. 解决k8s中node拉取镜像失败问题

    在k8s集群的使用过程中,初学者可能会碰到这样的(怪异)问题: 在一个k8s集群里,部署服务(用的私有镜像仓库,如harbor)的时候,只有个别node的服务是部署成功的,其他都是部署失败的. 错误的 ...

  7. k8s 拉取镜像失败_k8s 拉取私有仓库失败

    k8s 报错拉取镜像失败 Error response from daemon: pull access denied for istio/citadel, repository does not e ...

  8. k8s拉取镜像失败处理 ImagePullBackOff ErrImageNeverPull

    目录 一.环境描述 二.pod失败状态 三.整体解决方案 四.补充一下Pod状态解释 一.环境描述 系统环境:CentOS Linux release 7.9.2009 (Core) 系统内核:Lin ...

  9. docker 从harbor 拉取镜像慢_Kubernetes-通过Rancher从Harbor私有仓库拉取镜像

    引言   前一篇文章详细描述了如何使用rancher搭建Kubernetes高可用集群,集群搭建好了后,我们就需要开始部署应用了,那么如何从私有镜像仓库拉取镜像呢? 原理   Harbor使用了基于角 ...

最新文章

  1. 构建dubbo分布式平台-maven构建根项目
  2. Spring3MVC+Mybatis3.1框架下的事务
  3. Linux之Server环境配置
  4. 【Java线程】互斥 同步 异步 并发 多线程的区别与联系
  5. linux c 11 运行库,11.1.3 运行库与I/O
  6. mysql联合索引测试
  7. 大数据分析目前面临哪些问题
  8. 毕设项目 - 基于SSM的药品管理系统(含源码+论文)
  9. 初学python------写一个心理测试
  10. OSEK直接网络管理软件开发
  11. Github上8个很棒的Vue项目
  12. 新站长建设网站需要学习知识
  13. Python大数据-电商产品评论情感数据分析
  14. Application Loader上传成功了 iTunes Connect不显示构建版本
  15. 什么是服务器未响应手机,手机服务器未响应
  16. 腾讯后端面试题python_腾讯后端开发,一面面试题分享
  17. Python四行代码实现的猜数字小游戏,基于thinker,带GUI界面
  18. JavaScript入门笔记(6)
  19. 扬州首套旅游数字藏品“扬州园林”,打造数字化元宇宙城市名片
  20. Airflow使用MsSqlHook与数据库交互

热门文章

  1. android微信运动页面开发,微信小程序仿微信运动步数排行(交互)
  2. Mathmatica简介
  3. 如何将自己的网站上传至服务器并通过域名进行访问
  4. 【心理咨询师考试笔记】基础理论(六)——心理咨询概论
  5. 抱薪者说 | 薪火相传,薪之不绝,火亦不熄
  6. 解决tomcat启动-Skipping unneeded JARs during scanning can improve startup time and JSP compilation time
  7. 你需要一份更绝佳的文章排版与设计
  8. Introduce Parameter Object (引入参数对象)
  9. 敏捷开发?敏捷管理?什么是敏捷?(一)
  10. OpenCV中文文档4.0.0学习笔记(更新中……)