任务

任务
管理集群
Debug DNS 方案
Enabling Service Topology (EN)
IP Masquerade Agent 用户指南
Kubernetes 云管理控制器
Safely Drain a Node while Respecting the PodDisruptionBudget (EN)
为 Kubernetes 运行 etcd 集群
为系统守护进程预留计算资源
为节点发布扩展资源
使用 CoreDNS 进行服务发现
使用 KMS 提供商进行数据加密
使用 Kubernetes API 访问集群
关键插件 Pod 的调度保证
启用端点切片
命名空间演练
在 Kubernetes 集群中使用 NodeLocal DNSCache
在 Kubernetes 集群中使用 sysctl
在实时集群上重新配置节点的 Kubelet
声明网络策略
开发云控制器管理器
控制节点上的 CPU 管理策略
控制节点上的拓扑管理策略
搭建高可用的 Kubernetes Masters
改变默认 StorageClass
更改 PersistentVolume 的回收策略
自定义 DNS 服务
访问集群上运行的服务
通过命名空间共享集群
通过配置文件设置 Kubelet 参数
配置 API 对象配额
配置多个调度器
配置资源不足时的处理方式
限制存储消耗
集群 DNS 服务自动伸缩
集群安全
集群管理
静态加密 Secret 数据
用插件扩展 kubectl
管理巨页(HugePages)
调度 GPUs

Edit This Page

节点健康监测

节点问题探测器 是一个 DaemonSet 用来监控节点健康。它从各种守护进程收集节点问题,并以NodeConditionEvent 的形式报告给 apiserver 。

它现在支持一些已知的内核问题检测,并将随着时间的推移,检测更多节点问题。

目前,Kubernetes 不会对节点问题检测器监测到的节点状态和事件采取任何操作。将来可能会引入一个补救系统来处理这些节点问题。

更多信息请参阅 这里

准备开始

你必须拥有一个 Kubernetes 的集群,同时你的 Kubernetes 集群必须带有 kubectl 命令行工具。 如果你还没有集群,你可以通过 Minikube 构建一 个你自己的集群,或者你可以使用下面任意一个 Kubernetes 工具构建:

要获知版本信息,请输入 kubectl version.

局限性

  • 节点问题检测器的内核问题检测现在只支持基于文件类型的内核日志。 它不支持像 journald 这样的命令行日志工具。
  • 节点问题检测器的内核问题检测对内核日志格式有一定要求,现在它只适用于 Ubuntu 和 Debian。但是,将其扩展为 支持其它日志格式 也很容易。

在 GCE 集群中启用/禁用

节点问题检测器在 gce 集群中以集群插件的形式默认启用。

您可以在运行 kube-up.sh 之前,以设置环境变量 KUBE_ENABLE_NODE_PROBLEM_DETECTOR 的形式启用/禁用它。

在其它环境中使用

要在 GCE 之外的其他环境中启用节点问题检测器,您可以使用 kubectl 或插件 pod。

Kubectl

这是在 GCE 之外启动节点问题检测器的推荐方法。它的管理更加灵活,例如覆盖默认配置以使其适合您的环境或检测自定义节点问题。

  • 步骤 1: node-problem-detector.yaml:
debug/node-problem-detector.yaml
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: node-problem-detector-v0.1
  namespace: kube-system
  labels:
    k8s-app: node-problem-detector
    version: v0.1
    kubernetes.io/cluster-service: "true"
spec:
  selector:
    matchLabels:
      k8s-app: node-problem-detector  
      version: v0.1
      kubernetes.io/cluster-service: "true"
  template:
    metadata:
      labels:
        k8s-app: node-problem-detector
        version: v0.1
        kubernetes.io/cluster-service: "true"
    spec:
      hostNetwork: true
      containers:
      - name: node-problem-detector
        image: k8s.gcr.io/node-problem-detector:v0.1
        securityContext:
          privileged: true
        resources:
          limits:
            cpu: "200m"
            memory: "100Mi"
          requests:
            cpu: "20m"
            memory: "20Mi"
        volumeMounts:
        - name: log
          mountPath: /log
          readOnly: true
      volumes:
      - name: log
        hostPath:
          path: /var/log/

请注意保证您的系统日志路径与您的 OS 发行版相对应。

  • 步骤 2: 执行 kubectl 来启动节点问题检测器:

    kubectl create -f https://k8s.io/examples/debug/node-problem-detector.yaml

插件 Pod

这适用于拥有自己的集群引导程序解决方案的用户,并且不需要覆盖默认配置。 他们可以利用插件 Pod 进一步自动化部署。

只需创建 node-problem-detector.yaml,并将其放在主节点上的插件 pod 目录 /etc/kubernetes/addons/node-problem-detector 下。

覆盖配置文件

构建节点问题检测器的 docker 镜像时,会嵌入默认配置

不过,您可以像下面这样使用 ConfigMap 将其覆盖:

  • 步骤 1:config/ 中更改配置文件。
  • 步骤 2: 使用 kubectl create configmap node-problem-detector-config --from-file=config/ 创建 node-problem-detector-config
  • 步骤 3: 更改 node-problem-detector.yaml 以使用 ConfigMap:
debug/node-problem-detector-configmap.yaml
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: node-problem-detector-v0.1
  namespace: kube-system
  labels:
    k8s-app: node-problem-detector
    version: v0.1
    kubernetes.io/cluster-service: "true"
spec:
  selector:
    matchLabels:
      k8s-app: node-problem-detector  
      version: v0.1
      kubernetes.io/cluster-service: "true"
  template:
    metadata:
      labels:
        k8s-app: node-problem-detector
        version: v0.1
        kubernetes.io/cluster-service: "true"
    spec:
      hostNetwork: true
      containers:
      - name: node-problem-detector
        image: k8s.gcr.io/node-problem-detector:v0.1
        securityContext:
          privileged: true
        resources:
          limits:
            cpu: "200m"
            memory: "100Mi"
          requests:
            cpu: "20m"
            memory: "20Mi"
        volumeMounts:
        - name: log
          mountPath: /log
          readOnly: true
        - name: config # Overwrite the config/ directory with ConfigMap volume
          mountPath: /config
          readOnly: true
      volumes:
      - name: log
        hostPath:
          path: /var/log/
      - name: config # Define ConfigMap volume
        configMap:
          name: node-problem-detector-config
  • 步骤 4: 使用新的 yaml 文件重新创建节点问题检测器:

    kubectl delete -f https://k8s.io/examples/debug/node-problem-detector.yaml # If you have a node-problem-detector running
    kubectl create -f https://k8s.io/examples/debug/node-problem-detector-configmap.yaml

请注意,此方法仅适用于通过 kubectl 启动的节点问题检测器。

由于插件管理器不支持ConfigMap,因此现在不支持对于作为集群插件运行的节点问题检测器的配置进行覆盖。

内核监视器

内核监视器 是节点问题检测器中的问题守护进程。它监视内核日志并按照预定义规则检测已知内核问题。

内核监视器根据 config/kernel-monitor.json 中的一组预定义规则列表匹配内核问题。 规则列表是可扩展的,您始终可以通过覆盖配置来扩展它。

添加新的 NodeCondition

您可以使用新的状态描述来扩展 config/kernel-monitor.json 中的 conditions 字段以支持新的节点状态。

{
  "type": "NodeConditionType",
  "reason": "CamelCaseDefaultNodeConditionReason",
  "message": "arbitrary default node condition message"
}

检测新的问题

您可以使用新的规则描述来扩展 config/kernel-monitor.json 中的 rules 字段以检测新问题。

{
  "type": "temporary/permanent",
  "condition": "NodeConditionOfPermanentIssue",
  "reason": "CamelCaseShortReason",
  "message": "regexp matching the issue in the kernel log"
}

更改日志路径

不同操作系统发行版的内核日志的可能不同。 config/kernel-monitor.json 中的 log 字段是容器内的日志路径。您始终可以修改配置使其与您的 OS 发行版匹配。

支持其它日志格式

内核监视器使用 [Translator] 插件将内核日志转换为内部数据结构。我们可以很容易为新的日志格式实现新的翻译器。

注意事项

我们建议在集群中运行节点问题检测器来监视节点运行状况。但是,您应该知道这将在每个节点上引入额外的资源开销。一般情况下没有影响,因为:

  • 内核日志生成相对较慢。
  • 节点问题检测器有资源限制。
  • 即使在高负载下,资源使用也是可以接受的。 (参阅 基准测试结果)

反馈