I'm trying to add a snippet to an existing Ingress that is attached to an ingress-controller. However, when trying this, i get an error which is:
for: "app-ingress.yml": error when patching "app-ingress.yml": 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
the ingress already exists and I'm trying to patch it to add a header. The updated ingress yaml is as follows:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: app-web-dev
namespace: application
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "true"
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/server-snippet: |
expires 1M;
add_header Cache-Control "public";
spec:
ingressClassName: nginx
tls:
- hosts:
- dev.address.nl
secretName: app-wildcard
rules:
- host: dev.address.nl
http:
paths:
- path: /?(.*)
pathType: Prefix
backend:
service:
name: appwebsvc
port:
number: 80
I'm trying to use helm to update my ingress controller to enable snippets, but i can't find the right commands to do this.
Any ideas?
I am trying something like this:
helm upgrade --namespace ingress-nginx --install --set controller.config.server-snippet=true,controller.service.annotations.nginx\.ingress\.kubernetes\.io/allow-snippet-annotations=true --wait ingress-nginx ingress-nginx/ingress-nginx
kubectl patch
instead?