K8S常用命令
--删除pod
kubectl delete pod {podname} -n {namespace}
--强制删除pod
kubectl delete pod {podname} --force --grace-period=0 -n {namespace}
--删除命名空间
kubectl delete namespace testfws
--查看命名空间
kubectl get namespace
--查看信息 show.sh
kubectl get pods --all-namespaces -o wide
kubectl get services --all-namespaces -o wide
kubectl get no -o wide #查看node节点
INTERNAL-IP 节点所在的IP地址
EXTERNAL-IP IP的外部网络或互联网
OS-IMAGE 操作系统的镜像版本
KERNEL-VERSION 内核版本号
CONTAINER-RUNTIME 容器运行时的版本
#查看node节点各资源的使用情况
kubectl top node
kubectl get po --show-labels #查看pod对应的标签
查看pod详细配置信息
kubectl get pods -n testfws(命名空间) common-86c5498865-qwx72(pod名称) -o yaml
--进入pod
kubectl exec -it (pod名称) -n (命名空间) -- bash
--查看pod日志
kubectl logs -f provider-779485959-h6629(pod名称) -n testfws(命名空间)
-- 通过yaml文件创建pod
kubectl create -f 文件.yaml
查看deployment状态
kubectl get deployment -A
查看service状态
kubectl get service -A
查看pod日志
kubect get pod common-xxxxxx-xxxx -n fws
登录pod
kubect exec -it common-xxxxxx-xxxx -n fws -- bash
更新镜像:
kubectl set image deployment/common common=192.168.15.198/testfws/common:202112080938 -n testfws
扩容pod数量
kubect scale deployment common --replicas=3 -n testfws
查看pod详细信息,ip地址, 宿主机地址
kubectl get pod -A -o wide
查看 node cpu 内存使用量
kubect top node
查看 pod cpu 内存使用量
kubect top pod -A
查看 node状态
kubect get node
1. 硬件设施
1.1 检查pod所在服务器的磁盘空间是否被占满(df -h 和 du -sh /)
1.2 检查pod所在服务器的cpu、内存是否被占满(top 和 free -m)
2. 镜像
2.1 到pod所在主机检查pod所需的镜像是否能成功拉取(docker images)
3. 查看日志
kubectl describe pods xxx -n xxx
kubectl logs podname -n xxx --tail=200
kubectl get ns --show-labels
解析域名
nslookup (网址)