kubernetes部署第一個應用案例

馬昌偉發表於2022-01-04

對比有無-o wide引數的區別

kubectl get pod --all-namespaces
kubectl get pod --all-namespaces -o wide
如下,檢視所有Pod資訊,加上-o wide引數,能看到每個Pod的ip和k8s節點等資訊,看的多了

 

[machangwei@mcw7 ~]$ kubectl get pod --all-namespaces
NAMESPACE     NAME                           READY   STATUS             RESTARTS        AGE
kube-system   coredns-6d8c4cb4d-2296m        1/1     Running            1 (4h52m ago)   8h
kube-system   coredns-6d8c4cb4d-lphb2        1/1     Running            1 (4h52m ago)   8h
kube-system   etcd-mcw7                      1/1     Running            3               8h
kube-system   kube-apiserver-mcw7            1/1     Running            2               8h
kube-system   kube-controller-manager-mcw7   1/1     Running            4 (4h53m ago)   8h
kube-system   kube-flannel-ds-5pxmj          0/1     CrashLoopBackOff   49 (59s ago)    3h51m
kube-system   kube-flannel-ds-8gzfq          1/1     Running            0               4h57m
kube-system   kube-flannel-ds-s4qmj          0/1     CrashLoopBackOff   42 (80s ago)    3h14m
kube-system   kube-proxy-4lmsx               1/1     Running            0               3h51m
kube-system   kube-proxy-c5zmm               1/1     Running            0               8h
kube-system   kube-proxy-npmtv               1/1     Running            0               3h14m
kube-system   kube-scheduler-mcw7            1/1     Running            3 (4h53m ago)   8h
[machangwei@mcw7 ~]$ 
[machangwei@mcw7 ~]$ 
[machangwei@mcw7 ~]$ kubectl get pod --all-namespaces -o wide
NAMESPACE     NAME                           READY   STATUS             RESTARTS         AGE     IP           NODE   NOMINATED NODE   READINESS GATES
kube-system   coredns-6d8c4cb4d-2296m        1/1     Running            1 (4h59m ago)    8h      10.244.0.3   mcw7   <none>           <none>
kube-system   coredns-6d8c4cb4d-lphb2        1/1     Running            1 (4h59m ago)    8h      10.244.0.2   mcw7   <none>           <none>
kube-system   etcd-mcw7                      1/1     Running            3                8h      10.0.0.137   mcw7   <none>           <none>
kube-system   kube-apiserver-mcw7            1/1     Running            2                8h      10.0.0.137   mcw7   <none>           <none>
kube-system   kube-controller-manager-mcw7   1/1     Running            4 (4h59m ago)    8h      10.0.0.137   mcw7   <none>           <none>
kube-system   kube-flannel-ds-5pxmj          0/1     CrashLoopBackOff   50 (2m18s ago)   3h58m   10.0.0.138   mcw8   <none>           <none>
kube-system   kube-flannel-ds-8gzfq          1/1     Running            0                5h4m    10.0.0.137   mcw7   <none>           <none>
kube-system   kube-flannel-ds-s4qmj          0/1     CrashLoopBackOff   43 (2m42s ago)   3h21m   10.0.0.139   mcw9   <none>           <none>
kube-system   kube-proxy-4lmsx               1/1     Running            0                3h58m   10.0.0.138   mcw8   <none>           <none>
kube-system   kube-proxy-c5zmm               1/1     Running            0                8h      10.0.0.137   mcw7   <none>           <none>
kube-system   kube-proxy-npmtv               1/1     Running            0                3h21m   10.0.0.139   mcw9   <none>           <none>
kube-system   kube-scheduler-mcw7            1/1     Running            3 (4h59m ago)    8h      10.0.0.137   mcw7   <none>           <none>
[machangwei@mcw7 ~]$ 

 

檢視kubelet服務

如下:普通使用者加上sudo檢視狀態資訊,展示的資訊更多。這是kubernetes中,唯一沒有以容器形式執行的Kubernertes元件

[machangwei@mcw7 ~]$ systemctl status kubelet.service 
● kubelet.service - kubelet: The Kubernetes Node Agent
   Loaded: loaded (/usr/lib/systemd/system/kubelet.service; enabled; vendor preset: disabled)
  Drop-In: /usr/lib/systemd/system/kubelet.service.d
           └─10-kubeadm.conf
   Active: active (running) since Mon 2022-01-03 20:54:48 CST; 8h ago
     Docs: https://kubernetes.io/docs/
 Main PID: 41877 (kubelet)
   Memory: 65.6M
   CGroup: /system.slice/kubelet.service
           └─41877 /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --config=/var/lib/kubelet/config.ya...
[machangwei@mcw7 ~]$ 
[machangwei@mcw7 ~]$ 
[machangwei@mcw7 ~]$ sudo systemctl status kubelet.service 
● kubelet.service - kubelet: The Kubernetes Node Agent
   Loaded: loaded (/usr/lib/systemd/system/kubelet.service; enabled; vendor preset: disabled)
  Drop-In: /usr/lib/systemd/system/kubelet.service.d
           └─10-kubeadm.conf
   Active: active (running) since Mon 2022-01-03 20:54:48 CST; 8h ago
     Docs: https://kubernetes.io/docs/
 Main PID: 41877 (kubelet)
   Memory: 65.6M
   CGroup: /system.slice/kubelet.service
           └─41877 /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --config=/var/lib/kubelet/config.ya...

Jan 04 00:45:22 mcw7 kubelet[41877]: I0104 00:45:22.882382   41877 trace.go:205] Trace[1175956662]: "iptables ChainExists" (04-Jan-2022 00:45:06.975) (total time: 15906ms):
Jan 04 00:45:22 mcw7 kubelet[41877]: Trace[1175956662]: [15.906635619s] [15.906635619s] END
Jan 04 00:45:22 mcw7 kubelet[41877]: W0104 00:45:22.908527   41877 reflector.go:442] k8s.io/client-go/informers/factory.go:134: watch of *v1.RuntimeClass ended with: an error ...
Jan 04 00:45:22 mcw7 kubelet[41877]: W0104 00:45:22.908592   41877 reflector.go:442] k8s.io/kubernetes/pkg/kubelet/config/apiserver.go:66: watch of *v1.Pod ended with: an erro...
Jan 04 00:45:23 mcw7 kubelet[41877]: W0104 00:45:22.909431   41877 reflector.go:442] object-"kube-system"/"kube-flannel-cfg": watch of *v1.ConfigMap ended with: an error on th...
Jan 04 00:45:23 mcw7 kubelet[41877]: W0104 00:45:22.909490   41877 reflector.go:442] object-"kube-system"/"kube-proxy": watch of *v1.ConfigMap ended with: an error...m succeeding
Jan 04 00:45:23 mcw7 kubelet[41877]: E0104 00:45:22.685903   41877 event.go:276] Unable to write event: '&v1.Event{TypeMeta:v1.TypeMeta{Kind:"", APIVersion:""}, Ob...55", Generat
Jan 04 00:45:24 mcw7 kubelet[41877]: E0104 00:45:24.372904   41877 kubelet.go:2157] "Housekeeping took longer than 15s" err="housekeeping took too long" seconds=43.320536225
Jan 04 00:45:33 mcw7 kubelet[41877]: I0104 00:45:33.740561   41877 scope.go:110] "RemoveContainer" containerID="742e24b700514948f23ae7b06ded37b1c9234a05ac13fdd08f80aab0889c35ad"
Jan 04 00:45:33 mcw7 kubelet[41877]: I0104 00:45:33.879840   41877 scope.go:110] "RemoveContainer" containerID="de11102a90f955da94d5e316b3ada4adbfef6cc7b60cbae25c43f7396b0407a3"
Hint: Some lines were ellipsized, use -l to show in full.

應用部署案例:httpd(一個問題解決:/run/flannel/subnet.env: no such file or directory)

--replicas已經被棄用了,無法kubectl run指定副本數
下面包含遇到的 一個問題:/run/flannel/subnet.env: no such file or directory

部署應用

[machangwei@mcw7 ~]$ kubectl run httpd-app --image=httpd --replicas=1
Error: unknown flag: --replicas
See 'kubectl run --help' for usage.
[machangwei@mcw7 ~]$ kubectl run httpd-app --image=httpd --env="replicas=2"  #將它放在裡面,
pod/httpd-app created                                          #但是副本是預設的1,這樣env跟副本沒關係

檢視部署的應用

[machangwei@mcw7 ~]$ kubectl get deployment #當前沒有部署好 的應用
No resources found in default namespace.
[machangwei@mcw7 ~]$ kubectl get pod  #檢視剛剛部署的應用情況,這裡狀態一直是這樣的ContainerCreating,5分鐘過去還是麼有改變
NAME        READY   STATUS              RESTARTS   AGE
httpd-app   0/1     ContainerCreating   0          2m1s
[machangwei@mcw7 ~]$ kubectl get pod -o wide
NAME        READY   STATUS              RESTARTS   AGE    IP       NODE   NOMINATED NODE   READINESS GATES
httpd-app   0/1     ContainerCreating   0          1

檢視跑起來的容器有哪些,看剛剛建立的容器POD詳情

[machangwei@mcw7 ~]$ kubectl get pod --all-namespaces
NAMESPACE     NAME                           READY   STATUS              RESTARTS         AGE
default       httpd-app                      0/1     ContainerCreating   0                6m3s
kube-system   coredns-6d8c4cb4d-2296m        1/1     Running             1 (5h58m ago)    9h
kube-system   coredns-6d8c4cb4d-lphb2        1/1     Running             1 (5h58m ago)    9h
kube-system   etcd-mcw7                      1/1     Running             3                9h
kube-system   kube-apiserver-mcw7            1/1     Running             2                9h
kube-system   kube-controller-manager-mcw7   1/1     Running             4 (5h58m ago)    9h
kube-system   kube-flannel-ds-5pxmj          0/1     CrashLoopBackOff    61 (4m38s ago)   4h57m
kube-system   kube-flannel-ds-8gzfq          1/1     Running             0                6h3m
kube-system   kube-flannel-ds-s4qmj          0/1     CrashLoopBackOff    55 (30s ago)     4h20m
kube-system   kube-proxy-4lmsx               1/1     Running             0                4h57m
kube-system   kube-proxy-c5zmm               1/1     Running             0                9h
kube-system   kube-proxy-npmtv               1/1     Running             0                4h20m
kube-system   kube-scheduler-mcw7            1/1     Running             3 (5h58m ago)    9h

由上面可知,剛剛部署的應用是 httpd-app ,namespace是default。狀態是ContainerCreating,沒有ready。而且只有一個,不是兩個副本
根據上面的資訊檢視部署詳情。貌似我看到 Environment: replicas: 2,這裡應該是當成系統環境變數了

[machangwei@mcw7 ~]$  kubectl describe pod httpd-app --namespace=default
Name:         httpd-app
Namespace:    default
Priority:     0
Node:         mcw9/10.0.0.139
Start Time:   Tue, 04 Jan 2022 06:38:04 +0800
Labels:       run=httpd-app
Annotations:  <none>
Status:       Pending
IP:           
IPs:          <none>
Containers:
  httpd-app:
    Container ID:   
    Image:          httpd
    Image ID:       
    Port:           <none>
    Host Port:      <none>
    State:          Waiting
      Reason:       ContainerCreating
    Ready:          False
    Restart Count:  0
    Environment:
      replicas:  2
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-728h9 (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             False 
  ContainersReady   False 
  PodScheduled      True 
Volumes:
  kube-api-access-728h9:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              <none>
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type     Reason                  Age                     From               Message
  ----     ------                  ----                    ----               -------
  Normal   Scheduled               7m3s                    default-scheduler  Successfully assigned default/httpd-app to mcw9
  Warning  FailedCreatePodSandBox  6m56s                   kubelet            Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "80e204314b98b32c3ec47b12288e6888ef3a6cd4923a6e7ee9e77a072ef1189d" network for pod "httpd-app": networkPlugin cni failed to set up pod "httpd-app_default" network: open /run/flannel/subnet.env: no such file or directory
  Warning  FailedCreatePodSandBox  6m54s                   kubelet            Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "1db6657c883c79ff176ce5523f4e6e7dbd3a65278cf20777cf7e870f7b17473f" network for pod "httpd-app": networkPlugin cni failed to set up pod "httpd-app_default" network: open /run/flannel/subnet.env: no such file or directory
  Warning  FailedCreatePodSandBox  6m47s                   kubelet            Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "e2dc2971e915be8a693190d244bbd2b4c31a86ecc5ed7f11d48b89f913121cd2" network for pod "httpd-app": networkPlugin cni failed to set up pod "httpd-app_default" network: open /run/flannel/subnet.env: no such file or directory
  Warning  FailedCreatePodSandBox  6m34s                   kubelet            Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "c8a67cd41221a857c1795bf9739ecc68970fca82a06680b5093e915a48762b9c" network for pod "httpd-app": networkPlugin cni failed to set up pod "httpd-app_default" network: open /run/flannel/subnet.env: no such file or directory
  Warning  FailedCreatePodSandBox  6m33s                   kubelet            Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "574f061c8b01b9ac54a72d81dee6d8844cf375d7862335590a2a38ed66fcefa1" network for pod "httpd-app": networkPlugin cni failed to set up pod "httpd-app_default" network: open /run/flannel/subnet.env: no such file or directory
  Warning  FailedCreatePodSandBox  6m32s                   kubelet            Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "87f12760cfe8079bd3fc709327bd99f93b1cf2284b9832f748937a98db25a6d5" network for pod "httpd-app": networkPlugin cni failed to set up pod "httpd-app_default" network: open /run/flannel/subnet.env: no such file or directory
  Warning  FailedCreatePodSandBox  6m31s                   kubelet            Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "eb12e226a4233698e8aef1618910cfaad49be474363be9243fd2f9eced60f754" network for pod "httpd-app": networkPlugin cni failed to set up pod "httpd-app_default" network: open /run/flannel/subnet.env: no such file or directory
  Warning  FailedCreatePodSandBox  6m30s                   kubelet            Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "19c042430da85875f567bb9a872a559c423fc25acef91ffa154795e3bd8bbd75" network for pod "httpd-app": networkPlugin cni failed to set up pod "httpd-app_default" network: open /run/flannel/subnet.env: no such file or directory
  Warning  FailedCreatePodSandBox  6m29s                   kubelet            Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "670f4e24adcbe325b2b77a01a7a4e05d483ceb95dbcadf97bdf26dff1afd171d" network for pod "httpd-app": networkPlugin cni failed to set up pod "httpd-app_default" network: open /run/flannel/subnet.env: no such file or directory
  Normal   SandboxChanged          6m25s (x12 over 6m55s)  kubelet            Pod sandbox changed, it will be killed and re-created.
  Warning  FailedCreatePodSandBox  116s (x251 over 6m28s)  kubelet            (combined from similar events): Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "59edf6c07ceb9dc2db9eb5ba0a0b7263de5a2ab70099ba48c09a6867ef2e8084" network for pod "httpd-app": networkPlugin cni failed to set up pod "httpd-app_default" network: open /run/flannel/subnet.env: no such file or directory
[machangwei@mcw7 ~]$ 

journalctl  -u kubelet

journalctl  -u kubelet 這個命令普通使用者不能用,root在各個節點都能用,但是不太方便找錯誤資訊,我只會一點點往下拖進度

[root@mcw8 ~]$ journalctl  -u kubelet
-- Logs begin at Mon 2022-01-03 17:32:08 CST, end at Tue 2022-01-04 06:58:19 CST. --
Jan 03 18:10:12 mcw8 systemd[1]: Started kubelet: The Kubernetes Node Agent.
Jan 03 18:10:12 mcw8 systemd[1]: Starting kubelet: The Kubernetes Node Agent...
Jan 03 18:10:13 mcw8 kubelet[1940]: E0103 18:10:13.589113    1940 server.go:205] "Failed to load kubelet config file" err="failed to load Kubelet config file /var/lib/kubelet/con
Jan 03 18:10:13 mcw8 systemd[1]: kubelet.service: main process exited, code=exited, status=1/FAILURE
Jan 03 18:10:13 mcw8 systemd[1]: Unit kubelet.service entered failed state.

上面看到錯誤資訊是:Failed to create pod sandbox: ...open /run/flannel/subnet.env: no such file or directory
然後我用root看了下,這個檔案是存在的,
因為我是普通使用者執行部署應用的,部署報錯沒有這個檔案,會不會是我沒有它的寫許可權呢?我是修改這個檔案設定其它人可以寫或者是
用root去部署應用就可以了嗎?試一下
[root@mcw7 ~]$ ls /run/flannel/subnet.env -l
-rw-r--r-- 1 root root 96 Jan 4 00:42 /run/flannel/subnet.env


試試root部署應用

[root@mcw7 ~]$ kubectl run mcw1httpd-app --image=httpd  #我用root部署應用,但是報錯了
The connection to the server localhost:8080 was refused - did you specify the right host or port?
[machangwei@mcw7 ~]$ kubectl run mcw1httpd-app --image=httpd #用普通使用者就可以。果然root部署應用,好像哪裡有點問題
pod/mcw1httpd-app created
[machangwei@mcw7 ~]$ kubectl get pod
NAME            READY   STATUS              RESTARTS   AGE
httpd-app       0/1     ContainerCreating   0          31m
mcw1httpd-app   0/1     ContainerCreating   0          66s

 

[machangwei@mcw7 ~]$ kubectl get pod --all-namespaces
[machangwei@mcw7 ~]$  kubectl describe pod httpd-app --namespace=default #根據命令查出容器建立所在的節點,
Name:         httpd-app  
Namespace:    default
Priority:     0
Node:         mcw9/10.0.0.139  #是mcw9節點。

於是從mcw9節點上去檢視,發現有httpd-app容器不斷的在銷燬和重新建立。跟據kubectl describe pod httpd-app --namespace=default查出的後面的詳情,那也是有很多個記錄,應該是重試記錄。

[root@mcw9 ~]$ docker ps
CONTAINER ID   IMAGE                                                COMMAND                  CREATED       STATUS       PORTS     NAMES
881e2618fa9d   registry.aliyuncs.com/google_containers/kube-proxy   "/usr/local/bin/kube…"   5 hours ago   Up 5 hours             k8s_kube-proxy_kube-proxy-npmtv_kube-system_7f6b0d03-0d35-48ae-b091-5f1e0618ba85_0
75e85cb833df   registry.aliyuncs.com/google_containers/pause:3.6    "/pause"                 5 hours ago   Up 5 hours             k8s_POD_kube-proxy-npmtv_kube-system_7f6b0d03-0d35-48ae-b091-5f1e0618ba85_0
625efe596472   registry.aliyuncs.com/google_containers/pause:3.6    "/pause"                 5 hours ago   Up 5 hours             k8s_POD_kube-flannel-ds-s4qmj_kube-system_a8082592-8c92-4c48-98dc-c6b52ebb9498_0
[root@mcw9 ~]$ docker ps
CONTAINER ID   IMAGE                                                COMMAND                  CREATED        STATUS                  PORTS     NAMES
d7f65cd3d025   registry.aliyuncs.com/google_containers/pause:3.6    "/pause"                 1 second ago   Up Less than a second             k8s_POD_httpd-app_default_bb6090a2-b5e4-48a3-99b5-082bcc8f8d13_1934

主節點上看kubectl describe pod httpd-app 

--namespace=default報錯資訊,是沒有/run/flannel/subnet.env檔案。n,但是在node節點是不存在這個檔案的。;這個檔案是屬於flannel網路的。那麼,是否是主節點讓node節點建立容器,node節點沒有要在node本地找這個檔案嗎?如果是,那麼豈不是node本地也應該建立flannel網路呢?剛剛看了下資料。貌似架構圖中是,每個節點都需要部署flannel服務的

Warning FailedCreatePodSandBox 116s (x251 over 6m28s) kubelet (combined from similar events): Failed to create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "59edf6c07ceb9dc2db9eb5ba0a0b7263de5a2ab70099ba48c09a6867ef2e8084" network for pod "httpd-app": networkPlugin cni failed to set up pod "httpd-app_default" network: open /run/flannel/subnet.env: no such file or directory


可是我再node節點上 看了下,是部署了這個flannel網路的。那麼為什麼node節點沒有/run/flannel/subnet.env這個檔案呢,無法部署好應用是否和它有關係呢?

[root@mcw8 ~]$ docker ps |awk '{print $NF}'
NAMES
k8s_kube-proxy_kube-proxy-4lmsx_kube-system_fb743f5c-0f44-43a7-ad7e-78817ddafc12_0
k8s_POD_kube-flannel-ds-5pxmj_kube-system_0972d5b3-a774-44cc-94b1-6765ec8f4256_0
k8s_POD_kube-proxy-4lmsx_kube-system_fb743f5c-0f44-43a7-ad7e-78817ddafc12_0
[root@mcw8 ~]$ 

網上解決方案:open /run/flannel/subnet.env: no such file or directory

檢視pod的資訊時發現報錯:open /run/flannel/subnet.env: no such file or directory

一是檢視各個節點,包括master 節點是否有/run/flannel/subnet.env,內容應該是類似如下:

FLANNEL_NETWORK=10.244.0.0/16
FLANNEL_SUBNET=10.244.0.1/24
FLANNEL_MTU=1450
FLANNEL_IPMASQ=true
若有節點沒有該檔案那就拷貝一份。

二是在kubeadm init時是否新增標籤--pod-network-cidr=10.244.0.0/16這樣式的。如果環境允許可以 kubeadm reset,再重新init。


檢視node節點,有目錄但是沒有檔案

root@mcw8 ~]$ ls /run/flannel/
[root@mcw8 ~]$ 

[root@mcw9 ~]$ ls /run/flannel/
[root@mcw9 ~]$ 

在master節點,將這個檔案複製過去

[root@mcw7 ~]$ ls /run/flannel/subnet.env
/run/flannel/subnet.env
[root@mcw7 ~]$ scp /run/flannel/subnet.env 10.0.0.138:/run/flannel/
root@10.0.0.138's password: 
subnet.env                                                                                                                                      100%   96   230.1KB/s   00:00    
[root@mcw7 ~]$ scp /run/flannel/subnet.env 10.0.0.139:/run/flannel/
root@10.0.0.139's password: 
subnet.env                                                                                                                                      100%   96    88.6KB/s   00:00    
[root@mcw7 ~]$ 

然後在master節點用普通使用者獲取pod,發現有一個部署的應用已經是ready了,狀態已經是running了

[machangwei@mcw7 ~]$ kubectl get pod
NAME            READY   STATUS              RESTARTS   AGE
httpd-app       1/1     Running             0          63m
mcw1httpd-app   0/1     ContainerCreating   0          33m

打完上面的字再檢視,部署的兩個應用都好了

[machangwei@mcw7 ~]$ kubectl get pod
NAME            READY   STATUS    RESTARTS   AGE
httpd-app       1/1     Running   0          64m
mcw1httpd-app   1/1     Running   0          34m

部署的應用 POD 狀態是running後資訊檢視

[machangwei@mcw7 ~]$ kubectl get pod  #獲取pod資訊,剛剛部署的兩個應用,狀態running
NAME            READY   STATUS    RESTARTS   AGE
httpd-app       1/1     Running   0          67m
mcw1httpd-app   1/1     Running   0          37m
[machangwei@mcw7 ~]$ kubectl get pod -o wide  #加上引數,可以看到ip和node節點,ip是一樣的,不知道咋回事
NAME            READY   STATUS    RESTARTS   AGE   IP           NODE   NOMINATED NODE   READINESS GATES
httpd-app       1/1     Running   0          67m   10.244.0.2   mcw9   <none>           <none>
mcw1httpd-app   1/1     Running   0          37m   10.244.0.2   mcw8   <none>           <none>
[machangwei@mcw7 ~]$ kubectl get deployment
No resources found in default namespace.
[machangwei@mcw7 ~]$ kubectl get pod --all-namespaces #如下可以看到剛剛部署的兩個應用,都是屬於default的namespace
NAMESPACE     NAME                           READY   STATUS             RESTARTS         AGE
default       httpd-app                      1/1     Running            0                69m
default       mcw1httpd-app                  1/1     Running            0                39m
kube-system   coredns-6d8c4cb4d-2296m        1/1     Running            1 (7h2m ago)     10h
kube-system   coredns-6d8c4cb4d-lphb2        1/1     Running            1 (7h1m ago)     10h
kube-system   etcd-mcw7                      1/1     Running            3                10h
kube-system   kube-apiserver-mcw7            1/1     Running            2                10h
kube-system   kube-controller-manager-mcw7   1/1     Running            4 (7h2m ago)     10h
kube-system   kube-flannel-ds-5pxmj          0/1     CrashLoopBackOff   74 (93s ago)     6h1m
kube-system   kube-flannel-ds-8gzfq          1/1     Running            0                7h7m
kube-system   kube-flannel-ds-s4qmj          0/1     CrashLoopBackOff   67 (2m17s ago)   5h23m
kube-system   kube-proxy-4lmsx               1/1     Running            0                6h1m
kube-system   kube-proxy-c5zmm               1/1     Running            0                10h
kube-system   kube-proxy-npmtv               1/1     Running            0                5h23m
kube-system   kube-scheduler-mcw7            1/1     Running            3 (7h2m ago)     10h


[machangwei@mcw7 ~]$ kubectl get pod --all-namespaces -o wide #加上引數檢視
NAMESPACE     NAME                           READY   STATUS             RESTARTS         AGE     IP           NODE   NOMINATED NODE   READINESS GATES
default       httpd-app                      1/1     Running            0                73m     10.244.0.2   mcw9   <none>           <none>
default       mcw1httpd-app                  1/1     Running            0                43m     10.244.0.2   mcw8   <none>           <none>

 

相關文章