Alina TrofimovaIntroduction Upgrading Cilium, a critical networking and security solution for Kubernetes,...
Upgrading Cilium, a critical networking and security solution for Kubernetes, often introduces complex challenges. Recently, users upgrading from Cilium 1.18.16 to 1.19.10 or 1.20.4 have encountered a persistent issue: the Cilium agent enters an Init:CrashLoopBackOff state. This failure originates from the config init container, which is unable to establish a connection to the Kubernetes API server due to an I/O timeout. While the worker node can successfully reach the API server's ClusterIP using tools like curl, Cilium’s initialization process fails to do so, exposing a specific connectivity issue within the containerized environment. This discrepancy highlights a critical interaction between Cilium’s initialization logic and Kubernetes API server accessibility during upgrades.
The implications are severe: prolonged cluster downtime, potential misapplication of network policies, and increased operational burden for administrators. This issue is particularly pressing for users migrating to Cilium 1.19 or 1.20. While a workaround exists, it circumvents the problem without resolving the underlying API connectivity failure, necessitating further investigation. This article dissects the technical mechanisms driving the issue, the causal relationships between components, and the practical steps to mitigate immediate disruptions, ensuring smoother operations for Kubernetes clusters dependent on Cilium.
The issue originates in the config init container, which is responsible for fetching Cilium’s configuration by querying the Kubernetes API server. During the upgrade process, this container executes the command cilium-dbg build-config, which relies on API communication to retrieve essential configuration data. The failure occurs when the container’s network namespace cannot establish a TCP connection to the API server within the configured timeout period, despite the host network (accessible via curl) functioning correctly. This indicates a namespace-specific connectivity issue, likely exacerbated by transient network policies or incomplete service discovery during the upgrade.
The causal sequence is as follows:
The presence of CiliumNodeConfig may compound this issue by introducing additional API dependencies or configuration conflicts during the upgrade. However, the precise interaction between CiliumNodeConfig and the connectivity failure requires further analysis to establish causality.
A community-developed workaround circumvents the issue by eliminating the config init container and configuring Cilium to read its settings directly from a ConfigMap. While effective in restoring Cilium functionality, this approach does not address the root cause of the API connectivity failure. Implementation steps are as follows:
Check for existing CiliumNodeConfig resources:
kubectl get ciliumnodeconfigs.cilium.io -A
Add the following to your Helm values file (e.g., my-values.yaml) to disable the init container and specify the ConfigMap source:
daemon: configSources: "config-map:cilium-config"
Execute the Helm upgrade command with the modified configuration:
helm upgrade cilium cilium/cilium \--version 1.20.4 \-n kube-system \-f my-values.yaml
This configuration removes the config init container, allowing Cilium to start without API connectivity issues. However, it disables CiliumNodeConfig as a configuration source, which may impact clusters relying on per-node overrides. Administrators must weigh the trade-offs before implementing this workaround.
While the workaround provides immediate operational relief, it does not resolve the underlying API connectivity issue. By bypassing the config init container, the CrashLoopBackOff state is avoided, but the root cause remains unaddressed. This leaves clusters vulnerable to recurrence during future upgrades or configuration changes.
Key risks include:
Administrators should monitor clusters closely and treat this workaround as a temporary measure until a permanent fix is released by the Cilium development team.
The Init:CrashLoopBackOff issue during Cilium upgrades represents a significant operational challenge for Kubernetes administrators, stemming from a namespace-specific API connectivity failure in the config init container. While the community-driven workaround restores functionality by bypassing the problematic container, it does not address the underlying cause. Understanding the technical mechanisms and trade-offs of this issue is critical for effective management of Cilium upgrades and ensuring Kubernetes cluster stability.
For affected users, this workaround can mitigate immediate downtime, but vigilance is required to monitor for residual connectivity issues. Long-term resolution depends on a comprehensive fix from the Cilium project, which will provide a more robust and sustainable solution. Administrators are encouraged to stay informed about ongoing investigations and contribute to the community’s efforts in resolving this issue.
The Cilium upgrade issue manifesting as Init:CrashLoopBackOff during transitions from version 1.18.16 to 1.19.10 or 1.20.4 originates from a critical failure in the config init container. This container is responsible for initializing Cilium’s configuration by querying the Kubernetes API server. The failure occurs due to an I/O timeout when the container attempts to establish a TCP connection to the API server. The error message explicitly states:
"Unable to contact k8s api-server: Get 'https://10.96.0.1:443/api/v1/namespaces/kube-system': dial tcp 10.96.0.1:443: i/o timeout"
While the host network functions correctly—as evidenced by successful curl requests to the API ClusterIP—the container’s isolated network namespace fails to resolve or connect to the API server’s ClusterIP. This discrepancy underscores a namespace-specific connectivity issue, attributable to the following mechanisms:
The causal chain is as follows:
config init container, which executes cilium-dbg build-config, requiring API server access to fetch Cilium’s configuration.cilium-dbg build-config to fail.Init:CrashLoopBackOff state, which halts the Cilium agent’s initialization and prolongs cluster downtime.This issue is not isolated but arises in multiple scenarios, each driven by distinct mechanisms:
| Scenario | Mechanism |
| 1. Upgrading to Cilium 1.19/1.20 | The config init container fails due to incomplete kube-proxy configuration during the upgrade, preventing API server connectivity. |
2. Using CiliumNodeConfig Overrides
|
Per-node configurations introduce additional API dependencies, exacerbating connectivity issues during upgrades. |
| 3. Transient Network Policies | Misapplied or temporary Cilium network policies block the container’s outbound traffic to the API server. |
| 4. Incomplete Kube-Proxy Configuration | IPVS or iptables rules fail to propagate fully, preventing the container from resolving the API server’s ClusterIP. |
| 5. Network Namespace Isolation | The container’s network namespace lacks necessary routes or DNS resolution for the API server, isolating it from cluster networking. |
| 6. Resource Contention During Upgrade | High CPU or memory usage during the upgrade delays API server responses, triggering timeouts in the config init container. |
The proposed workaround—bypassing the config init container and configuring Cilium to read from a ConfigMap—provides immediate relief but introduces significant risks:
CiliumNodeConfig: Per-node configuration overrides are disabled, reducing flexibility in cluster management.The underlying risk mechanisms are:
CiliumNodeConfig may lead to configuration drift if per-node overrides were previously used.A permanent fix from the Cilium development team is critical to address the root cause and ensure stable, reliable upgrades.
Upgrading Cilium from version 1.18.16 to 1.19.10 or 1.20.4 may trigger a critical failure where the config init container fails to establish a TCP connection to the Kubernetes API server's ClusterIP. This failure occurs within the container's network namespace, resulting in an I/O timeout and causing the Cilium agent to enter Init:CrashLoopBackOff. The host network remains functional, isolating the issue to the container's network configuration. Below is a structured guide to diagnose, apply a temporary workaround, and understand the underlying mechanisms.
Confirm the failure by inspecting the logs of the config init container:
kubectl describe pod <cilium-pod-name> -n kube-system
Unable to contact k8s api-server: Get "https://10.96.0.1:443/api/v1/namespaces/kube-system": dial tcp 10.96.0.1:443: i/o timeout
Ensure the host network can reach the Kubernetes API server, confirming the issue is namespace-specific:
curl -k https://10.96.0.1:443/api/v1/namespaces/kube-system
Determine if CiliumNodeConfig is in use, as it may introduce additional API dependencies that exacerbate the issue:
kubectl get ciliumnodeconfigs.cilium.io -A
Bypass the config init container by configuring Cilium to read settings directly from the ConfigMap:
my-values.yaml):daemon: configSources: "config-map:cilium-config"
helm upgrade cilium cilium/cilium --version 1.20.4 -n kube-system -f my-values.yaml
Verify that the Cilium agents start successfully:
kubectl get pods -n kube-system | grep cilium
Running state.While this workaround resolves the immediate issue, it introduces significant risks:
CiliumNodeConfig: Eliminates per-node configuration overrides, reducing cluster management flexibility.Mechanism: The workaround redirects configuration retrieval from the config init container to the ConfigMap, circumventing the namespace-specific connectivity issue. However, it does not rectify the container's network namespace failure, leaving the cluster susceptible to similar issues.
The Cilium development team must address the root cause of the API connectivity failure to ensure stable upgrades. Track progress in the Cilium issue: Cilium Issue #44464.
The Cilium upgrade issue resulting in Init:CrashLoopBackOff stems from Kubernetes API timeouts during the initialization process. While a workaround exists, it circumvents the symptom rather than resolving the underlying connectivity problem. Below are evidence-based strategies to mitigate risks during Cilium upgrades, focusing on pre-upgrade validation, proactive monitoring, and robust configuration practices.
Prior to initiating the upgrade, confirm that all nodes can establish connections to the Kubernetes API server. Utilize kubectl or curl to test connectivity to the API server's ClusterIP (10.96.0.1:443). This ensures the Cilium init container's network namespace can resolve and connect to the API server, preventing I/O timeouts.
Mechanism: Incomplete service proxy rules (e.g., kube-proxy IPVS/iptables) or misconfigured network policies can obstruct API access. Pre-upgrade testing identifies these issues before they trigger failures.
Inspect active CiliumNodeConfig resources using kubectl get ciliumnodeconfigs.cilium.io -A. Evaluate whether these configurations introduce additional API dependencies or conflicts that could exacerbate upgrade issues.
Mechanism: CiliumNodeConfig increases API interaction complexity, potentially delaying or blocking the config init container's initialization process due to transient connectivity issues.
Examine Cilium network policies for rules that may inadvertently block outbound traffic to the Kubernetes API server during upgrades. Temporarily disable or adjust policies to ensure uninterrupted API access.
Mechanism: Transient policies applied during upgrades can block the config init container's TCP connection attempts, triggering timeouts.
During upgrades, actively monitor the logs of the config init container for I/O timeout errors. Leverage kubectl logs or centralized logging solutions to detect issues promptly.
Mechanism: Early detection of timeout errors enables immediate intervention, minimizing downtime and operational impact.
Implement monitoring for Kubernetes API server latency and response times. Elevated latency or resource contention can delay API responses, triggering timeouts in the init container.
Mechanism: Resource-constrained API servers may fail to respond within the init container's timeout window, leading to crashes.
Configure alerts for pods entering CrashLoopBackOff states during upgrades. This facilitates rapid response to prevent prolonged cluster unavailability.
Mechanism: Timely alerts enable administrators to apply workarounds or investigate root causes before the issue escalates.
Configure Cilium to read settings from a ConfigMap instead of relying on the config init container. Add daemon: configSources: "config-map:cilium-config" to your Helm values file.
Mechanism: Bypassing the init container eliminates the risk of namespace-specific connectivity issues during upgrades.
Avoid using CiliumNodeConfig unless strictly necessary. Per-node overrides increase complexity and API dependencies, elevating the risk of upgrade failures.
Mechanism: Reducing API interactions during upgrades lowers the likelihood of transient connectivity issues.
Always test Cilium upgrades in a staging environment that mirrors production. This identifies potential issues without impacting live workloads.
Mechanism: Staging environments replicate production configurations, exposing upgrade-related problems before they affect critical systems.
The workaround of using ConfigMap instead of the config init container mitigates immediate symptoms but introduces risks:
The underlying API connectivity failure remains unresolved, leaving clusters susceptible to recurrence.
Mechanism: The workaround shifts the failure point without addressing the namespace-specific connectivity issue.
Disabling CiliumNodeConfig diminishes cluster management flexibility and risks configuration drift if overrides were previously used.
Mechanism: Loss of per-node configurations can lead to misaligned settings across nodes, causing policy or performance inconsistencies.
Manual application of the workaround heightens the risk of misconfiguration, particularly in large or complex clusters.
Mechanism: Human error during Helm configuration changes can introduce unintended side effects or inconsistencies.
While the workaround provides temporary relief, a permanent fix from the Cilium development team is essential. Monitor Cilium Issue #44464 for updates on root cause resolution. In the interim, adopt the above practices to minimize upgrade risks and maintain system stability.
Mechanism: Addressing the root cause ensures stable upgrades by resolving namespace-specific connectivity issues, eliminating the need for temporary workarounds.