K8S组件

核心组件

  • 配置存储中心 -> etcd

  • 主控 (master) 节点

    • kube-apiserver服务
      • 提供了集群管理的Restful风格API接口(包括鉴权、数据校验及集群状态变更), 可以类比ElasticSearch的Restful风格API, curl -xput | xget | xdelete 等。
      • 负责其他模块之间的数据交互, 承担通信枢纽功能
      • 是资源配额控制的入口
      • 提供完备的集群安全机制
    • kube-controller-manager服务
      • 由一系列控制器组成, 通过apiserver监控整个集群的状态, 并确保集群处于预期的工作状态
      • Node Controller
      • Deployment Controller
      • Service Controller
      • Volume Controller (存储卷控制器)
      • EndPoint Controller (接入点控制器)
      • Garbage Controller (垃圾控制器 类似GC)
      • Namespace Controller (名称空间控制器)
      • Job Controller
      • Resource quota Controller (资源调度控制器)
    • kube-scheduler服务
      • 主要功能是接收调度pod到适合的运算节点
      • 预算策略 (predict)
      • 优选策略 (priorities)
  • 运算 (node) 节点

    • kube-kubelet 服务

      • 主要功能是定时从某个地方获取节点上 pod 的期望状态(运行什么容器、运行的副本数量、网络或者存储如何配置等等), 并调用对应的容器平台接口达到这个状态。
      • 定时汇报当前节点的状态给apiserver, 以供调度的时候使用
      • 镜像和容器的清理工作, 保证节点上镜像不会占满磁盘空间, 退出的容器不会占用太多资源。
    • kube-proxy 服务

      • 是K8S在每个节点上运行网络代理, service资源的载体

      • 建立了pod网络和集群网络的关系 (clusterip -> podip)

      • 常用三种流量调度模式

        • Userspace (废弃, 需要大量用户态内核态转换, 资源消耗过多)
        • Iptables (濒临废弃)
        • Ipvs (推荐)
          • 相当于在K8S中内嵌了一套LVS
      • 负责建立和删除包括更新调度规则、通知apiserver自己的更新, 或者从apiserver那里获取其他kube-proxy的调度规则变化来更新自己

        img

    • 逻辑架构图

      img

CLI客户端

  • kubectl

    • kubectl是Kubernetes集群的命令行工具,通过kubectl能够对集群本身进行管理,并能够在集群上进行容器化应用的安装部署。

    • 运行kubectl命令的语法如下:

      kubectl [command] [TYPE] [NAME] [flags]
      
      • command: 指定要对资源执行的操作, 例如create、get、describe 和 delete

      • TYPE: 指定资源类型, 资源类型是大小写敏感的, 开发者能够以单数、复数和缩略的形式:

        kubectl get pod pod1
        kubectl get pods pod1
        kubectl get po pod1
        
      • NAME: 指定资源的名称, 名称也是大小写敏感的。

        • 如果省略名称,则会显示所有的资源:

          kubectl get pods
          
      • flags: 指定可选的参数。例如, 可以使用 -s 或者-server参数指定 Kubernetes API server的地址和端口。

      • 通过kubectl help 命令获取更多信息:

        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 [使用 replication controller, service, deployment 或者 pod 并暴露它作为一个新的 Kubernetes Service]
          run            Run a particular image on the cluster[在集群中运行一个指定的镜像]
          set            Set specific features on objects[为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[为 Deployment, ReplicaSet, Replication Controller 或者 Job 设置一个新的副本数]
          autoscale      Auto-scale a Deployment, ReplicaSet, or ReplicationController[自动调整一个 Deployment, ReplicaSet, 或者 ReplicationController 的副本数量]
        
        Cluster Management Commands:
          certificate    Modify certificate resources.[修改证书资源]
          cluster-info   Display cluster info[展示集群信息]
          top            Display Resource (CPU/Memory/Storage) usage.[展示资源使用(CPU/内存/磁盘存储空间)]
          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[显示一个指定 resource 或者 group 的 resources 详情]
          logs           Print the logs for a container in a pod[输出容器在 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[将一个或多个端口转发到一个pod]
          proxy          Run a proxy to the Kubernetes API server[运行一个Kubernetes API server的代理]
          cp             Copy files and directories to and from containers.[复制 files 和 directories 到 containers 和从容器中复制 files 和 directories.]
          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[通过文件名或标准输入流(stdin)对资源进行配置]
          patch          Update field(s) of a resource using strategic merge patch[使用合并补丁策略更新一个资源的 field(s)]
          replace        Replace a resource by filename or stdin[通过 filename 或者 stdin替换一个资源]
          wait           Experimental: Wait for a specific condition on one or many resources.[等待对于一个或多个资源来说的某个特定条件]
          convert        Convert config files between different API versions[在不同的API版本间转化文件]
          kustomize      Build a kustomization target from a directory or a remote url[从一个目录或远程url创建一个定制化的目标].
        
        Settings Commands:
          label          Update the labels on a resource[更新在此资源上的labels]
          annotate       Update the annotations on a resource[更新一个资源的注解]
          completion     Output shell completion code for the specified shell [对特定的shell(比如bash或zsh)输出shell操作完成代码](bash or zsh)
        
        Other Commands:
          api-resources  Print the supported API resources on the serverp[打印支持的服务器上的API 资源]
          api-versions   Print the supported API versions on the server, in the form of "group/version"[以组和版本的形式打印服务器所支持的API版本]
          config         Modify kubeconfig files[修改k8s配置文件]
          plugin         Provides utilities for interacting with plugins.[提供与插件交互的工具包]
          version        Print the client and server version information[打印客户端与服务器版本信息]
        
        Usage:
          kubectl [flags] [options]
        

核心附件

  • CNI网络插件 -> flannel / calico
  • 服务发现用插件 -> coredns
  • 服务暴露用插件 -> traefik
  • GUI管理插件 -> Dashboard
原文地址:https://www.cnblogs.com/ronnieyuan/p/12603562.html