From 1b5f8b8779bedb514d3b32ffc95b2acb1fc70ea5 Mon Sep 17 00:00:00 2001 From: Arjan Schaaf Date: Mon, 24 Apr 2017 16:24:20 +0200 Subject: [PATCH 1/3] ConfigMap with proxy-set-headers not required when using the configuration-snippets to add a custom header to a specific Ingress configuration. The Ingress does need to be created for the example to work. --- .../configuration-snippets/nginx/README.md | 10 +++++++++- .../nginx/nginx-load-balancer-conf.yaml | 7 ------- 2 files changed, 9 insertions(+), 8 deletions(-) delete mode 100644 examples/customization/configuration-snippets/nginx/nginx-load-balancer-conf.yaml diff --git a/examples/customization/configuration-snippets/nginx/README.md b/examples/customization/configuration-snippets/nginx/README.md index 9adfa78a0..de277c424 100644 --- a/examples/customization/configuration-snippets/nginx/README.md +++ b/examples/customization/configuration-snippets/nginx/README.md @@ -38,7 +38,15 @@ default-http-backend-2657704409-qgwdd 1/1 Running 0 2m nginx-ingress-controller-873061567-4n3k2 1/1 Running 0 42s ``` +## Ingress +The Ingress in this example adds a custom header to Nginx configuration that only applies to that specific Ingress. If you want to add headers that apply globally to all Ingresses, please have a look at [this example](/examples/customization/custom-headers/nginx). + +```console +$ kubectl apply -f ingress.yaml +deployment "nginx-ingress-controller" created +``` + ## Test -Check the contents of the annotation is present in the nginx.conf file using: +Check if the contents of the annotation are present in the nginx.conf file using: `kubectl exec nginx-ingress-controller-873061567-4n3k2 -n kube-system cat /etc/nginx/nginx.conf` diff --git a/examples/customization/configuration-snippets/nginx/nginx-load-balancer-conf.yaml b/examples/customization/configuration-snippets/nginx/nginx-load-balancer-conf.yaml deleted file mode 100644 index 239918267..000000000 --- a/examples/customization/configuration-snippets/nginx/nginx-load-balancer-conf.yaml +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: v1 -data: - proxy-set-headers: "kube-system/custom-headers" -kind: ConfigMap -metadata: - name: nginx-load-balancer-conf - namespace: kube-system From 4c54a7be03f9840968b4550d8e6e1ae5ee2b8798 Mon Sep 17 00:00:00 2001 From: Arjan Schaaf Date: Mon, 24 Apr 2017 16:25:16 +0200 Subject: [PATCH 2/3] ConfigMap with proxy-set-headers not required when using the configuration-snippets to add a custom header to a specific Ingress configuration. The Ingress does need to be created for the example to work. --- examples/customization/configuration-snippets/nginx/README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/examples/customization/configuration-snippets/nginx/README.md b/examples/customization/configuration-snippets/nginx/README.md index de277c424..798e3e17e 100644 --- a/examples/customization/configuration-snippets/nginx/README.md +++ b/examples/customization/configuration-snippets/nginx/README.md @@ -20,10 +20,6 @@ NAME READY STATUS RESTARTS AGE default-http-backend-2657704409-qgwdd 1/1 Running 0 28s ``` -```console -$ kubectl create -f nginx-load-balancer-conf.yaml -``` - ## Controller You can deploy the controller as follows: From 1a191846a9c3ffd098b7293257863ac85617ece2 Mon Sep 17 00:00:00 2001 From: Arjan Schaaf Date: Mon, 24 Apr 2017 16:27:56 +0200 Subject: [PATCH 3/3] Mentioned in the comments of #180 the annotation for configuration snippets was missing from the configuration documentation --- controllers/nginx/configuration.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/controllers/nginx/configuration.md b/controllers/nginx/configuration.md index b5b19b627..678875046 100644 --- a/controllers/nginx/configuration.md +++ b/controllers/nginx/configuration.md @@ -48,6 +48,7 @@ The following annotations are supported: |[ingress.kubernetes.io/auth-url](#external-authentication)|string| |[ingress.kubernetes.io/auth-tls-secret](#certificate-authentication)|string| |[ingress.kubernetes.io/auth-tls-verify-depth](#certificate-authentication)|number| +|[ingress.kubernetes.io/configuration-snippet](#configuration-snippet)|string| |[ingress.kubernetes.io/enable-cors](#enable-cors)|true or false| |[ingress.kubernetes.io/force-ssl-redirect](#server-side-https-enforcement-through-redirect)|true or false| |[ingress.kubernetes.io/limit-connections](#rate-limiting)|number| @@ -151,6 +152,14 @@ The validation depth between the provided client certificate and the Certificati Please check the [tls-auth](/examples/auth/client-certs/nginx/README.md) example. +### Configuration snippet + +Using this annotion you can add additional configuration to the NGINX location. For example: + +``` +ingress.kubernetes.io/configuration-snippet: | + more_set_headers "Request-Id: $request_id"; +``` ### Enable CORS