Skip to main content

ConfigMaps

Immutable Configmaps Improve Performance

To understand the performace improvement with configmaps, you should undersgtand how configmaps and its updates are treated by Kubelet.

🫸 Kubelet & ConfigMap

Kubelet, the agent that runs on each node, plays a important role in ensuring that the configurations defined in ConfigMaps are kept in sync with the pods that consume them.

When a pod is first created, Kubelet fetches the ConfigMap specified in the pod's configuration.

Kubelet periodically synchronizes the ConfigMap data with the pod's filesystem. This ensures that the data remains up to date if the ConfigMap is updated.

Kubelet checks ConfigMaps based on the syncFrequency setting in the KubeletConfiguration file.

By default, this is set to 1 minute, meaning Kubelet checks for updates to ConfigMaps every 1 minute. If any changes are detected, Kubelet updates the running containers with the new configurations.

Here is what official documenation says about configmpa updates.

Kubelet checks whether the mounted ConfigMap is fresh on every periodic sync. However, it uses its local TTL-based cache for getting the current value of the ConfigMap. As a result, the total delay from the moment when the ConfigMap is updated to the moment when new keys are projected to the pod can be as long as kubelet sync period (1 minute by default) + TTL of ConfigMaps cache (1 minute by default) in kubelet. You can trigger an immediate refresh by updating one of the pod's annotations.

⚙️ Performance Improvement Immutable Configmaps

Now think of large production clusters with thousands of configmaps? It comes with a cost to continuously watch for changes.

When a ConfigMap is marked as immutable, kubelet does not watch for changes.

This eliminates the need for Kubelet to continuously check for updates, thereby improving performance.

From the official documentation.

improves performance of your cluster by significantly reducing load on kube-apiserver, by closing watches for ConfigMaps marked as immutable.