简体   繁体   English

如何检查 Kubernetes 集群是否运行良好

[英]How to check if Kubernetes cluster is running fine

I have a Kubernetes cluster running.我有一个 Kubernetes 集群正在运行。 I used:我用了:

kubeadm init --apiserver-advertise-address=192.168.20.101 --pod-network-cidr=10.244.0.0/16

This is working okay.这工作正常。 Now I'm putting this in a script and I only want to execute kubeadm init again if my cluster is not running fine.现在我把它放在一个脚本中,如果我的集群运行不正常,我只想再次执行 kubeadm init。 How can I check if a Kubernetes cluster is running fine?如何检查 Kubernetes 集群是否运行良好? So if not I can recreate the cluster.所以如果没有,我可以重新创建集群。

You can use the following command to do that:您可以使用以下命令来执行此操作:

[root@ip-10-0-1-19]# kubectl cluster-info
Kubernetes master is running at https://10.0.1.197:6443
KubeDNS is running at https://10.0.1.197:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

It shows that your master is running fine on particular url.它表明您的主人在特定 url 上运行良好。

kubectl get cs

The above command would display the health of controller, scheduler and etcd as Healthy if your cluster is fine如果您的集群正常,上面的命令会将控制器、调度程序和 etcd 的健康状况显示为 Healthy

# kubectl get cs
NAME                 STATUS    MESSAGE             ERROR
controller-manager   Healthy   ok
scheduler            Healthy   ok
etcd-0               Healthy   {"health":"true"}

您还应该检查集群中运行的节点。

kubectl get nodes

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM