zoukankan      html  css  js  c++  java
  • Kubernetes之kubectl认识

    kubectl概述

    kubectl是k8s集群的命令行工具,通过kubect能够实现对集群本身进行管理维护

    kubectl命令的语法

    大致上就是这么个语法 :kubectl [command] [type] [name] [flags]

    • command : 操作指令,比如create、get、describe、delete等

    • type:指定资源类型,大小写敏感,但可以写单数、复数、或者缩略形式

      • kubectl get pod nginx

      • kubectl get pods nginx

      • kubectl get po nginx

    • name:指定资源的名称,大小写敏感,可省略,则操作所有的资源

    • flags:指定可选的参数,

      • 比如可用-s或者-server参数指定kubenetes API server的地址和端口

    kubectl --help

    • 键入 kubectl --help:看到如下信息

    Basic Commands (Beginner):
    create       Create a resource from a file or from stdin.
    expose       使用 replication controller, service, deployment 或者 pod 并暴露它作为一个新的 Kubernetes
    Service
    run           在集群中运行一个指定的镜像
     set           为 objects 设置一个指定的特征

    Basic Commands (Intermediate):
    explain       查看资源的文档
     get           显示一个或更多 resources
    edit         在服务器上编辑一个资源
    delete       Delete resources by filenames, stdin, resources and names, or by resources and label selector

    Deploy Commands:
    rollout       Manage the rollout of a resource
    scale         Set a new size for a Deployment, ReplicaSet or Replication Controller
    autoscale     自动调整一个 Deployment, ReplicaSet, 或者 ReplicationController 的副本数量

    Cluster Management Commands:
    certificate   修改 certificate 资源.
    cluster-info 显示集群信息
     top           Display Resource (CPU/Memory/Storage) usage.
    cordon       标记 node 为 unschedulable
    uncordon     标记 node 为 schedulable
    drain         Drain node in preparation for maintenance
    taint         更新一个或者多个 node 上的 taints

    Troubleshooting and Debugging Commands:
    describe     显示一个指定 resource 或者 group 的 resources 详情
    logs         输出容器在 pod 中的日志
    attach       Attach 到一个运行中的 container
    exec         在一个 container 中执行一个命令
    port-forward Forward one or more local ports to a pod
    proxy         运行一个 proxy 到 Kubernetes API server
     cp           复制 files 和 directories 到 containers 和从容器中复制 files 和 directories.
    auth         Inspect authorization

    Advanced Commands:
     diff         Diff live version against would-be applied version
    apply         通过文件名或标准输入流(stdin)对资源进行配置
    patch         使用 strategic merge patch 更新一个资源的 field(s)
    replace       通过 filename 或者 stdin替换一个资源
    wait         Experimental: Wait for a specific condition on one or many resources.
    convert       在不同的 API versions 转换配置文件
    kustomize     Build a kustomization target from a directory or a remote url.

    Settings Commands:
    label         更新在这个资源上的 labels
    annotate     更新一个资源的注解
    completion   Output shell completion code for the specified shell (bash or zsh)

    Other Commands:
    alpha         Commands for features in alpha
    api-resources Print the supported API resources on the server
    api-versions Print the supported API versions on the server, in the form of "group/version"
    config       修改 kubeconfig 文件
    plugin       Provides utilities for interacting with plugins.
    version       输出 client 和 server 的版本信息

    Usage:
    kubectl [flags] [options]

    kubectl 命令分类总结

    基础命令

    基础命令解释
    create 通过文件名或标准输入创建资源
    expose 将一个资源公开为一个新的Service
    run 在集群中运行一个特定的镜像
    get 显示一个或者多个资源
    set 在对象上设置特定的功能
    explain 文档参考资料
    edit 使用默认的编辑器编辑一个资源
    delete 通过文件名、标准输入、资源名称,或标签来删除资源

    部署命令

    部署命令解释
    rollout 管理资源的发布
    rolling-update 对给定的复制控制器滚动更新
    scale 扩容或者缩绒pod数量、Deployment、ReplicaSet、RC、Job
    autoscale 创建一个自动进行扩容和缩容并设置Pod数量

    集群管理命令

    集群管理命令解释
    certificate 修改证书资源
    cluster-info 显示集群信息
    top 显示资源使用,需要Heapster运行
    cordon 标记节点不可被调度
    uncordon 标记几点可被调度
    drain 驱逐姐弟啊上的应用,准备下线维护
    taint 修改节点taint标记

    故障和调试命令

    故障和调试命令解释
    describe 显示特定资源胡资源组的详细信息
    logs 在一个pod中打印一个容器日志,如果pod只有一个容器,容器名称是可选的
    attach 附加到一个运行的容器
    exex 执行命令到容器
    port-forward 转发一个多或多个本地端口到pod
    proxy 运行一个proxy到kubenetes API Server
    cp 拷贝文件或目录到容器中
    auth 检查授权

    其他命令

    其他命令解释
    apply 通过文件名或者标准输入对资源应用配置
    patch 使用补丁修改,更新资源字段
    replace 通过文件名或标准输入替换一个资源
    convert 不同的API版本之间转换配置文件
    label 更新资源上的标签
    annotate 更新资源上的注释
    completion 用于实现kucectl工具自动补全
    api-versions 打印受支持的API版本
    config 修改kubeconfig文件,用于访问API,比如配置认证信息
    help 所有帮助命令
    plugin 运行一个命令行插件
    version 打印客户端和服务版本信息

    .

     

  • 相关阅读:
    转录组分析的正确姿势
    NGS基础
    蛋白质组学研究概述
    Real-time qPCR So Easy?
    UI设计师给的px尺寸单位,安卓如何换算成dp?
    用户·角色·权限·表的设计
    ie浏览器多开-----同时登陆多个账号
    WPF中触发器Trigger、MultiTrigger、DataTrigger、MultiDataTrigger、EventTrigger几种
    WPF 单个触发器、多个触发器、多条件触发器
    WPF样式中TargetType 属性 (Property) 和 x:Key 属性 (Attribute)
  • 原文地址:https://www.cnblogs.com/msi-chen/p/14286804.html
Copyright © 2011-2022 走看看