02.查看节点的状态

指令如下:


kubectl get nodes
kubectl describe node NODE_NAME

输出如下(这儿只关注status字段中得addresses、capacity、allocatable、conditions):

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139

status:
  addresses:
  - address: 192.168.23.61
    type: InternalIP
  - address: node2
    type: Hostname
  allocatable:
    cpu: "2"
    ephemeral-storage: "27761957638"
    hugepages-2Mi: "0"
    memory: 3777764Ki
    pods: "110"
  capacity:
    cpu: "2"
    ephemeral-storage: 30123652Ki
    hugepages-2Mi: "0"
    memory: 3880164Ki
    pods: "110"
  conditions:
  - lastHeartbeatTime: "2021-12-24T09:47:07Z"
    lastTransitionTime: "2021-12-24T09:47:07Z"
    message: Flannel is running on this node
    reason: FlannelIsUp
    status: "False"
    type: NetworkUnavailable
  - lastHeartbeatTime: "2021-12-29T06:26:44Z"
    lastTransitionTime: "2021-12-24T09:46:37Z"
    message: kubelet has sufficient memory available
    reason: KubeletHasSufficientMemory
    status: "False"
    type: MemoryPressure
  - lastHeartbeatTime: "2021-12-29T06:26:44Z"
    lastTransitionTime: "2021-12-24T09:46:37Z"
    message: kubelet has no disk pressure
    reason: KubeletHasNoDiskPressure
    status: "False"
    type: DiskPressure
  - lastHeartbeatTime: "2021-12-29T06:26:44Z"
    lastTransitionTime: "2021-12-24T09:46:37Z"
    message: kubelet has sufficient PID available
    reason: KubeletHasSufficientPID
    status: "False"
    type: PIDPressure
  - lastHeartbeatTime: "2021-12-29T06:26:44Z"
    lastTransitionTime: "2021-12-24T09:46:43Z"
    message: kubelet is posting ready status
    reason: KubeletReady
    status: "True"
    type: Ready
  daemonEndpoints:
    kubeletEndpoint:
      Port: 10250
  images:
  - names:
    - rancher/rancher@sha256:f411ee37efa38d7891c11ecdd5c60ca73eb03dcd32296678af808f6b4ecccfff
    - rancher/rancher:v2.6.3
    sizeBytes: 1162917989
  - names:
    - rancher/shell@sha256:9c33c0e58ceb0b3cb6a85d2a6349b1f7fe818e383e6a3cb46671558fbb2f7781
    - rancher/shell:v0.1.14
    sizeBytes: 170950834
  - names:
    - rancher/fleet-agent@sha256:c929f1f23b69a7269921aba5b7c4c407428fb978939101659f72e441863b332b
    - rancher/fleet-agent:v0.3.8
    sizeBytes: 154998416
  - names:
    - nginx@sha256:c97ee70c4048fe79765f7c2ec0931957c2898f47400128f4f3640d0ae5d60d10
    - nginx:1.8
    sizeBytes: 133241734
  - names:
    - k8s.gcr.io/kube-proxy@sha256:d5334eee53a3f0ddff4588b25e7e7f5bbd96b9a728eee0ae1a19c0e1b23c29d5
    - k8s.gcr.io/kube-proxy:v1.21.8
    sizeBytes: 103567283
  - names:
    - nginx@sha256:e3456c851a152494c3e4ff5fcc26f240206abac0c9d794affb40e0714846c451
    - nginx:1.7.9
    sizeBytes: 91664166
  - names:
    - rancher/fleet@sha256:b83872e82bf2f1b47133e6052823a8854297f974dc0e236142fcec2173b48218
    - rancher/fleet:v0.3.8
    sizeBytes: 73351324
  - names:
    - quay.io/coreos/flannel@sha256:9a296fbb67790659adc3701e287adde3c59803b7fcefe354f1fc482840cdb3d9
    - quay.io/coreos/flannel:v0.15.1
    sizeBytes: 69516425
  - names:
    - quay.io/jetstack/cert-manager-controller@sha256:330f19ed47bdbd34a0c11c5a58ccceead1b118eb29aa7202d374e71003937d48
    - quay.io/jetstack/cert-manager-controller:v1.5.1
    sizeBytes: 63334645
  - names:
    - rancher/gitjob@sha256:6c0ecbe6f566cee572d572689a569aed67661ce7b2a1ec22581821dabc9aad58
    - rancher/gitjob:v0.1.23
    sizeBytes: 61509831
  - names:
    - eipwork/metrics-server@sha256:2a8e43d89e434b6235858444bb0701c44bd03475d2937fdf6831a7bb4ee14240
    - eipwork/metrics-server:v0.3.7
    sizeBytes: 55367782
  - names:
    - quay.io/jetstack/cert-manager-webhook@sha256:45934ab42749e8c90da0726734155374f4ea55d7796246264e7adea87569918a
    - quay.io/jetstack/cert-manager-webhook:v1.6.1
    sizeBytes: 46625554
  - names:
    - quay.io/jetstack/cert-manager-webhook@sha256:d6c8924dc61a2d6e83f21f4bf584ff6b5a8837afe7342a044a90bc3c0f75009a
    - quay.io/jetstack/cert-manager-webhook:v1.5.1
    sizeBytes: 46396684
  - names:
    - quay.io/jetstack/cert-manager-cainjector@sha256:910eb00317ccb8482f39f395027fb40f1ed6a28f834970b5ff66aeb1bb89f8c8
    - quay.io/jetstack/cert-manager-cainjector:v1.5.1
    sizeBytes: 42243730
  - names:
    - quay.io/jetstack/cert-manager-cainjector@sha256:916ef12af73c8a4cbdfb6127d6f513f476f3aeed2447ec7f1a58a95113bda713
    - quay.io/jetstack/cert-manager-cainjector:v1.6.1
    sizeBytes: 42000784
  - names:
    - wangyanglinux/myapp@sha256:9c3dc30b5219788b2b8a4b065f548b922a34479577befb54b03330999d30d513
    - wangyanglinux/myapp:v1
    sizeBytes: 15504557
  - names:
    - rancher/mirrored-flannelcni-flannel-cni-plugin@sha256:bfe8f30c74bc6f31eba0cc6659e396dbdd5ab171314ed542cc238ae046660ede
    - rancher/mirrored-flannelcni-flannel-cni-plugin:v1.0.0
    sizeBytes: 9031177
  - names:
    - k8s.gcr.io/pause@sha256:6c3835cab3980f11b83277305d0d736051c32b17606f5ec59f1dda67c9ba3810
    - k8s.gcr.io/pause:3.4.1
    sizeBytes: 682696
  nodeInfo:
    architecture: amd64
    bootID: 9661796e-a93d-4f48-8999-b80eb2d48cad
    containerRuntimeVersion: docker://20.10.6
    kernelVersion: 3.10.0-1160.el7.x86_64
    kubeProxyVersion: v1.21.0
    kubeletVersion: v1.21.0
    machineID: 9cf3ac32ce194bcf946e35b4419afbe4
    operatingSystem: linux
    osImage: CentOS Linux 7 (Core)
    systemUUID: 5979B22F-C64B-4F24-A195-64A08DC3AC84


addresses

capacity

allocatable

conditions

描述了节点的状态,conditons的例子有:

  1. OutOfDisk:磁盘空间不足,无法运行新的Pod时则为True,否则为False
  2. Ready:节点健康且可以接受新的Pod,则为True,否则我False
  3. MemoryPressure:内存紧张则为True,否则为False
  4. PIDPressure:进程过多则为True,否则为False
  5. DiskPressure:磁盘空间紧张则为True,否则为False
  6. NetworkUnvailable:网络配置有问题则为True,否则为False