---
title: "Reload Prometheus ConfigMap without Restarting the Kubernetes Pod"
source: "https://support.tools/reload-prometheus-configmap-kubernetes/"
published: 2024-09-04
categories: ["Prometheus","Kubernetes"]
tags: ["Prometheus","Kubernetes","ConfigMap","Reload","DevOps"]
---


In Kubernetes, Prometheus configuration changes traditionally require a pod restart to take effect. However, using a configuration reload method, you can avoid downtime and ensure smooth configuration updates.

### The Problem

When running Prometheus in Kubernetes, configuration changes to the Prometheus ConfigMap typically require a pod restart to load the new configuration. While configuration changes might not happen often, the downtime from restarting the pod can be undesirable.

### The Solution

Starting with Prometheus 2.0, you can enable HTTP reloads using the `--web.enable-lifecycle` flag and integrate the `configmap-reload` container to trigger a reload when the ConfigMap is updated.

The `configmap-reload` is a simple binary that watches for changes in the Kubernetes ConfigMap and triggers a reload in Prometheus when needed. Here’s how you can set it up.

### Step-by-Step Implementation

#### 1. Update Your Prometheus Deployment

First, update your Prometheus Deployment configuration to enable HTTP reloads by adding the `--web.enable-lifecycle` flag. You also need to add the `prometheus-server-configmap-reload` container to handle the reloads.

Here is an example Kubernetes Deployment configuration with the necessary changes. Most of the non-relevant parts of the deployment have been omitted for simplicity:

```yaml
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: prometheus-server
  namespace: monitoring
spec:
  template:
    spec:
      volumes:
        - name: config-volume
          configMap:
            name: prometheus-server
            defaultMode: 420
      containers:
        - name: prometheus-server-configmap-reload
          image: jimmidyson/configmap-reload:v0.5.0
          imagePullPolicy: IfNotPresent
          args:
            - '--volume-dir=/etc/config'
            - '--webhook-url=http://127.0.0.1:9090/-/reload'
          volumeMounts:
            - name: config-volume
              readOnly: true
              mountPath: /etc/config
        - name: prometheus-server
          image: quay.io/prometheus/prometheus:v2.37.0
          imagePullPolicy: IfNotPresent
          args:
            - '--config.file=/etc/config/prometheus.yml'
            - '--enable-feature=expand-external-labels'
            - '--storage.tsdb.path=/data'
            - '--storage.tsdb.retention.time=14d'
            - '--web.enable-lifecycle'
```

#### 2. Deploy the Updated Configuration

After making these changes, deploy the updated configuration to your Kubernetes cluster. The `prometheus-server-configmap-reload` container will monitor changes in the Prometheus ConfigMap and automatically reload the configuration without restarting the pod.

### Final Thoughts

By adding the `--web.enable-lifecycle` flag and the `configmap-reload` container, you can make your Prometheus configuration dynamic and reload changes seamlessly, avoiding downtime and improving overall efficiency.

## [Reload Prometheus ConfigMap without Restarting the Kubernetes Pod](#reload-prometheus-configmap-without-restarting-the-kubernetes-pod)

Utilizing the HTTP reload endpoint and the configmap-reload container, you can make Prometheus reload its configuration without restarting the pod.

