Fix ingress-nginx Snippet Annotation Errors After 1.9 Upgrade
Deployed a fresh Kubernetes cluster today and hit a wall I’d never seen before. My ingress-nginx Helm deployment failed with errors I’d never encountered in previous setups.
The Problem
Two specific errors stopped my deployment cold:
Error: UPGRADE FAILED: failed to create resource: admission webhook "validate.nginx.ingress.kubernetes.io" denied the request: nginx.ingress.kubernetes.io/server-snippet annotation cannot be used. Snippet directives are disabled by the Ingress administrator
Error: UPGRADE FAILED: failed to create resource: admission webhook "validate.nginx.ingress.kubernetes.io" denied the request: annotation group ServerSnippet contains risky annotation based on ingress configuration
These errors never appeared in my previous ingress-nginx deployments. Something had changed.
The Breaking Change
A quick search led me to GitHub issue #10543, which revealed the culprit: ingress-nginx 1.9 introduced a breaking change for security reasons.
Starting in version 1.9, snippet annotations are disabled by default because they allow arbitrary nginx configuration injection, which poses security risks in multi-tenant environments.
Solution 1: Helm Configuration (Recommended)
For Helm deployments, you need to explicitly enable snippet annotations with two configuration flags:
helm upgrade --install ingress-nginx ingress-nginx/ingress-nginx \
--namespace ingress-nginx --create-namespace \
--set controller.allowSnippetAnnotations=true \
--set controller.config.annotations-risk-level=Critical
What these flags do:
controller.allowSnippetAnnotations=true: Enables the use of snippet annotationscontroller.config.annotations-risk-level=Critical: Sets the risk tolerance for potentially dangerous annotations
Solution 2: ConfigMap Direct Edit
If you already have ingress-nginx deployed, you can modify the ConfigMap directly as suggested in this Stack Overflow answer:
# Edit the ConfigMap
kubectl edit configmap ingress-nginx-controller -n ingress-nginx
# Add these entries to the data section:
# allow-snippet-annotations: "true"
# annotations-risk-level: "Critical"
# Restart the controller to apply changes
kubectl rollout restart deployment ingress-nginx-controller -n ingress-nginx
The ConfigMap should look like this:
data:
allow-snippet-annotations: "true"
annotations-risk-level: "Critical"
Security Considerations
Before enabling snippet annotations, understand the security implications:
- Server snippets allow arbitrary nginx configuration injection
- In multi-tenant environments, this could be exploited for privilege escalation
- Only enable if you trust all users who can create Ingress resources
When to Use Each Solution
- Use Helm configuration for new deployments or when you control the entire installation
- Use ConfigMap editing when modifying existing clusters or when Helm values can’t be easily changed
The Bigger Picture
This change reflects a broader trend in Kubernetes security: making dangerous features opt-in rather than opt-out. It’s a reminder to always check release notes when upgrading infrastructure components.
The 1.9 change caught me off guard because snippet annotations “just worked” in previous versions. Now they require explicit acknowledgment of the security risks involved.
While initially frustrating, this change makes sense for production environments where security should always be a conscious decision, not an accidental default.
For more insights on security-first architectural decisions, check out Building Zero-Trust Secret Management: The Design Decisions Behind the Architecture to see how similar security-over-convenience tradeoffs shape system design.