Kubernetes version:
Cloud being used: AWS
Installation method:
Host OS (the client):
Linux Ubuntu 22.04
Hello,
i would like to use a Kubernetes ingress controller and from an external client be able to see if for example serviceB has more errors than the current serviceA.
For this I add two ingresses with one (ingressB) with the following configuration:
And I would like from a client to llop for a while and calculate errors with a curl command to the ingress controller:
curl -iH “Host: hostOfApp” AWS_ENDPOINT:80;
I have try to follow this example: kubernetes.github.io/ingress-nginx/examples/customization/custom-headers/
And it works to allow me to get a customized headers in the response.
But I would like to have a dynamic header allowing from the client perspective to tell if ingressA or ingressB was used and in the end serviceA or serviceB.
I do not have any Canary Header in the responses corresponding to ingressB (serviceB)
Hi,
It seems that nginx does not populate header value correctly. It always returns name of ingress A/service A. One of the options would be to return upstream address to check where request landed.
upstream_service_name header will include name of k8s service that received request. upstream_addr header will include ip of the pod that sent response.
Note that when you mark an ingress as canary, then all the other non-canary annotations
will be ignored (inherited from the corresponding main ingress) except
nginx.ingress.kubernetes.io/load-balance,
nginx.ingress.kubernetes.io/upstream-hash-by,
and annotations related to session affinity.
If you want to restore the original behavior of canaries when session
affinity was ignored, set nginx.ingress.kubernetes.io/affinity-canary-behavior
annotation with value legacy on the canary ingress definition.
From my understanding you can not use at the same time the following annotations:
nginx.ingress.kubernetes.io/configuration-snippet
So I tried to use the canary annotations in a “canary” Ingress, and in the “current version of service” ingress (let’s call it main) I have used nginx.ingress.kubernetes.io/configuration-snippet annotation.
In the end, responses were dispatched from two different services but I can not prove it from the client perspective because response headers from canary ingress included the header that I specified only in the “main” Ingress.
Thank you for your time @fox-md :=)
Noice! Thanks a lot @fox-md it works
For completeness I just had to modify directly the Ingress controller yaml that I downloaded locally because the configmap was not pickup if it was declared with Deployment and service. So I modified the default ConfigMap of the Ingress Nginx Controller.
I had to delete the pod of the Ingress Controller as well after aplying the new configuration-snippet.