如何判断K8S是否安装成功
使用kubeode一键部署k8s后,我想知道k8s是否安装成功了,怎么办呢?这时候就需要使用kubectl命令了。
1、使用kubectl get nodes检查k8s是否安装成功
kubectl get nodes
上述结果中,status字段非常重要,直接显示了node的状态,必须是ready才是成功的标志。
官方网站解释如下:
节点状况 | 描述 |
Ready | 如节点是健康的并已经准备好接收 Pod 则为 True;False 表示节点不健康而且不能接收 Pod;Unknown 表示节点控制器在最近 node-monitor-grace-period 期间(默认 40 秒)没有收到节点的消息 |
DiskPressure | True 表示节点存在磁盘空间压力,即磁盘可用量低, 否则为 False |
MemoryPressure | True 表示节点存在内存压力,即节点内存可用量低,否则为 False |
PIDPressure | True 表示节点存在进程压力,即节点上进程过多;否则为 False |
NetworkUnavailable | True 表示节点网络配置不正确;否则为 False |
2、增加-o wide参数检查nodes的ip
kubectl get nodes -o wide
-o wide | 以纯文本格式输出,包含所有附加信息。对于 Pod 包含节点名。 |
3、简略形式
kubectl get nodes -o name
4、API查询形式,可以查到比较丰富的信息
kubectl get nodes -o yaml
[root@node01 ~]# kubectl get nodes -o yaml
apiVersion: v1
items:
- apiVersion: v1
kind: Node
metadata:
annotations:
node.alpha.kubernetes.io/ttl: "0"
volumes.kubernetes.io/controller-managed-attach-detach: "true"
creationTimestamp: "2023-06-03T06:04:53Z"
labels:
beta.kubernetes.io/arch: amd64
beta.kubernetes.io/os: linux
kubernetes.io/arch: amd64
kubernetes.io/hostname: node01
kubernetes.io/os: linux
node.kubernetes.io/node: ""
name: node01
resourceVersion: "4166369"
uid: 26453d8f-02f9-4a83-ab92-a150dfe737d4
spec:
podCIDR: 100.64.1.0/24
podCIDRs:
- 100.64.1.0/24
status:
addresses:
- address: 192.168.235.139
type: InternalIP
- address: node01
type: Hostname
allocatable:
cpu: "32"
ephemeral-storage: "483173420666"
hugepages-1Gi: "0"
hugepages-2Mi: "0"
memory: 131757996Ki
pods: "110"
capacity:
cpu: "32"
ephemeral-storage: 524276716Ki
hugepages-1Gi: "0"
hugepages-2Mi: "0"
memory: 131860396Ki
pods: "110"
conditions:
- lastHeartbeatTime: "2023-06-03T06:05:29Z"
lastTransitionTime: "2023-06-03T06:05:29Z"
message: Calico is running on this node
reason: CalicoIsUp
status: "False"
type: NetworkUnavailable
- lastHeartbeatTime: "2023-07-05T09:32:29Z"
lastTransitionTime: "2023-06-03T06:04:53Z"
message: kubelet has sufficient memory available
reason: KubeletHasSufficientMemory
status: "False"
type: MemoryPressure
- lastHeartbeatTime: "2023-07-05T09:32:29Z"
lastTransitionTime: "2023-06-03T06:04:53Z"
message: kubelet has no disk pressure
reason: KubeletHasNoDiskPressure
status: "False"
type: DiskPressure
- lastHeartbeatTime: "2023-07-05T09:32:29Z"
lastTransitionTime: "2023-06-03T06:04:53Z"
message: kubelet has sufficient PID available
reason: KubeletHasSufficientPID
status: "False"
type: PIDPressure
- lastHeartbeatTime: "2023-07-05T09:32:29Z"
lastTransitionTime: "2023-06-03T06:05:34Z"
message: kubelet is posting ready status
reason: KubeletReady
status: "True"
type: Ready
daemonEndpoints:
kubeletEndpoint:
Port: 10250
images:
- names:
- mysql@sha256:f57eef421000aaf8332a91ab0b6c96b3c83ed2a981c29e6528b21ce10197cd16
- mysql:5.7
sizeBytes: 568629848
- names:
- calico/node:v3.15.5
sizeBytes: 437164545
- names:
- kubeguide/tomcat-app@sha256:7a9193c2e5c6c74b4ad49a8abbf75373d4ab76c8f8db87672dc526b96ac69ac4
- kubeguide/tomcat-app:v1
sizeBytes: 358241257
- names:
- portainer/agent@sha256:2c1abfac4937923e625be5f63a15f49a19cc4cca247c50f8746a9222023865a3
- portainer/agent:2.16.2
sizeBytes: 165665328
- names:
- calico/cni:v3.15.5
sizeBytes: 108767177
- names:
- calico/kube-controllers:v3.15.5
sizeBytes: 52865826
- names:
- coredns/coredns:1.9.3
sizeBytes: 48803555
- names:
- calico/pod2daemon-flexvol:v3.15.5
sizeBytes: 21894737
- names:
- registry.cn-hangzhou.aliyuncs.com/google_containers/pause-amd64:3.3
sizeBytes: 682696
nodeInfo:
architecture: amd64
bootID: f1efc214-e9dd-42d2-8426-978ec9161310
containerRuntimeVersion: docker://20.10.9
kernelVersion: 3.10.0-957.el7.x86_64
kubeProxyVersion: v1.23.5
kubeletVersion: v1.23.5
machineID: d05dd626909f446baae658ac5fbcf0cd
operatingSystem: linux
osImage: CentOS Linux 7 (Core)
systemUUID: A5076CD8-A6F3-4613-8EC0-A643AEC3CA1E
- apiVersion: v1
kind: Node
metadata:
annotations:
node.alpha.kubernetes.io/ttl: "0"
volumes.kubernetes.io/controller-managed-attach-detach: "true"
creationTimestamp: "2023-06-03T06:04:53Z"
labels:
beta.kubernetes.io/arch: amd64
beta.kubernetes.io/os: linux
kubernetes.io/arch: amd64
kubernetes.io/hostname: node02
kubernetes.io/os: linux
node.kubernetes.io/node: ""
name: node02
resourceVersion: "4166370"
uid: ac0b2b8f-0d93-414e-b0b7-65ff79056402
spec:
podCIDR: 100.64.0.0/24
podCIDRs:
- 100.64.0.0/24
status:
addresses:
- address: 192.168..235.189
type: InternalIP
- address: node02
type: Hostname
allocatable:
cpu: "16"
ephemeral-storage: "289899892666"
hugepages-1Gi: "0"
hugepages-2Mi: "0"
memory: 65704024Ki
pods: "110"
capacity:
cpu: "16"
ephemeral-storage: 314561516Ki
hugepages-1Gi: "0"
hugepages-2Mi: "0"
memory: 65806424Ki
pods: "110"
conditions:
- lastHeartbeatTime: "2023-06-03T06:08:36Z"
lastTransitionTime: "2023-06-03T06:08:36Z"
message: Calico is running on this node
reason: CalicoIsUp
status: "False"
type: NetworkUnavailable
- lastHeartbeatTime: "2023-07-05T09:35:56Z"
lastTransitionTime: "2023-06-03T06:07:59Z"
message: kubelet has sufficient memory available
reason: KubeletHasSufficientMemory
status: "False"
type: MemoryPressure
- lastHeartbeatTime: "2023-07-05T09:35:56Z"
lastTransitionTime: "2023-06-03T06:07:59Z"
message: kubelet has no disk pressure
reason: KubeletHasNoDiskPressure
status: "False"
type: DiskPressure
- lastHeartbeatTime: "2023-07-05T09:35:56Z"
lastTransitionTime: "2023-06-03T06:07:59Z"
message: kubelet has sufficient PID available
reason: KubeletHasSufficientPID
status: "False"
type: PIDPressure
- lastHeartbeatTime: "2023-07-05T09:35:56Z"
lastTransitionTime: "2023-06-03T06:08:40Z"
message: kubelet is posting ready status
reason: KubeletReady
status: "True"
type: Ready
daemonEndpoints:
kubeletEndpoint:
Port: 10250
images:
- names:
- calico/node:v3.15.5
sizeBytes: 437164545
- names:
- kubeguide/tomcat-app@sha256:7a9193c2e5c6c74b4ad49a8abbf75373d4ab76c8f8db87672dc526b96ac69ac4
- kubeguide/tomcat-app:v1
sizeBytes: 358241257
- names:
- calico/cni:v3.15.5
sizeBytes: 108767177
- names:
- calico/kube-controllers:v3.15.5
sizeBytes: 52865826
- names:
- coredns/coredns:1.9.3
sizeBytes: 48803555
- names:
- calico/pod2daemon-flexvol:v3.15.5
sizeBytes: 21894737
- names:
- registry.cn-hangzhou.aliyuncs.com/google_containers/pause-amd64:3.3
sizeBytes: 682696
nodeInfo:
architecture: amd64
bootID: b8343e9a-fa30-4909-99b2-b6150cfbfbd4
containerRuntimeVersion: docker://20.10.9
kernelVersion: 3.10.0-957.el7.x86_64
kubeProxyVersion: v1.23.5
kubeletVersion: v1.23.5
machineID: d05dd626909f446baae658ac5fbcf0cd
operatingSystem: linux
osImage: CentOS Linux 7 (Core)
systemUUID: AEB3646B-ED8E-4116-A54F-305FBB717C34
kind: List
metadata:
resourceVersion: ""
selfLink: ""
请先 后发表评论~