zoukankan      html  css  js  c++  java
  • kubectl命令

    查看所有 pod 列表, -n 后跟 namespace, 查看指定的命名空间

    kubectl get pod
    kubectl get pod -n kube

    查看 RC 和 service 列表, -o wide 查看详细信息

    kubectl get rc,svc
    kubectl get pod,svc -o wide
    kubectl get pod -o yaml

    显示 Node 的详细信息

    kubectl describe node 192.168.0.212

    显示 Pod 的详细信息, 特别是查看 pod 无法创建的时候的日志

    kubectl describe pod
    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=

    kubectl delete namespace xxx

    删除所有 Pod

    kubectl delete pod --all

    查看 endpoint 列表

    kubectl get endpoints

    kubectl get namespace

    执行 pod 的 date 命令

    kubectl exec -- date
    kubectl exec -- bash
    kubectl exec -- ping 10.24.51.9

    通过bash获得 pod 中某个容器的TTY,相当于登录容器

    kubectl exec -it -c -- bash
    eg:
    kubectl exec -it redis-master-cln81 -- bash
    例如user-deployment:
    kubectl --namespace=default exec -it user-deployment-54469dd57-vg87g --container user -- sh

    查看容器的日志

    kubectl logs
    kubectl logs -f # 实时查看日志

    容器日志输出到文件

    log_pod release-xxxx 10000 > xxxx.txt

  • 相关阅读:
    REBOOT Reload 可安装在优盘的 Windows 和 DOS 启动盘
    给博客添加框架固定式背景音乐
    假期太长,很无聊
    CISCO NAT 配置
    网络地址转换全面通
    [转]drupal用程序创建node的方法
    drupal文件上传表单的例子
    drupal6重建menu遇到的问题
    运行效率与开发效率的随想
    joomla jSeblod的研究
  • 原文地址:https://www.cnblogs.com/aric2016/p/12549582.html
Copyright © 2011-2022 走看看