kubernetes 如何重现daemonset失败且pod未就绪的情况

px9o7tmv  于 2023-06-21  发布在  Kubernetes
关注(0)|答案(1)|浏览(124)

如何在部署daemonset时重现没有pod就绪?
我举一个小例子:

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: fluentd
  namespace: logging
  labels:
    app: fluentd-logging
spec:
  selector:
    matchLabels:
      name: fluentd
  template:
    metadata:
      labels:
        name: fluentd
    spec:
      containers:
      - name: fluentd-elasticsearch
        image: quay.io/fluentd_elasticsearch/fluentd:v2.5.2
        resources:
          limits:
            memory: 200Mi
          requests:
            cpu: 100m
            memory: 200Mi
        volumeMounts:
        - name: varlog
          mountPath: /var/log
      terminationGracePeriodSeconds: 30
      volumes:
      - name: varlog
        hostPath:
          path: /var/log

接下来的问题是如何使用字段选择器获取daemonset错误的事件?
involvedObject.kind=Daemonset,involvedObject.name="{daemonset-name}”

c6ubokkw

c6ubokkw1#

要设置为DaemonSet的未就绪pod,您只需添加一个永远不会就绪的就绪探测器。

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: fluentd
  namespace: default
  labels:
    app: fluentd-logging
spec:  
  selector:
    matchLabels:
      name: fluentd
  template:
    metadata:
      labels:
        name: fluentd
    spec:
      containers:
      - name: fluentd-elasticsearch
        image: quay.io/fluentd_elasticsearch/fluentd:v2.5.2
        # here the readinessProbe
        readinessProbe:
          initialDelaySeconds: 5
          httpGet:
            host: www.dominiochenonesiste.com
            port: 80       
        resources:
          limits:
            memory: 200Mi
          requests:
            cpu: 100m
            memory: 200Mi
        volumeMounts:
        - name: varlog
          mountPath: /var/log
      terminationGracePeriodSeconds: 30
      volumes:
      - name: varlog
        hostPath:
          path: /var/log

要检查pod状态,可以使用kubetcl describe pod <nameofyourdaemonsetpodcreated>
在输出中,您将获得:

Conditions:
  Type              Status
  Initialized       True 
  Ready             False 
  ContainersReady   False 
  PodScheduled      True

希望能帮上忙!
Cose贝儿!

相关问题