创建 deployment时 从 私有仓库 拉取镜像失败的解决办法 ErrImagePull

我刚开始的 ssm-deployment.yml 文件如下

使用 kubectl get deploy  结果如下

居然没有起来 因为我 pull  和push 镜像都没有问题 。然后我看 具体的Pod的状态如下

Failed to pull image "10.136.195.150:80/micro/ssm:latest": rpc error: code =

Unknown desc = Error response from daemon: pull access denied for 10.136.195.150:80/micro/ssm, repository does not exist or may require ‘do

cker login‘

可是 我已经登录 我自己的 私有仓库了啊

经过百度 发现需要配置 secret

命令如下

然后在 ssm-deployment.yml 中引用这个 secret 就可以了

[[email protected] ~]# kubectl get secretsNAME                  TYPE                                  DATA   AGEdefault-token-77vdj   kubernetes.io/service-account-token   3      40h[[email protected] ~]# vi ssm-deployment.yml [[email protected] ~]# kubectl get deployNAME                  READY   UP-TO-DATE   AVAILABLE   AGEkubernetes-bootcamp   1/1     1            1           26hnginx-deployment      2/2     2            2           26hssm-deployment        0/2     2            0           46m[[email protected] ~]# kubectl delete deploy ssm-deploymentdeployment.extensions "ssm-deployment" deleted[[email protected] ~]# kubectl apply -f ssm-deployment.yml deployment.apps/ssm-deployment created[[email protected] ~]# kubectl get deployNAME                  READY   UP-TO-DATE   AVAILABLE   AGEkubernetes-bootcamp   1/1     1            1           26hnginx-deployment      2/2     2            2           26hssm-deployment        0/2     2            0           9s[[email protected] ~]# kubectl get deployNAME                  READY   UP-TO-DATE   AVAILABLE   AGEkubernetes-bootcamp   1/1     1            1           26hnginx-deployment      2/2     2            2           26hssm-deployment        0/2     2            0           14s[[email protected] ~]# kubectl get podsNAME                                  READY   STATUS             RESTARTS   AGEkubernetes-bootcamp-76fcb8587-cd7s7   1/1     Running            1          26hnginx-deployment-5754944d6c-pf256     1/1     Running            1          26hnginx-deployment-5754944d6c-r7ths     1/1     Running            1          26hssm-deployment-855cd7f589-48qcg       0/1     InvalidImageName   0          20sssm-deployment-855cd7f589-skmxx       0/1     InvalidImageName   0          20s[[email protected] ~]# kubectl get podsNAME                                  READY   STATUS             RESTARTS   AGEkubernetes-bootcamp-76fcb8587-cd7s7   1/1     Running            1          26hnginx-deployment-5754944d6c-pf256     1/1     Running            1          26hnginx-deployment-5754944d6c-r7ths     1/1     Running            1          26hssm-deployment-855cd7f589-48qcg       0/1     InvalidImageName   0          30sssm-deployment-855cd7f589-skmxx       0/1     InvalidImageName   0          30s[[email protected] ~]# [[email protected] ~]# kubectl get podsNAME                                  READY   STATUS             RESTARTS   AGEkubernetes-bootcamp-76fcb8587-cd7s7   1/1     Running            1          26hnginx-deployment-5754944d6c-pf256     1/1     Running            1          26hnginx-deployment-5754944d6c-r7ths     1/1     Running            1          26hssm-deployment-855cd7f589-48qcg       0/1     InvalidImageName   0          34sssm-deployment-855cd7f589-skmxx       0/1     InvalidImageName   0          34s[[email protected] ~]# kubectl get podsNAME                                  READY   STATUS             RESTARTS   AGEkubernetes-bootcamp-76fcb8587-cd7s7   1/1     Running            1          26hnginx-deployment-5754944d6c-pf256     1/1     Running            1          26hnginx-deployment-5754944d6c-r7ths     1/1     Running            1          26hssm-deployment-855cd7f589-48qcg       0/1     InvalidImageName   0          36sssm-deployment-855cd7f589-skmxx       0/1     InvalidImageName   0          36s[[email protected] ~]# kubectl describe pod ssm-deployment-855cd7f589-skmxxName:           ssm-deployment-855cd7f589-skmxxNamespace:      defaultPriority:       0Node:           node1/10.136.195.150Start Time:     Thu, 14 Nov 2019 11:31:45 +0800Labels:         app=ssm-service                pod-template-hash=855cd7f589Annotations:    <none>Status:         PendingIP:             10.244.1.47Controlled By:  ReplicaSet/ssm-deployment-855cd7f589Containers:  ssm:    Container ID:       Image:          http://10.136.195.150:80/micro/ssm:latest    Image ID:           Port:           8070/TCP    Host Port:      0/TCP    State:          Waiting      Reason:       InvalidImageName    Ready:          False    Restart Count:  0    Environment:    <none>    Mounts:      /var/run/secrets/kubernetes.io/serviceaccount from default-token-77vdj (ro)Conditions:  Type              Status  Initialized       True   Ready             False   ContainersReady   False   PodScheduled      True Volumes:  default-token-77vdj:    Type:        Secret (a volume populated by a Secret)    SecretName:  default-token-77vdj    Optional:    falseQoS Class:       BestEffortNode-Selectors:  <none>Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s                 node.kubernetes.io/unreachable:NoExecute for 300sEvents:  Type     Reason         Age               From               Message  ----     ------         ----              ----               -------  Normal   Scheduled      60s               default-scheduler  Successfully assigned default/ssm-deployment-855cd7f589-skmxx to node1  Warning  InspectFailed  2s (x6 over 59s)  kubelet, node1     Failed to apply default image tag "http://10.136.195.150:80/micro/ssm:latest": couldn‘t parse image reference "http://10.136.195.150:80/micro/ssm:latest": invalid reference format  Warning  Failed         2s (x6 over 59s)  kubelet, node1     Error: InvalidImageName[[email protected] ~]# kubectl get deployNAME                  READY   UP-TO-DATE   AVAILABLE   AGEkubernetes-bootcamp   1/1     1            1           26hnginx-deployment      2/2     2            2           26hssm-deployment        0/2     2            0           95s[[email protected] ~]# kubectl delete deploy ssm-deploymentdeployment.extensions "ssm-deployment" deleted[[email protected] ~]# vi ssm-deployment.yml [[email protected] ~]# kubectl apply -f ssm-deployment.yml deployment.apps/ssm-deployment created[[email protected] ~]# kubectl get deployNAME                  READY   UP-TO-DATE   AVAILABLE   AGEkubernetes-bootcamp   1/1     1            1           26hnginx-deployment      2/2     2            2           26hssm-deployment        0/2     2            0           7s[[email protected] ~]# kubectl get deployNAME                  READY   UP-TO-DATE   AVAILABLE   AGEkubernetes-bootcamp   1/1     1            1           26hnginx-deployment      2/2     2            2           26hssm-deployment        0/2     2            0           11s[[email protected] ~]# kubectl get deployNAME                  READY   UP-TO-DATE   AVAILABLE   AGEkubernetes-bootcamp   1/1     1            1           26hnginx-deployment      2/2     2            2           26hssm-deployment        0/2     2            0           13s[[email protected] ~]# kubectl get podsNAME                                  READY   STATUS         RESTARTS   AGEkubernetes-bootcamp-76fcb8587-cd7s7   1/1     Running        1          26hnginx-deployment-5754944d6c-pf256     1/1     Running        1          26hnginx-deployment-5754944d6c-r7ths     1/1     Running        1          26hssm-deployment-5959dfbb8b-cls58       0/1     ErrImagePull   0          18sssm-deployment-5959dfbb8b-hcwhf       0/1     ErrImagePull   0          18s[[email protected] ~]# bubectl describe pod ssm-deployment-5959dfbb8b-cls58-bash: bubectl: command not found[[email protected] ~]# kubectl describe pod ssm-deployment-5959dfbb8b-cls58Name:           ssm-deployment-5959dfbb8b-cls58Namespace:      defaultPriority:       0Node:           node1/10.136.195.150Start Time:     Thu, 14 Nov 2019 11:35:34 +0800Labels:         app=ssm-service                pod-template-hash=5959dfbb8bAnnotations:    <none>Status:         PendingIP:             10.244.1.49Controlled By:  ReplicaSet/ssm-deployment-5959dfbb8bContainers:  ssm:    Container ID:       Image:          micro/ssm:latest    Image ID:           Port:           8070/TCP    Host Port:      0/TCP    State:          Waiting      Reason:       ErrImagePull    Ready:          False    Restart Count:  0    Environment:    <none>    Mounts:      /var/run/secrets/kubernetes.io/serviceaccount from default-token-77vdj (ro)Conditions:  Type              Status[[email protected] ~]# kubectl create secret docker-registry regsecret --docker-server=registry.cn-hangzhou.aliyuncs.com [email protected] --docker-password=xxxxxx [email protected]/regsecret created[[email protected] ~]# [[email protected] ~]# [[email protected] ~]# [[email protected] ~]# 作者:殷临风-bash: 作者:殷临风: command not found[[email protected] ~]# 链接:https://www.jianshu.com/p/fd13c2762d81-bash: 链接:https://www.jianshu.com/p/fd13c2762d81: No such file or directory[[email protected] ~]# 来源:简书-bash: 来源:简书: command not found                                                                                           ^C[[email protected] ~]# kubectl create secret docker-registry regsecret --docker-server=registry.cn-hangzhou.aliyuncs.com --docker-username=yin321Error: required flag(s) "docker-password" not set

Examples:[[email protected] ~]# kubectl create secret docker-registry regsecret --docker-server=10.136.195.150:80 --docker-username=adminError: required flag(s) "docker-password" not set

Examples:  # If you don‘t already have a .dockercfg file, you can create a dockercfg secret directly by using:  kubectl create secret docker-registry my-secret --docker-server=DOCKER_REGISTRY_SERVER --docker-username=DOCKER_USER --docker-password=DOCKER_PASSWORD --docker-email=DOCKER_EMAIL
Options:      --allow-missing-template-keys=true: If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.      --append-hash=false: Append a hash of the secret to its name.      --docker-email=‘‘: Email for Docker registry      --docker-password=‘‘: Password for Docker registry authentication      --docker-server=‘https://index.docker.io/v1/‘: Server location for Docker registry      --docker-username=‘‘: Username for Docker registry authentication      --dry-run=false: If true, only print the object that would be sent, without sending it.      --from-file=[]: Key files can be specified using their file path, in which case a default name will be given to them, or optionally with a name and file path, in which case the given name will be used.  Specifying a directory will iterate each named file in the directory that is a valid secret key.      --generator=‘secret-for-docker-registry/v1‘: The name of the API generator to use.  -o, --output=‘‘: Output format. One of: json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-file.      --save-config=false: If true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.      --template=‘‘: Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].      --validate=true: If true, use a schema to validate the input before sending it
Usage:  kubectl create secret docker-registry NAME --docker-username=user --docker-password=password --docker-email=email [--docker-server=string] [--from-literal=key1=value1] [--dry-run] [options]
Use "kubectl options" for a list of global command-line options (applies to all commands).
required flag(s) "docker-password" not set[[email protected] ~]# kubectl create secret docker-registry regsecret --docker-server=10.136.195.150:80 --docker-username=admin -- docker-possword Harbor12345Error: required flag(s) "docker-password" not set

[[email protected] ~]# kubectl create secret docker-registry regsecret \> --docker-server=10.136.195.150:80 \> --docker-username=admin \> --docker-password=Harbor12345 \> ^C[[email protected] ~]# kubectl create secret docker-registry regsecret --docker-server=10.136.195.150:80 --docker-username=admin --docker-password=Harbor12345Error from server (AlreadyExists): secrets "regsecret" already exists[[email protected] ~]# kubectl create secret docker-registry myregsecret --docker-server=10.136.195.150:80 --docker-username=admin --docker-password=Harbor12345secret/myregsecret created[[email protected] ~]# kubectl get secretsNAME                  TYPE                                  DATA   AGEdefault-token-77vdj   kubernetes.io/service-account-token   3      41hmyregsecret           kubernetes.io/dockerconfigjson        1      18sregsecret             kubernetes.io/dockerconfigjson        1      4m7s[[email protected] ~]# lsanaconda-ks.cfg  kube-flannel.yml  nginx-deployment.yml  nginx-service.yml  ssm-deployment.yml  ssm-service.yml[[email protected] ~]# vi ssm-deployment.yml [[email protected] ~]# kubectl get deployNAME                  READY   UP-TO-DATE   AVAILABLE   AGEkubernetes-bootcamp   1/1     1            1           26hnginx-deployment      2/2     2            2           26hssm-deployment        0/2     2            0           15m[[email protected] ~]# kubectl delete deploy ssm-deploymentdeployment.extensions "ssm-deployment" deleted[[email protected] ~]# kubectl apply -f ssm-deployment.yml deployment.apps/ssm-deployment created[[email protected] ~]# kubectl get deployNAME                  READY   UP-TO-DATE   AVAILABLE   AGEkubernetes-bootcamp   1/1     1            1           26h

原文地址:https://www.cnblogs.com/gaohq/p/11856183.html

时间: 2024-08-29 04:40:29

创建 deployment时 从 私有仓库 拉取镜像失败的解决办法 ErrImagePull的相关文章

使用docker pull从镜像仓库拉取镜像时报错

[[email protected] ~]# docker pull centos Using default tag: latest Trying to pull repository docker.io/library/centos ... Get https://registry-1.docker.io/v2/: dial tcp: lookup registry-1.docker.io on 119.29.29.29:53: read udp 192.168.100.100:59205-

Kubernetes从私有镜像仓库中拉取镜像

当我们尝试从私有仓库中拉取镜像时,可能会收到这样提示:requested access to the resource is denied Error response from daemon: pull access denied for xxx repository does not exist or may require 'docker login': denied: requested access to the resource is denied  这是由于访问私有仓库时是需要凭证

局域网部署docker--从无到有创建自己的docker私有仓库

由于GFW的关系,国内用户在使用docker的时候,pull一个基本的镜像都拉下来,更不用说使用官方的index镜像了.差点放弃使用docker了,google了一圈,总算找到办法. 第一步:安装docker 参见官方指南或则各类中文指南 第二步:从文件系统创建一个image镜像 创建镜像有很多方法,官方的推荐是pull一个,无奈GFW,想下一个基本的ubuntu都下不下来 还有一个办法就是从一个文件系统import一个镜像,个人推荐可以使用opvz的模板来创建: openvz的模板下载地址如下

Docker Hub.拉取镜像

注:此记录谨基于默认在搭建好的docker环境下进行!   拉取镜像很假单,只需要一个“docker pull 镜像名“的命令即可.当然,前提是我们已经在一个已经搭建好的docker环境下.但是,如何将拉取到主机的镜像下载到本地电脑呢.请看如下记录: 假设我们要拉取的镜像是一个note基础镜像,那么我们执行的命令首先是:docker pull note .当镜像下载成功,我们需要检查一下,该镜像是否已经存在主机了.可以执行:docker images 查看镜像是否存在,如果没错的话,应该是有 n

SharePoint 创建SSP时出现异常,信息如 设置失败: 找不到 Windows NT 用户或组 &#39;【

1.安装完sharepoint后,使用"sharepoint产品和技术配置向导"配置时,中间有连接sql server时输入的用户名和信息,(如果域是test.com)切记只能输入test/administrator的用户名格式.   2.如果还有这样的问题,可以打上sharepoint的补丁包,参考网址:    http://support.microsoft.com/kb/953471 SharePoint 创建SSP时出现异常,信息如 设置失败: 找不到 Windows NT 用

【Docker学习之三】Docker查找拉取镜像、启动容器、容器使用

环境 docker-ce-19.03.1-3.el7.x86_64 CentOS 7 一.查找.拉取镜像.启动容器1.查找镜像-docker search默认查找Docker Hub上的镜像,举例:Docker安装nginx [[email protected] ~]# docker search nginx NAME DESCRIPTION STARS OFFICIAL AUTOMATED nginx Official build of Nginx. 11866 [OK] jwilder/ng

yiic创建YII应用 &quot;php.exe&quot;不是内部或外部命令 解决办法

第一步:运行CMD命令. 第二步:进入Yiic文件的目录   (例如在D盘里面 D:/yii/framework) 第三步:D:\yii\framework>yiic webapp D:/xampp/htdocs/filename (D:/xampp/htdocs 为WebRoot,filename为要创建的应用名字) Create a Web application under 'D:\xampp\htdocs\mywebsite'? [yes|no] (提示是否创建应用) 在执行yiic w

chart.js插件生成折线图时数据普遍较大时Y轴数据不从0开始的解决办法[bubuko.com]

chart.js插件生成折线图时数据普遍较大时Y轴数据不从0开始的解决办法,原文: 默认情况下如下图 Y轴并不是从0开始,这样折现图的幅度会很大,不是正常的幅度,解决办法如下, 示例代码: window.onload = function () { var ctx = document.getElementById("canvas").getContext("2d"); window.myLine = new Chart(ctx).Line(lineChartDat

Python-使用unrar库时Couldn&#39;t find path to unrar library的解决办法

在Pycharm安装完unrar后,还要安装rar官方的库 不然运行的时候会抛出Couldn't find path to unrar library的错误 Windows: 下载rarlib的库文件,地址:http://www.rarlab.com/rar/UnRARDLL.exe 下载安装,默认设置就好了 安装完成后要设置环境变量 如果是64位操作系统 设置完环境变量后重启Pycharm Linux: 下载地址:http://www.rarlab.com/rar/unrarsrc-5.4.5