侧边栏壁纸
博主头像
一揽芳华 博主等级

行动起来,活在当下

  • 累计撰写 265 篇文章
  • 累计创建 24 个标签
  • 累计收到 4 条评论

目 录CONTENT

文章目录

二、Kubernetes集群客户端命令

芳华是个男孩!
2024-10-15 / 0 评论 / 0 点赞 / 12 阅读 / 0 字
广告 广告

1、kubeclt命令

集群中的管理操作几乎所有都可以用kubectl完成

[root@k8s-master01 ~]# kubectl -h
kubectl controls the Kubernetes cluster manager.

 Find more information at: https://kubernetes.io/docs/reference/kubectl/overview/

Basic Commands (Beginner):
  create        Create a resource from a file or from stdin.
  expose        Take a replication controller, service, deployment or pod and expose it as a new Kubernetes Service
  run           Run a particular image on the cluster
  set           Set specific features on objects

Basic Commands (Intermediate):
  explain       Documentation of resources
  get           Display one or many resources
  edit          Edit a resource on the server
  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     Auto-scale a Deployment, ReplicaSet, StatefulSet, or ReplicationController

Cluster Management Commands:
  certificate   Modify certificate resources.
  cluster-info  Display cluster info
  top           Display Resource (CPU/Memory) usage.
  cordon        Mark node as unschedulable
  uncordon      Mark node as schedulable
  drain         Drain node in preparation for maintenance
  taint         Update the taints on one or more nodes

Troubleshooting and Debugging Commands:
  describe      Show details of a specific resource or group of resources
  logs          Print the logs for a container in a pod
  attach        Attach to a running container
  exec          Execute a command in a container
  port-forward  Forward one or more local ports to a pod
  proxy         Run a proxy to the Kubernetes API server
  cp            Copy files and directories to and from containers.
  auth          Inspect authorization
  debug         Create debugging sessions for troubleshooting workloads and nodes

Advanced Commands:
  diff          Diff live version against would-be applied version
  apply         Apply a configuration to a resource by filename or stdin
  patch         Update field(s) of a resource
  replace       Replace a resource by filename or stdin
  wait          Experimental: Wait for a specific condition on one or many resources.
  kustomize     Build a kustomization target from a directory or URL.

Settings Commands:
  label         Update the labels on a resource
  annotate      Update the annotations on a resource
  completion    Output shell completion code for the specified shell (bash or zsh)

Other Commands:
  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        Modify kubeconfig files
  plugin        Provides utilities for interacting with plugins.
  version       Print the client and server version information

Usage:
  kubectl [flags] [options]

Use "kubectl <command> --help" for more information about a given command.
Use "kubectl options" for a list of global command-line options (applies to all commands).
以下是将命令功能翻译成中文:

基本命令(初学者):
  create        从文件或标准输入创建资源。
  expose        将复制控制器、服务、部署或 Pod 暴露为新的 Kubernetes 服务。
  run           在集群上运行特定镜像。
  set           在对象上设置特定功能。

基本命令(中级):
  explain       资源的文档说明。
  get           显示一个或多个资源。
  edit          在服务器上编辑资源。
  delete        通过文件名、标准输入、资源和名称,或通过资源和标签选择器删除资源。

部署命令:
  rollout       管理资源的滚动更新。
  scale         为部署、副本集或复制控制器设置新的大小。
  autoscale     自动调整部署、副本集、有状态集或复制控制器的规模。

集群管理命令:
  certificate   修改证书资源。
  cluster-info  显示集群信息。
  top           显示资源(CPU/内存)使用情况。
  cordon        将节点标记为不可调度。
  uncordon      将节点标记为可调度。
  drain         在维护前准备中排空节点。
  taint         更新一个或多个节点的污点。

故障排除和调试命令:
  describe      显示特定资源或资源组的详细信息。
  logs          打印 Pod 中容器的日志。
  attach        连接到正在运行的容器。
  exec          在容器中执行命令。
  port-forward  将一个或多个本地端口转发到 Pod。
  proxy         运行到 Kubernetes API 服务器的代理。
  cp            将文件和目录复制到容器中,或从容器中复制出来。
  auth          检查授权。
  debug         创建用于故障排除工作负载和节点的调试会话。

高级命令:
  diff          将实时版本与应用版本进行比较。
  apply         通过文件名或标准输入将配置应用于资源。
  patch         更新资源的字段。
  replace       通过文件名或标准输入替换资源。
  wait          实验性功能:等待一个或多个资源的特定条件。
  kustomize     从目录或 URL 构建自定义目标。

设置命令:
  label         更新资源的标签。
  annotate      更新资源的注释。
  completion    输出指定 shell(bash 或 zsh)的自动补全代码。

其他命令:
  api-resources 打印服务器上支持的 API 资源。
  api-versions  打印服务器上支持的 API 版本,格式为 "group/version"。
  config        修改 kubeconfig 文件。
  plugin        提供与插件交互的实用工具。
  version       打印客户端和服务器版本信息。

使用:
  kubectl [标志] [选项]

使用 "kubectl <command> --help" 获取有关特定命令的更多信息。
使用 "kubectl options" 获取全局命令行选项的列表(适用于所有命令)。

2、kubectl命令说明

invalid image(图片无法加载)

invalid image(图片无法加载)

3、kubectl命令补全😁

😁 😁
yum install bash-completion -y

source /usr/share/bash-completion/bash_completion
source <(kubectl completion bash)
kubectl completion bash > ~/.kube/completion.bash.inc
source '/root/.kube/completion.bash.inc'
echo 'source /usr/share/bash-completion/bash_completion' >> $HOME/.bash_profile
echo "source '/root/.kube/completion.bash.inc'" >> $HOME/.bash_profile
source $HOME/.bash_profile
0
广告 广告

评论区