zoukankan      html  css  js  c++  java
  • kubectl 常用命令总结

    # 查看所有 pod 列表,  -n 后跟 namespace, 查看指定的命名空间
    kubectl get pod
    kubectl get pod -n kube  
    kubectl get pod -o wide
    
    
    # 查看 RC 和 service 列表, -o wide 查看详细信息
    kubectl get rc,svc
    kubectl get pod,svc -o wide  
    kubectl get pod <pod-name> -o yaml
    
    
    # 显示 Node 的详细信息
    kubectl describe node 192.168.0.212
    
    
    # 显示 Pod 的详细信息, 特别是查看 pod 无法创建的时候的日志
    kubectl describe pod <pod-name>
    eg:
    kubectl describe pod redis-master-tqds9
    
    
    # 根据 yaml 创建资源, apply 可以重复执行,create 不行
    kubectl create -f pod.yaml
    kubectl apply -f pod.yaml
    
    
    # 基于 pod.yaml 定义的名称删除 pod 
    kubectl delete -f pod.yaml 
    
    
    # 删除所有包含某个 label 的pod 和 service
    kubectl delete pod,svc -l name=<label-name>
    
    
    # 删除所有 Pod
    kubectl delete pod --all
    
    
    # 查看 endpoint 列表
    kubectl get endpoints
    
    
    # 执行 pod 的 date 命令
    kubectl exec <pod-name> -- date
    kubectl exec <pod-name> -- bash
    kubectl exec <pod-name> -- ping 10.24.51.9
    
    
    # 通过bash获得 pod 中某个容器的TTY,相当于登录容器
    kubectl exec -it <pod-name> -c <container-name> -- bash
    eg:
    kubectl exec -it redis-master-cln81 -- bash
    
    
    # 查看容器的日志
    kubectl logs <pod-name>
    kubectl logs -f <pod-name> # 实时查看日志
    kubectl log  <pod-name>  -c <container_name> # 若 pod 只有一个容器,可以不加 -c 
    
    kubectl logs -l app=frontend # 返回所有标记为 app=frontend 的 pod 的合并日志。
    
    
    # 查看注释
    kubectl explain pod
    kubectl explain pod.apiVersion
    
    # 查看节点 labels
    kubectl get node --show-labels
    
    # 重启 pod
    kubectl get pod <POD名称> -n <NAMESPACE名称> -o yaml | kubectl replace --force -f -
    
    # 修改网络类型
    kubectl patch service istio-ingressgateway -n istio-system -p '{"spec":{"type":"NodePort"}}'
    
  • 相关阅读:
    【BZOJ-4592】脑洞治疗仪 线段树
    【BZOJ-1369】Gem 树形DP
    【BZOJ-3696】化合物 树形DP + 母函数(什么鬼)
    【BZOJ-2435】道路修建 (树形DP?)DFS
    【BZOJ-4590】自动刷题机 二分 + 判定
    【BZOJ-4591】超能粒子炮·改 数论 + 组合数 + Lucas定理
    【BZOJ-1492】货币兑换Cash DP + 斜率优化 + CDQ分治
    【BZOJ-1324】Exca王者之剑 最小割
    【BZOJ-1017】魔兽地图DotR 树形DP + 背包
    【BZOJ-1131】Sta 树形DP
  • 原文地址:https://www.cnblogs.com/klvchen/p/9585746.html
Copyright © 2011-2022 走看看