返回总目录页

kubernetes部署第一个应用案例

对比有无-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>

 

posted @ 2022-01-04 00:46  马昌伟  阅读(1112)  评论(0编辑  收藏  举报
博主链接地址:https://www.cnblogs.com/machangwei-8/