【问题标题】:why does my daemonset crash when a node goes down?为什么当节点关闭时我的守护进程崩溃?
【发布时间】:2022-08-08 18:34:06
【问题描述】:

我已经在 Kubernetes 官方页面上的集群中配置了这个 DaemonSet,并且一切正常,因为它在我的两个可用工作节点之间重新分区了我的应用程序的副本。当一个节点出现故障时,问题就出现了,然后所有副本都开始在另一个节点上运行。一旦宕机的节点恢复,Pod 不会在我的节点之间自动分区,因此我必须手动删除所有副本并再次扩展它们以使 DaemonSet 正常工作。 我怎样才能解决这个问题?

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: fluentd-elasticsearch
  namespace: kube-system
  labels:
    k8s-app: fluentd-logging
spec:
  selector:
    matchLabels:
      name: fluentd-elasticsearch
  template:
    metadata:
      labels:
        name: fluentd-elasticsearch
    spec:
      tolerations:
      - key: node-role.kubernetes.io/master
        operator: Exists
        effect: NoSchedule
      containers:
      - name: fluentd-elasticsearch
        image: gcr.io/fluentd-elasticsearch/fluentd:v2.5.1
        resources:
          limits:
            memory: 200Mi
          requests:
            cpu: 100m
            memory: 200Mi
        volumeMounts:
        - name: varlog
          mountPath: /var/log
        - name: varlibdockercontainers
          mountPath: /var/lib/docker/containers
          readOnly: true
      terminationGracePeriodSeconds: 30
      volumes:
      - name: varlog
        hostPath:
          path: /var/log
      - name: varlibdockercontainers
        hostPath:
          path: /var/lib/docker/containers

    标签: kubernetes


    【解决方案1】:

    检查 DeamonSet 中的所有 Pod:kubectl get pod -l app=[label]

    检查 Pod 的状态,例如 crashloopbackoff、挂起和驱逐,如果您发现任何此类问题,请运行此命令以获取更多信息:kubectl describe pod [pod-name] 或记录 kubectl logs [pod-name]

    检查 Pod 是否耗尽资源:kubectl get pod [pod-name] -o wide 并查看当前可用的资源,使用 kubectl top node [node-name],最后调试您的容器问题:docker run -ti --rm ${image} /bin/bash

    笔记:DaemonSet 每个节点部署一个 pod。豆荚的数量将与节点一样多。您无法控制副本的数量。您需要将对象更改为 Deployment 或 Statefulset 以管理副本数

    【讨论】:

      猜你喜欢
      • 2014-01-05
      • 2012-10-26
      • 2017-10-26
      • 2022-12-12
      • 1970-01-01
      • 2013-02-20
      • 1970-01-01
      • 1970-01-01
      • 2017-10-28
      相关资源
      最近更新 更多