Automate Proxy Injection in EKS Fargate with Kyverno
In a world where cloud-native applications need to communicate securely and efficiently, managing proxy settings can become a cumbersome task. Manually adding proxy environment variables to each container in your deployment manifests is not only error-prone but also time-consuming. Automating this process with Kyverno allows you to enforce consistent proxy settings across your pods, enhancing security and simplifying your deployment workflow.
Kyverno operates as a mutating admission webhook within your Kubernetes cluster. When a pod creation request is made, the API server sends an AdmissionReview to Kyverno. If the pod's namespace is labeled with proxy-injection: enabled, Kyverno injects the necessary HTTPS_PROXY, HTTP_PROXY, and NO_PROXY environment variables into every container and init container at admission time. This means that your applications will start with the correct proxy settings already in place, allowing them to route outbound calls through the corporate proxy without additional configuration. The failurePolicy: Ignore setting ensures that pod scheduling is not blocked if the webhook is temporarily unavailable, maintaining your deployment's reliability.
In production, ensure that your Fargate profiles are correctly configured to match CoreDNS, Kyverno, and any other pods you schedule. Be aware that while CIDR ranges in NO_PROXY are honored by some clients, others like curl and libcurl may not behave as expected. This can lead to unexpected behavior if your applications rely on these tools for outbound communication. Always verify your proxy settings and test your applications thoroughly to avoid connectivity issues.
Key takeaways
- →Leverage Kyverno's MutatingPolicy to automate proxy injection for EKS Fargate pods.
- →Use the `proxy-injection: enabled` label to trigger automatic environment variable injection.
- →Configure `failurePolicy: Ignore` to prevent deployment issues during webhook outages.
- →Be cautious of NO_PROXY behavior across different clients, especially with curl and libcurl.
- →Ensure Fargate profiles are correctly set up to avoid pending states for your pods.
Why it matters
Automating proxy injection reduces manual errors and saves time, allowing your team to focus on building features rather than managing configurations. This consistency enhances security by ensuring all outbound traffic is routed through the corporate proxy.
Code examples
One MutatingPolicy of roughly 30 lines of YAML covers each pod in a labeled namespace, instead of three environment variables added by hand to each container in each deployment manifest.When NOT to use this
The official docs don't call out specific anti-patterns here. Use your judgment based on your scale and requirements.
Want the complete reference?
Read official docsIndustry-standard certifications built by the people behind Linux and Kubernetes. Earn the CKA — the gold standard Kubernetes administrator cert. OpsCanary readers get 30% off year-round with code OPSCANARY3.
Get CKA certified →Streamline Your ECR Workflow with Global Authentication Tokens
Managing container images across multiple AWS Regions can be a hassle. A global authentication token simplifies this by allowing you to push and pull images in any Region with a single token. Learn how to leverage this feature effectively in your Kubernetes deployments.
Kube-Proxy IPVS Backend: Transitioning to Nftables
The kube-proxy IPVS backend is on its way out, and understanding this transition is crucial for maintaining performance. With Kubernetes 1.35 marking its deprecation and a planned removal in 1.40, it’s time to shift your focus to the nftables backend. This article dives into the mechanics and implications of this change.
Mastering Kubernetes Networking: The CKNE Certification Unpacked
The Certified Kubernetes Network Engineer (CKNE) certification is here to elevate your networking skills in Kubernetes. This performance-based exam tests your ability to handle real-world networking challenges across production environments. Dive in to understand the key domains covered and how this certification can impact your career.
Get the daily digest
One email. 5 articles. Every morning.
No spam. Unsubscribe anytime.