zoukankan      html  css  js  c++  java
  • k8s从Harbor拉取启动镜像测试

    登陆harbor

    [root@k8s-master ~]#  docker login 192.168.180.105:1180
    Username: admin
    Password:
    WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
    Configure a credential helper to remove this warning. See
    https://docs.docker.com/engine/reference/commandline/login/#credentials-store
    
    Login Succeeded

    拉取启动

    [root@k8s-master ~]# kubectl run nginx-test --image=192.168.180.105:1180/topcheer/nginx:1.2 --port=80 --replicas=1
    kubectl run --generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version. Use kubectl run --generator=run-pod/v1 or kubectl create instead.
    deployment.apps/nginx-test created
    [root@k8s-master ~]# kubectl get rs
    NAME                    DESIRED   CURRENT   READY   AGE
    nginx-test-754bbf667c   1         1         0       17s
    [root@k8s-master ~]# kubectl get pod -o wide
    NAME                          READY   STATUS              RESTARTS   AGE   IP       NODE         NOMINATED NODE   READINESS GATES
    nginx-test-754bbf667c-q4z25   0/1     ContainerCreating   0          50s   <none>   k8s-node02   <none>           <none>
    [root@k8s-master ~]# kubectl get pod -o wide
    NAME                          READY   STATUS              RESTARTS   AGE   IP       NODE         NOMINATED NODE   READINESS GATES
    nginx-test-754bbf667c-q4z25   0/1     ContainerCreating   0          95s   <none>   k8s-node02   <none>           <none>

    发现一直没有启动,查看日志

    [root@k8s-master ~]# kubectl describe pod nginx-test-754bbf667c-q4z25
    Name:           nginx-test-754bbf667c-q4z25
    Namespace:      default
    Priority:       0
    Node:           k8s-node02/192.168.180.103
    Start Time:     Tue, 26 Nov 2019 22:13:31 +0800
    Labels:         pod-template-hash=754bbf667c
                    run=nginx-test
    Annotations:    <none>
    Status:         Pending
    IP:
    Controlled By:  ReplicaSet/nginx-test-754bbf667c
    Containers:
      nginx-test:
        Container ID:
        Image:          192.168.180.105:1180/topcheer/nginx:1.2
        Image ID:
        Port:           80/TCP
        Host Port:      0/TCP
        State:          Waiting
          Reason:       ContainerCreating
        Ready:          False
        Restart Count:  0
        Environment:    <none>
        Mounts:
          /var/run/secrets/kubernetes.io/serviceaccount from default-token-hd24d (ro)
    Conditions:
      Type              Status
      Initialized       True
      Ready             False
      ContainersReady   False
      PodScheduled      True
    Volumes:
      default-token-hd24d:
        Type:        Secret (a volume populated by a Secret)
        SecretName:  default-token-hd24d
        Optional:    false
    QoS Class:       BestEffort
    Node-Selectors:  <none>
    Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                     node.kubernetes.io/unreachable:NoExecute for 300s
    Events:
      Type    Reason     Age    From                 Message
      ----    ------     ----   ----                 -------
      Normal  Scheduled  2m53s  default-scheduler    Successfully assigned default/nginx-test-754bbf667c-q4z25 to k8s-node02
      Normal  Pulling    2m11s  kubelet, k8s-node02  Pulling image "192.168.180.105:1180/topcheer/nginx:1.2"

    日志中没有显示报错,需要在等等

    [root@k8s-master ~]# kubectl get pod -o wide
    NAME                          READY   STATUS    RESTARTS   AGE     IP           NODE         NOMINATED NODE   READINESS GATES
    nginx-test-754bbf667c-q4z25   1/1     Running   0          6m43s   10.244.1.2   k8s-node02   <none>           <none>
    [root@k8s-master ~]# kubectl get pod -o wide
    NAME                          READY   STATUS    RESTARTS   AGE     IP           NODE         NOMINATED NODE   READINESS GATES
    nginx-test-754bbf667c-q4z25   1/1     Running   0          6m49s   10.244.1.2   k8s-node02   <none>           <none>
    [root@k8s-master ~]# curl 10.244.1.2
    <!DOCTYPE html>
    <html>
    <head>
    <title>Welcome to nginx!</title>
    <style>
        body {
             35em;
            margin: 0 auto;
            font-family: Tahoma, Verdana, Arial, sans-serif;
        }
    </style>
    </head>
    <body>
    <h1>Welcome to nginx!</h1>
    <p>If you see this page, the nginx web server is successfully installed and
    working. Further configuration is required.</p>
    
    <p>For online documentation and support please refer to
    <a href="http://nginx.org/">nginx.org</a>.<br/>
    Commercial support is available at
    <a href="http://nginx.com/">nginx.com</a>.</p>
    
    <p><em>Thank you for using nginx.</em></p>
    </body>
    </html>

    上面显示,在等2个节点运行的

    [root@k8s-node02 ~]# docker ps -a
    CONTAINER ID        IMAGE                                 COMMAND                  CREATED             STATUS                      PORTS               NAMES
    b5323553263a        192.168.180.105:1180/topcheer/nginx   "nginx -g 'daemon of…"   2 minutes ago       Up 2 minutes                                    k8s_nginx-test_nginx-test-754bbf667c-q4z25_default_5a0b95b7-6853-4493-bebc-971847fc15e9_0

    成功,并启动完成

  • 相关阅读:
    win安装Theano
    Photoshop
    Sublime Text与LaTeX的结合
    Python开源库的bug
    Pillow库的学习和使用
    对OpenSSL心脏出血漏洞的试验
    Scrapy的学习和使用
    FreeImage库的学习和使用
    gdal库的学习和使用
    VirtualBox安装Debian
  • 原文地址:https://www.cnblogs.com/dalianpai/p/11939337.html
Copyright © 2011-2022 走看看