当前位置:首页 > 容器 > k8s > 正文内容

k8s 常用命令

root2年前 (2022-04-02)k8s490

k8s常用命令

- 查看pod

kubectl  get pod

- 查看rs 资源控制器 容器副本情况

kubectl  get rs

- 查看 管理器  deployment

kubectl  get deploy  


- 查看 有状态的集合 (例如mysql集群)

kubectl  get sts


-查看 服务

kubectl  get svc


-查看pv 硬盘资源 持久化资源

kubectl  get pv


-查看 已经使用的硬盘资源

kubectl  get pvc


-查看 configmap 配置信息

kubectl  get cm


-Secret 是用来存储敏感信息的

kubectl  get Secret


- 查看负载均衡

kubectl  get vs 


-查看命名空间

kubectl  get ns

kubectl  get Node

kubectl  get ClusterRole

kubectl  get RoleBinding

kubectl  get ClusterRoleBinding


- 进入容器

kubectl exec -it podname  -n namespaces -- bash


- 拷贝文件

kubectl cp -n namespaces podname:filepath localpath


- 查看日志

kubectl logs -f -n namespaces  podname


- 编辑资源信息

kubectl edit 资源类型  -n namespaces  podname


- 查看pod详细信息

kubectl describe po -n namespaces podname


- 查看 Pod 在节点上的资源分配情况(banana-61 是节点名称)

kubectl describe node banana-61  |grep -A 20 'Allocated resources'


- 查看你node 详细信息

kubectl describe node banana-61


- 查看节点的资源使用情况

kubectl top node banana-61


- 查看pod占用资源情况

kubectl top pod -n namespaces |grep gitee-scan


- 检测k8s探针命令

kubectl get pod podname -n namespaces -o json | jq -r '.spec.containers[0].livenessProbe'


- 删除驱逐节点

kubectl get pods -n NameSpace | grep Evicted | awk '{print $1}' | xargs kubectl delete pod -n NameSpace


- 查看node 节点详细情况

kubectl describe node


- 查看节点的资源使用情况

kubectl top node


- 查看pod 的资源使用情况

kubectl top po


扫描二维码推送至手机访问。

版权声明:本文由一叶知秋发布,如需转载请注明出处。

本文链接:https://zhiqiu.top/?id=226

分享给朋友:
返回列表

没有更早的文章了...

下一篇:k8s 的搭建

相关文章

k8s 的搭建

原文 修改node标签参考文档 命令端口不同问题解决 init 初始化问题解决 主机名主机ip版本CPU内存master1192.168.56.11Ubuntu server 18.042核1Gworker1192.168.56.21Ubu...

k8s 漂移pod

k8s 漂移pod

背景:当前业务中需要将旧的node替换为新的node。需要将旧的node上的pod 迁移到新的node上。也就是对node节点进行维护,驱逐pod参考:对node节点进行维护,驱逐pod 设置node1 不能调度kubectl&n...

k8s 给node这只标签

k8s 给node这只标签

给node 设置role 标签 kubectl label nodes 10.0.64.121 node-role.kubernetes.io/test=去掉role标签kubectl label nodes 10.0.64.12...