Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
当Kubernetes中的configmap更新时刷新守护程序吊舱_Kubernetes_Kubernetes Pod_Configmap - Fatal编程技术网

当Kubernetes中的configmap更新时刷新守护程序吊舱

当Kubernetes中的configmap更新时刷新守护程序吊舱,kubernetes,kubernetes-pod,configmap,Kubernetes,Kubernetes Pod,Configmap,如何在更新与守护程序关联的Kubernetes Pod的configmap时自动重新启动它们 根据文档,当更新configmap卷装载时,它会自动更新POD。但是,我不认为守护程序会发生这种情况。我错过了什么 下面是我的配置图 apiVersion: v1 kind: ConfigMap metadata: name: fluent-bit-update namespace: default labels: k8s-app: fluent-bit data: # Conf

如何在更新与守护程序关联的Kubernetes Pod的configmap时自动重新启动它们

根据文档,当更新configmap卷装载时,它会自动更新POD。但是,我不认为守护程序会发生这种情况。我错过了什么

下面是我的配置图

apiVersion: v1
kind: ConfigMap
metadata:
  name: fluent-bit-update
  namespace: default
  labels:
    k8s-app: fluent-bit
data:
  # Configuration files: server, input, filters and output
  # ======================================================
  fluent-bit.conf: |
    [SERVICE]
        Flush         1
        Log_Level     info
        Daemon        off
        Parsers_File  parsers.conf


    @INCLUDE input-kubernetes.conf
    @INCLUDE filter-kubernetes.conf
    @INCLUDE output-logaggregator.conf

  input-kubernetes.conf: |
    [INPUT]
        Name              tail
        Tag               kube.*
        Path              /var/log/containers/abc.log
        Parser            docker
        DB                /var/log/tail-containers-state.db
        DB.Sync           Normal
        Mem_Buf_Limit     5MB
        Skip_Long_Lines   On
        Refresh_Interval  10
        Rotate_Wait      60
        Docker_Mode      On

  filter-kubernetes.conf: |

    [FILTER]
        Name                kubernetes
        Match               kube.*
        Kube_URL            https://kubernetes.default.svc:443
        Kube_CA_File        /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
        Kube_Token_File     /var/run/secrets/kubernetes.io/serviceaccount/token
        Kube_Tag_Prefix     kube.var.log.conatiners.
        Merge_Log           On
        Keep_Log            Off
        K8S-Logging.Parser  On
        K8S-Logging.Exclude Off
        Labels              On
        Annotations         On

  output-kubernetes.conf: |

    [OUTPUT]
        Name              cloudwatch
        Match             kube.*
        region            us-west-2
        log_group_name    fluent-bit-cloudwatch
        log_stream_prefix from-fluent-bit
        auto_create_group true

  parsers.conf: |

    [PARSER]
        Name         docker
        Format       json
        Time_Key     time
        Time_Format  %Y-%m-%dT%H:%M:%S.%L
        Time_Keep    On
        Decode_Field_As   escaped_utf8    log    do_next
        Decode_Field_As   json       log

    [PARSER]
        Name         docker_default
        Format       json
        Time_Key     time
        Time_Format  %Y-%m-%dT%H:%M:%S.%L
        Time_Keep    On
&我的守护程序清单文件

apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
  name: fluent-bit-update
  namespace: default
  labels:
    k8s-app: fluent-bit-logging
    version: v1
    kubernetes.io/cluster-service: "true"
spec:
  template:
    metadata:
      labels:
        k8s-app: fluent-bit-logging
        version: v1
        kubernetes.io/cluster-service: "true"
      annotations:
        prometheus.io/scrape: "true"
        prometheus.io/port: "2020"
        prometheus.io/path: /api/v1/metrics/prometheus
    spec:
      containers:
        - name: aws-for-fluent-bit
          image: amazon/aws-for-fluent-bit:latest
          imagePullPolicy: Always
          ports:
            - containerPort: 2020
          volumeMounts:
            - name: varlog
              mountPath: /var/log
            - name: varlibdockercontainers
              mountPath: /var/lib/docker/containers
              readOnly: true
            - name: fluent-bit-volume
              mountPath: /fluent-bit/etc/
      terminationGracePeriodSeconds: 10
      volumes:
        - name: varlog
          hostPath:
            path: /var/log
        - name: varlibdockercontainers
          hostPath:
            path: /var/lib/docker/containers
        - name: fluent-bit-volume
          configMap:
            name: fluent-bit-update
      serviceAccountName: fluent-bit
      tolerations:
        - key: node-role.kubernetes.io/master
          operator: Exists
          effect: NoSchedule
        - operator: "Exists"
          effect: "NoExecute"
        - operator: "Exists"
          effect: "NoSchedule"
当我更新configmap中的Path字段以读取另一个日志文件时,虽然我看到卷装载正在更新,但除非我删除并重新创建守护程序,否则我看不到POD接收到更改


有没有一种方法可以在不重新启动守护程序的情况下自动实现这一点?我希望得到一些指导。谢谢

根据您指出的文档,Kubernetes将在您的情况下更新configmap fluent位配置,但您的应用程序有责任选择更新的配置。通常,应用程序会在启动时获取配置,但要定期更新配置,应用程序应支持此模块,或者应使用另一个模块(如配置更新程序),当配置发生更改时,该模块将重新启动应用程序而不重新启动pod。 对于fluent bit,您可以参考此动态配置。
普罗米修斯已经像这样支持它。

根据您指出的文档,Kubernetes将在您的情况下更新configmap fluent位配置,但您的应用程序有责任选择更新的配置。通常,应用程序会在启动时获取配置,但要定期更新配置,应用程序应支持此模块,或者应使用另一个模块(如配置更新程序),当配置发生更改时,该模块将重新启动应用程序而不重新启动pod。 对于fluent bit,您可以参考此动态配置。
普罗米修斯已经像这样支持它了。

使用重载器是唯一的选择吗?你说的什么意思?我看不到吊舱捡起零钱。Kubernetes只负责使用更新的配置映射更新卷。使用重新加载程序是唯一的选项吗?我看不到POD接受更改是什么意思。Kubernetes只负责使用更新的配置映射更新卷。