登陆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 {
        width: 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

成功,并启动完成

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐