Loading

创建一个k8s应用

一、创建一个测试用的deployment

[root@linux-node1 src]# kubectl run net-test --image=alpine --replicas=2 sleep 360000
deployment.apps "net-test" created

查看获取IP情况

[root@linux-node1 src]# kubectl get pod -o wide     #网络问题,等待一段时间
NAME                        READY     STATUS              RESTARTS   AGE       IP        NODE
net-test-5767cb94df-gdlqq   0/1       ContainerCreating   0          11s       <none>    192.168.56.12
net-test-5767cb94df-r2wp5   0/1       ContainerCreating   0          11s       <none>    192.168.56.13


[root@linux-node1 src]# kubectl get pod -o wide
NAME                        READY     STATUS    RESTARTS   AGE       IP          NODE
net-test-5767cb94df-gdlqq   1/1       Running   0          6m        10.2.13.2   192.168.56.12
net-test-5767cb94df-r2wp5   1/1       Running   0          6m        10.2.17.2   192.168.56.13

测试连通性

[root@linux-node1 src]# ping 10.2.13.2
PING 10.2.13.2 (10.2.13.2) 56(84) bytes of data.
64 bytes from 10.2.13.2: icmp_seq=1 ttl=63 time=1.00 ms
64 bytes from 10.2.13.2: icmp_seq=2 ttl=63 time=0.751 ms
^C
--- 10.2.13.2 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.751/0.879/1.007/0.128 ms
[root@linux-node1 src]# ping 10.2.17.2
PING 10.2.17.2 (10.2.17.2) 56(84) bytes of data.
64 bytes from 10.2.17.2: icmp_seq=1 ttl=63 time=1.01 ms
64 bytes from 10.2.17.2: icmp_seq=2 ttl=63 time=1.67 ms
^C
--- 10.2.17.2 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 1.010/1.342/1.675/0.334 ms

二、创建一个Nginx镜像

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.10.3
        ports:
        - containerPort: 80
nginx-deployment.yaml
[root@linux-node1 ~]# kubectl create -f nginx-deployment.yaml
deployment.apps "nginx-deployment" created
[root@linux-node1 ~]# kubectl get deployment
NAME               DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
net-test           2         2         2            2           15m
nginx-deployment   3         3         3            0           35s
[root@linux-node1 ~]# kubectl describe deployment nginx-deployment
Name:                   nginx-deployment
Namespace:              default
CreationTimestamp:      Thu, 31 May 2018 17:09:05 +0800
Labels:                 app=nginx
Annotations:            deployment.kubernetes.io/revision=1
Selector:               app=nginx
Replicas:               3 desired | 3 updated | 3 total | 0 available | 3 unavailable
StrategyType:           RollingUpdate
MinReadySeconds:        0
RollingUpdateStrategy:  25% max unavailable, 25% max surge
Pod Template:
  Labels:  app=nginx
  Containers:
   nginx:
    Image:        nginx:1.10.3
    Port:         80/TCP
    Host Port:    0/TCP
    Environment:  <none>
    Mounts:       <none>
  Volumes:        <none>
Conditions:
  Type           Status  Reason
  ----           ------  ------
  Available      False   MinimumReplicasUnavailable
  Progressing    True    ReplicaSetUpdated
OldReplicaSets:  <none>
NewReplicaSet:   nginx-deployment-75d56bb955 (3/3 replicas created)
Events:
  Type    Reason             Age   From                   Message
  ----    ------             ----  ----                   -------
  Normal  ScalingReplicaSet  1m    deployment-controller  Scaled up replica set nginx-deployment-75d56bb955 to 3


[root@linux-node1 ~]# kubectl get pod
NAME                                READY     STATUS              RESTARTS   AGE
net-test-5767cb94df-gdlqq           1/1       Running             0          17m
net-test-5767cb94df-r2wp5           1/1       Running             0          17m
nginx-deployment-75d56bb955-4bvhk   0/1       ImagePullBackOff    0          2m
nginx-deployment-75d56bb955-5kvfw   0/1       ContainerCreating   0          2m
nginx-deployment-75d56bb955-r5dr5   0/1       ContainerCreating   0          2m
[root@linux-node1 ~]# kubectl describe pod nginx-deployment-75d56bb955-4bvhk
Name:           nginx-deployment-75d56bb955-4bvhk
Namespace:      default
Node:           192.168.56.12/192.168.56.12
Start Time:     Thu, 31 May 2018 17:09:05 +0800
Labels:         app=nginx
                pod-template-hash=3181266511
Annotations:    <none>
Status:         Pending
IP:             10.2.13.3
Controlled By:  ReplicaSet/nginx-deployment-75d56bb955
Containers:
  nginx:
    Container ID:
    Image:          nginx:1.10.3
    Image ID:
    Port:           80/TCP
    Host Port:      0/TCP
    State:          Waiting
      Reason:       ImagePullBackOff
    Ready:          False
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-wn78r (ro)
Conditions:
  Type           Status
  Initialized    True
  Ready          False
  PodScheduled   True
Volumes:
  default-token-wn78r:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-wn78r
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     <none>
Events:
  Type     Reason                 Age              From                    Message
  ----     ------                 ----             ----                    -------
  Normal   Scheduled              3m               default-scheduler       Successfully assigned nginx-deployment-75d56bb955-4bvhk to 192.168.56.12
  Normal   SuccessfulMountVolume  3m               kubelet, 192.168.56.12  MountVolume.SetUp succeeded for volume "default-token-wn78r"
  Warning  Failed                 2m               kubelet, 192.168.56.12  Failed to pull image "nginx:1.10.3": rpc error: code = Unknown desc = error pulling image configuration: Get https://dseasb33srnrn.cloudfront.net/registry-v2/docker/registry/v2/blobs/sha256/03/0346349a1a640da9535acfc0f68be9d9b81e85957725ecb76f3b522f4e2f0455/data?Expires=1527760756&Signature=FsFobL4~r~N6zja0Nft-H-GlJCzxDZ6Ne-z-Ucnh-4iQe4fFi2m1bV9naqFWAo2ayIZHyo2FKdR4wujqZuqQKdwuj9L8bevbdIlKwy7qbBMFJq3n6g3jzmIjZ5QrlvV3AMD~hb60A2TRHtbOAtPgsYBEANbzJUnlnSDtpW8fxkg_&Key-Pair-Id=APKAJECH5M7VWIS5YZ6Q: net/http: TLS handshake timeout
  Warning  Failed                 2m               kubelet, 192.168.56.12  Error: ErrImagePull
  Normal   BackOff                2m               kubelet, 192.168.56.12  Back-off pulling image "nginx:1.10.3"
  Warning  Failed                 2m               kubelet, 192.168.56.12  Error: ImagePullBackOff

 

posted @ 2018-05-31 21:46  KubeSec  阅读(3400)  评论(1编辑  收藏  举报