Container networking is a critical component of modern cloud infrastructure, yet it remains one of the most complex areas for junior engineers to master. When deploying on Amazon Elastic Kubernetes Service (EKS), the default CNI plugin often requires customization for specific security or performance needs. Calico is frequently chosen for its robust policy enforcement capabilities. However, misconfigurations in Calico’s CNI (Container Network Interface) plugins or overly aggressive NetworkPolicy deny rules can lead to complete application isolation and service outages. This guide provides a practical, step-by-step approach to troubleshooting these issues within an EKS environment.
Before diving into the lab steps, it is essential to understand that this content describes general technical procedures and does not constitute individualized legal or financial advice. Terms, availability, and specific behaviors of Kubernetes components depend heavily on the underlying infrastructure provider (AWS, Azure), the specific version of the EKS control plane, the Calico operator version, and local jurisdiction laws regarding data sovereignty. Always verify current documentation from AWS and Tigera (Calico) before applying changes to production clusters.
Understanding the Architecture and Failure Modes
In a typical EKS setup using Calico, the CNI plugin is responsible for assigning IP addresses to pods and setting up routing tables between them. Simultaneously, NetworkPolicy objects define security rules that allow or deny traffic based on labels, namespaces, or IP blocks. A common failure scenario occurs when a developer applies a NetworkPolicy with a broad egress: deny rule intended to secure a specific workload, inadvertently blocking essential DNS resolution (port 53) or cluster internal communication (kube-proxy loopback).
Another frequent issue involves the Calico CNI node agent failing to reconcile IPAM (IP Address Management) resources. If a pod is created but does not receive an IP address, the calico-node DaemonSet logs will typically show errors related to IP allocation failures or BGP neighbor flapping if using overlay networking. Troubleshooting requires a systematic approach that isolates whether the issue lies in the CNI layer (connectivity) or the Policy layer (permission).
Step 1: Verify CNI Plugin Status and Log Analysis
The first actionable step in any troubleshooting scenario is to confirm the health of the Calico nodes and inspect their logs. In an EKS cluster, the calico-node pods run as DaemonSets on every node. If these are unhealthy, no traffic can flow.
-
Check Pod Status: Execute the following command to ensure all Calico nodes are running:
bash
kubectl get pods -n kube-system -l k8s-app=calico-node
Expected Result: All pods should be inRunningstate with0/0restart counts for critical components. -
Inspect Logs for CNI Errors: If a pod is stuck or restarting, examine the logs. Look specifically for messages regarding IPAM allocation failures or interface attachment errors.
bash
kubectl logs -n kube-system -l k8s-app=calico-node --tail=100
Illustrative Output:E "failed to allocate IP": no valid IPs left in the pool. This indicates an exhaustion issue, not necessarily a policy block. -
Validate Interface Attachment: Verify that Calico has successfully attached interfaces to the node. Use
ip addron the underlying OS or check thecalico/nodepod logs for “interface up” messages. If the interface is missing, it suggests a kernel module loading issue or a specific AWS ENI attachment problem.
Step 2: Analyzing NetworkPolicy Deny Rules and DNS Resolution
Once CNI health is confirmed, the focus shifts to policy-induced isolation. A common mistake is applying a deny rule without explicitly allowing egress to 10.96.0.0/16 (kube-system) or external DNS servers (8.8.8.8, 1.1.1.1).
To troubleshoot this, create a test deployment that attempts to resolve an external hostname. If the pod fails with lookup failed or times out, the deny rule is likely too restrictive.
Practical Example Scenario:
Imagine a developer applies a policy to restrict a web server from accessing the internet to prevent data exfiltration:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: strict-deny-egress
namespace: default
spec:
podSelector: {} # Applies to all pods in namespace
policyTypes:
- Egress
egress: [] # Deny all egress by default
Verification Steps:
1. Deploy a simple Nginx pod: kubectl run test-pod --image=nginx.
2. Execute an internal connectivity test from within the pod:
bash
kubectl exec -it test-pod -- nslookup google.com
Expected Result: If the policy is active and restrictive, this command will hang or return a timeout error.
3. Fix: Update the egress section to explicitly allow DNS and required cluster services:
yaml
egress:
- ports:
- port: 53
protocol: UDP
- port: 443
protocol: TCP
Step 3: Validating BGP Peering and Routing Tables
If using Calico’s BGP mode (common in large clusters), routing leaks or dropped routes can occur if the bird process fails to establish peering with other nodes. This manifests as pods being able to reach each other but failing to reach external services.
- Check BIRD Status:
bash
kubectl logs -n kube-system -l k8s-app=calico-node | grep bird - Inspect Routing Tables: From a worker node, check if routes for other pods exist:
bash
ip route show table calico
Common Error: Missing routes for specific pod CIDR blocks often indicate that the BGP peer session timed out due to network instability or incorrect ASN configuration in thecalicoctlconfig.
Industry Application and Student Practice Task
Industry Application:
In a high-security financial environment, teams often use “deny-by-default” policies on Calico. The architecture requires strict segmentation between Dev, Test, and Prod namespaces. Engineers must implement egress controls that allow only specific API gateways while blocking direct internet access. Monitoring tools like Prometheus and Grafana should be configured to alert when calico_node logs show repeated BGP flapping or IP allocation failures, indicating a potential infrastructure attack or misconfiguration.
Student Practice Task:
Scenario: You have an EKS cluster with Calico installed. Your task is to simulate a breach where a malicious pod in the default namespace tries to exfiltrate data via port 443.
1. Create a NetworkPolicy named block-exfiltration that denies all egress from pods in default except those with the label app: allowed-api.
2. Deploy a pod labeled app: bad-actor and attempt to curl an external URL.
3. Document the exact error message received and modify the policy to allow traffic only to a specific whitelisted IP range (e.g., a corporate firewall).
4. Submit a report detailing how you verified the policy was applied using kubectl get networkpolicy -n default.
Common Mistakes and Cost Controls
A frequent error is applying global deny policies without considering the impact on control plane components like CoreDNS or the EKS CNI itself. Always apply policies to specific namespaces rather than cluster-wide unless absolutely necessary, as this reduces operational risk.
From a cost control perspective, inefficient IP allocation in Calico can lead to “IP exhaustion,” where the node’s subnet runs out of addresses despite having free ENIs (Elastic Network Interfaces). This forces the cluster to wait for IPAM cleanup cycles, increasing latency and potentially triggering autoscaling delays. Regularly auditing calicoctl ipam show helps prevent this. Additionally, ensure that unnecessary logging levels are not enabled in production, as high-volume log shipping can inflate AWS CloudWatch costs significantly.
Conclusion
Troubleshooting Calico CNI plugins and NetworkPolicy deny rules in an EKS cluster requires a methodical approach: verify the CNI layer first, then isolate policy restrictions, and finally check routing integrity. By following the numbered steps above—checking pod status, validating DNS resolution against policies, and inspecting BGP peering—engineers can quickly identify root causes. Remember to always test changes in a non-production environment and consult official AWS and Calico documentation for the most current best practices regarding security and compliance.
Educational-use notice: This tutorial is for learning and controlled lab use only. Test carefully, use backups, and obtain authorization before making changes. Do not run unfamiliar commands on production systems. We accept no responsibility for misuse, damage, data loss, or production issues.

