Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

341
Vistas
How to notify application about updated config file in kubernetes?

When having configmap update, how to automatically trigger the reload of parameters by the application? Application uses POSIX signals for that.

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Depending on how you are consuming the configmap values, there could be two ways in which you can reload the configmap updates into a running pod.

  • If you are consuming the configs as environment variables, you can write a controller, which watches for the updates in configs and restarts your pods with new config whenever the config changes.

  • If you are consuming the configmap via volumes, you can watch for file changes and notify that to your process in the container and handle the update in application. Please see https://github.com/jimmidyson/configmap-reload for example.

over 4 years ago · Santiago Trujillo Denunciar

0

There are good solutions mentioned around here but I tried to find a solution that could be done without modifying existing deployment pipelines, etc. Here is an example of a filebeat Daemonset from a Helm chart that reloads when the filebeat config changes. The approach is not new: use the liveness probe to trigger a reload of the pod from within the pod itself. The postStart calculates an md5 sum of the configmap directory; the liveness probe checks it. That's all.

The '...' are just to cut out the cruft. You can see that the filebeat.yml file is mounted directly into /etc and used by filebeat itself. The configmap is mounted again, specifically for the purposes of watching the configmap contents for changes.

Once configmap is edited (or otherwise modified), it takes some time before the pod is actually restarted. You can tweak all of that separately.

#apiVersion: apps/v1
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
  name: ...-filebeat
...
      containers:
      - name: ...-filebeat
        image: "{{ .Values.filebeat.image.url }}:{{ .Values.filebeat.image.version }}"
        imagePullPolicy: "{{ .Values.filebeat.image.pullPolicy }}"
        command: [ "filebeat" ]
        args: [
          "-c", "/etc/filebeat-config/filebeat.yml",
          "-e"
        ]
        env:
...
        resources:
...
    lifecycle:
      postStart:
        exec:
          command: ["sh", "-c", "ls -LRih /etc/filebeat-config | md5sum >> /tmp/filebeat-config-md5.txt"]
    livenessProbe:
      exec:
        # Further commands can be strung to the statement e.g. calls with curl
        command:
          - sh
          - -c
          - >
            x=$(cat /tmp/filebeat-config-md5.txt);
            y=$(ls -LRih /etc/filebeat-config | md5sum);
            if [ "$x" != "$y" ]; then exit 1; fi
      initialDelaySeconds: 60
      periodSeconds: 60
    volumeMounts:
    - name: filebeat-config
      mountPath: /etc/filebeat-config
      readOnly: true
....
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda