Home | 简体中文 | 繁体中文 | 杂文 | Github | 知乎专栏 | 51CTO学院 | CSDN程序员研修院 | OSChina 博客 | 腾讯云社区 | 阿里云栖社区 | Facebook | Linkedin | Youtube | 打赏(Donations) | About

第 109 章 Kubernetes 集群管理

kubectl - controls the Kubernetes cluster manager.


109.1. 配置
109.1.2. use-context
109.2. 如何从 docker 过渡到 kubectl 命令
109.2.1. 执行 Shell
109.2.2. 查看信息
109.2.3. 查看 pod 日志
109.2.4. 复制文件
109.2.5. edit
109.2.6. 端口转发
109.2.7. 操作系统资源配置
109.2.8. endpoints
109.2.9. explain
109.2.10. describe
109.3. namespace 命名空间
109.3.1. 查看命名空间
109.3.2. 创建命名空间
109.3.3. 使用 yaml 创建命名空间
109.3.4. 删除命名空间
109.4. label 标签
109.5. 服务管理
109.5.1. 列出服务
109.5.2. 创建服务
109.5.3. 查看服务详细信息
109.5.4. 更新服务
109.5.5. 删除服务
109.5.6. clusterip
109.5.7. 设置外部IP
109.5.8. externalname
109.5.9. 负载均衡
109.5.10. nodeport
109.5.11. Example
109.6. serviceaccount
109.7. Pod 管理
109.7.1. 查看 POD 状态
109.7.2. 运行 POD
109.7.3. 删除 pod
109.7.4. 查看 Pod 的事件
109.7.5. Taint(污点)和 Toleration(容忍)
109.7.6. 镜像拉取策略
109.7.7. 指定主机名
109.7.8. 环境变量
109.7.9. 健康状态检查
109.7.10. securityContext
109.7.11. nodeName 选择节点
109.7.12. nodeSelector 选择节点
109.7.13. nodeAffinity 选择节点
109.7.14. Taint(污点)和 Toleration(容忍)
109.7.15. strategy
109.8. 部署管理
109.8.1. expose
109.8.2. 部署容器
109.8.3. 删除 deployment
109.8.4. 扩容管理
109.8.5. rollout
109.8.6. 重启容器
109.8.7. 更新镜像
109.9. secret 密钥管理
109.9.1. 获取 Token
109.9.2. 创建 Secret
109.9.3. Private Registry 用户认证
109.9.4. 配置TLS SSL
109.10. ConfigMap
109.10.1. 创建 Key-Value 配置项
109.10.2. 从文件创建 ConfigMap
109.10.3. 从环境变量文件创建 ConfigMap
109.10.4. 查看 ConfigMap
109.10.5. 删除 ConfigMap
109.10.6. ConfigMap
109.11. Job/CronJob
109.11.1. CronJob
109.11.2. Job
109.12. clusterrolebinding
109.13. Volume
109.13.1. local
109.14. Ingress
109.14.1. 管理 Ingress
109.14.2. 挂载 SSL 证书上
109.14.3. 端口
109.14.4. URI 规则
109.14.5. vhost 虚拟主机
109.14.6. rewrite
109.14.7. annotations 配置
109.14.8. 金丝雀发布(灰度发布)
109.14.9. 解决 504 网关超时


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, Replication Controller, or Job
  autoscale      Auto-scale a Deployment, ReplicaSet, or ReplicationController

Cluster Management Commands:
  certificate    Modify certificate resources.
  cluster-info   Display cluster info
  top            Display Resource (CPU/Memory/Storage) 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

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 using strategic merge patch
  replace        Replace a resource by filename or stdin
  wait           Experimental: Wait for a specific condition on one or many resources.
  convert        Convert config files between different API versions

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

  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).	

109.1. 配置



109.1.2. use-context

[root@netkiller ~]# kubectl config view
apiVersion: v1
- cluster:
    certificate-authority-data: DATA+OMITTED
  name: k3d-mycluster
- context:
    cluster: k3d-mycluster
    user: admin@k3d-mycluster
  name: k3d-mycluster
current-context: k3d-mycluster
kind: Config
preferences: {}
- name: admin@k3d-mycluster
    client-certificate-data: REDACTED
    client-key-data: REDACTED			
$ kubectl config use-context