zoukankan      html  css  js  c++  java
  • k8s ---kubectl 部署时,pull image 报错,拉取不到镜像

    1、kubectl describe pod tomcat-ccbc756f6-bh6wg  #查看信息如下报错

     2、在node节点

    [root@linux-node2 ~]# cat .docker/config.json |base64 -w 0
    ewoJImF1dGhzIjogewoJCSIxOTIuMTY4LjU2LjExIjogewoJCQkiYXV0aCI6ICJlbXA1T2pFeU16UTFOa0V1WTI5dCIKCQl9Cgl9LAoJIkh0dHBIZWFkZXJzIjogewoJCSJVc2VyLUFnZW50IjogIkRvY2tlci1DbGllbnQvMTguMDMuMC1jZSAobGludXgpIgoJfQp9[root@linux-node2 ~]#  cat .docker/config.json
    {
        "auths": {
            "192.168.56.11": {
                "auth": "emp5OjEyMzQ1NkEuY29t"
            }
        },
        "HttpHeaders": {
            "User-Agent": "Docker-Client/18.03.0-ce (linux)"
        }
    }You have new mail in /var/spool/mail/root
    [root@linux-node2 ~]#  cat .docker/config.json
    {
        "auths": {
            "192.168.56.11": {
                "auth": "emp5OjEyMzQ1NkEuY29t"
            }
        },
        "HttpHeaders": {
            "User-Agent": "Docker-Client/18.03.0-ce (linux)"
        }
    }[root@linux-node2 ~]#cat .docker/config.json |base64 -w 0
    ewoJImF1dGhzIjogewoJCSIxOTIuMTY4LjU2LjExIjogewoJCQkiYXV0aCI6ICJlbXA1T2pFeU16UTFOa0V1WTI5dCIKCQl9Cgl9LAoJIkh0dHBIZWFkZXJzIjogewoJCSJVc2VyLUFnZW50IjogIkRvY2tlci1DbGllbnQvMTguMDMuMC1jZSAobGludXgpIgoJfQp9
    .docker/config.json文件

    3、在master节点创建registry-pull-sercret.yaml文件

    [root@linux-node1 daemon]# cat registry-pull-sercret.yaml
    apiVersion: v1
    kind: Secret
    metadata:
      name: registry-pull-sercet
    data:
      .dockerconfigjson: ewoJImF1dGhzIjogewoJCSIxOTIuMTY4LjU2LjExIjogewoJCQkiYXV0aCI6ICJlbXA1T2pFeU16UTFOa0V1WTI5dCIKCQl9Cgl9LAoJIkh0dHBIZWFkZXJzIjogewoJCSJVc2VyLUFnZW50IjogIkRvY2tlci1DbGllbnQvMTguMDMuMC1jZSAobGludXgpIgoJfQp9
    type: kubernetes.io/dockerconfigjson
    registry-pull-sercret.yaml

    4、创建

    kubectl apply -f registry-pull-sercret.yaml

    5、修改tomcat.yaml

    [root@linux-node1 daemon]# cat deploy-tomcat.yaml 
    ---
    apiVersion: apps/v1beta2
    kind: Deployment
    metadata:
      name: tomcat
      labels:
        app: tomcat123
    spec:
      replicas: 3
      selector:
        matchLabels:
          app: tomcat
      template:
        metadata:
          labels:
            app: tomcat
        spec:
          imagePullSecrets:
          - name: registry-pull-sercet
          containers:
          - name: tomcat
            imagePullPolicy: Always
            image: 192.168.56.11/project/java-demo:master
            ports:
            - containerPort: 8080
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: tomcat-service
      labels:
        app: tomcat
    spec:
      type: NodePort
      ports:
      - port: 80
        targetPort: 8080
      selector:
        app: tomcat
    View Code

     最后测试正常了

  • 相关阅读:
    MySQL数据表命令
    Linux 系统多台主机之间做SSH免密码登陆
    CentOS7配置NFS网络文件系统
    windows10下安装pygame并验证成功
    Docker中的Dockerfile命令详解FROM RUN COPY ADD ENTRYPOINT...
    Docker中使用多阶段Dockerfile构建容器镜像image(镜像优化)
    CentOS7Linux中Docker容器平台的使用
    linux下文件的压缩与解压缩
    Linux修改系统默认Bash shell为Zsh shell
    CentOSLinux系统中Ansible自动化运维的安装以及利用Ansible部署JDK和Hadoop
  • 原文地址:https://www.cnblogs.com/zhaojingyu/p/12178445.html
Copyright © 2011-2022 走看看