当前位置: 首页 > 文档资料 > Kubernetes 指南 >

3. 核心组件 - 3.4 kube-controller-manager

优质
小牛编辑
136浏览
2023-12-01

Controller Manager由kube-controller-manager和cloud-controller-manager组成,是Kubernetes的大脑,它通过apiserver监控整个集群的状态,并确保集群处于预期的工作状态。

3.4 kube-controller-manager - 图1

kube-controller-manager由一系列的控制器组成

  • Replication Controller
  • Node Controller
  • CronJob Controller
  • Daemon Controller
  • Deployment Controller
  • Endpoint Controller
  • Garbage Collector
  • Namespace Controller
  • Job Controller
  • Pod AutoScaler
  • RelicaSet
  • Service Controller
  • ServiceAccount Controller
  • StatefulSet Controller
  • Volume Controller
  • Resource quota Controller

cloud-controller-manager在Kubernetes启用Cloud Provider的时候才需要,用来配合云服务提供商的控制,也包括一系列的控制器,如

  • Node Controller
  • Route Controller
  • Service Controller

从v1.6开始,cloud provider已经经历了几次重大重构,以便在不修改Kubernetes核心代码的同时构建自定义的云服务商支持。

Metrics

Controller manager metrics提供了控制器内部逻辑的性能度量,如Go语言运行时度量、etcd请求延时、云服务商API请求延时、云存储请求延时等。Controller manager metrics默认监听在kube-controller-manager的10252端口,提供Prometheus格式的性能度量数据,可以通过http://localhost:10252/metrics来访问。

  1. $ curl http://localhost:10252/metrics
  2. ...
  3. # HELP etcd_request_cache_add_latencies_summary Latency in microseconds of adding an object to etcd cache
  4. # TYPE etcd_request_cache_add_latencies_summary summary
  5. etcd_request_cache_add_latencies_summary{quantile="0.5"} NaN
  6. etcd_request_cache_add_latencies_summary{quantile="0.9"} NaN
  7. etcd_request_cache_add_latencies_summary{quantile="0.99"} NaN
  8. etcd_request_cache_add_latencies_summary_sum 0
  9. etcd_request_cache_add_latencies_summary_count 0
  10. # HELP etcd_request_cache_get_latencies_summary Latency in microseconds of getting an object from etcd cache
  11. # TYPE etcd_request_cache_get_latencies_summary summary
  12. etcd_request_cache_get_latencies_summary{quantile="0.5"} NaN
  13. etcd_request_cache_get_latencies_summary{quantile="0.9"} NaN
  14. etcd_request_cache_get_latencies_summary{quantile="0.99"} NaN
  15. etcd_request_cache_get_latencies_summary_sum 0
  16. etcd_request_cache_get_latencies_summary_count 0
  17. ...

kube-controller-manager启动示例

  1. kube-controller-manager --enable-dynamic-provisioning=true
  2. --feature-gates=AllAlpha=true
  3. --horizontal-pod-autoscaler-sync-period=10s
  4. --horizontal-pod-autoscaler-use-rest-clients=true
  5. --node-monitor-grace-period=10s
  6. --cluster-signing-cert-file=/etc/kubernetes/pki/ca.crt
  7. --address=127.0.0.1
  8. --leader-elect=true
  9. --use-service-account-credentials=true
  10. --controllers=*,bootstrapsigner,tokencleaner
  11. --kubeconfig=/etc/kubernetes/controller-manager.conf
  12. --insecure-experimental-approve-all-kubelet-csrs-for-group=system:bootstrappers
  13. --root-ca-file=/etc/kubernetes/pki/ca.crt
  14. --service-account-private-key-file=/etc/kubernetes/pki/sa.key
  15. --cluster-signing-key-file=/etc/kubernetes/pki/ca.key