Ingress-nginx: server-alias annotation not working since version 0.29.0 and 0.30.0

Created on 19 Mar 2020  路  10Comments  路  Source: kubernetes/ingress-nginx

NGINX Ingress controller version: 0.30.0 and 0.29.0

Kubernetes version (use kubectl version):

Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.6", GitCommit:"7015f71e75f670eb9e7ebd4b5749639d42e20079", GitTreeState:"clean", BuildDate:"2019-11-13T11:20:18Z", GoVersion:"go1.12.12", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.9", GitCommit:"500f5aba80d71253cc01ac6a8622b8377f4a7ef9", GitTreeState:"clean", BuildDate:"2019-11-13T11:13:04Z", GoVersion:"go1.12.12", Compiler:"gc", Platform:"linux/amd64"}

Environment:

  • Cloud provider or hardware configuration: AWS with kops
  • OS (e.g. from /etc/os-release): Debian
  • Kernel (e.g. uname -a):
  • Install tools: helm
  • Others:

What happened: Using annotation nginx.ingress.kubernetes.io/server-alias does not work any more with ingress controller version 0.30.0 and 0.29.0

What you expected to happen: Using annotation nginx.ingress.kubernetes.io/server-alias to work correctly like it works with 0.28.0 and probably older

How to reproduce it: In an ingress definition use annotation nginx.ingress.kubernetes.io/server-alias and observe it not working due to no definition added among the server_name;

Anything else we need to know:

/kind bug

kinbug

Most helpful comment

Hi @smoke The same thing happened to me when I upgraded to 0.30.0. My alias definitions stopped working on the upgrade..

All 10 comments

@smoke how are you defining the values? do you have more than one value? comma-separated?

@aledbf I have both, also I have specifically tried both - it is broken regardless. I have also checked out the versions explicitly and I found that with 0.28.0 it works, where with 0.29.0 and 0.30.0 it does not work, so I have updated the ticket accordingly.

@smoke I cannot reproduce this.

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.30.0/deploy/static/mandatory.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.30.0/deploy/static/provider/baremetal/service-nodeport.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.30.0/docs/examples/http-svc.yaml

echo '
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: delay
  annotations:
    nginx.ingress.kubernetes.io/server-alias: else.dev,test.dev
spec:
  rules:
  - host: something.dev
    http:
      paths:
      - backend:
          serviceName: http-svc
          servicePort: 80
        path: /
' | kubectl apply -f -
k exec -n ingress-nginx nginx-ingress-controller-7f74f657bd-wjlfp cat nginx.conf|grep something.dev
    ## start server something.dev
        server_name something.dev else.dev test.dev ;
    ## end server something.dev

Please check the ingress definitions and the ingress controller pod log.

@aledbf Hm, there is something fishy - now it works. What I can say is that I have 2 Ingress definitions, both defining same host, same server-alias and different service and paths. I have had an ingress-nginx with version 0.28.0, then when I updated to 0.30.0 the server_alias was not respected. However now when I was digging for more details - I have changed the helm chart causing one of the Ingress to be deleted and then created again and now everything seems to be working fine.
I am sorry but I don't have kind or minikube to try it out, I will try to reproduce it in isolation tomorrow.

Closing. Please reopen when you can provide reproducible steps.

Hi @smoke The same thing happened to me when I upgraded to 0.30.0. My alias definitions stopped working on the upgrade..

We are also encountering this issue on v0.30.0. I believe it is related to having more than one ingress for the same host. My guess, from looking at controller.go:1135, is that it expects the server-alias to exist on the first ingress it processes and any subsequent ingresses with the server-alias annotation are ignored.

I was able to reproduce it by applying the ingress in this order

---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: app-b
spec:
  rules:
    - host: app.mydomain.com
      http:
        paths:
          - backend:
              serviceName: my-app-b
              servicePort: 80
            path: /app-b
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/server-alias: app-alias.mydomain.com
  name: app-a
spec:
  rules:
    - host: app.mydomain.com
      http:
        paths:
          - backend:
              serviceName: my-app-a
              servicePort: 80
            path: /app-a

@eerichmond thank you for reproducing the issue. I just opened https://github.com/kubernetes/ingress-nginx/pull/5309 to address the issue, adding a new e2e test to avoid regressions.
The image quay.io/kubernetes-ingress-controller/nginx-ingress-controller-amd64:dev contains the mentioned PR.

@eerichmond @aledbf I confirm that this matches our setup as well, so this finding is pretty plausible.

Those guys who are having issues in making server-alias work. I was also facing the same issue that even after using 2 different ingress yamls, one having all the rules and a wildcard DNS domain and other having just the hostnames which will be included in server-alias annotation. I used the following configuration in configmap of nginx ingress controller:-

apiVersion: v1
data:
  add-headers: ingress-nginx/custom-headers
  server-tokens: "false"
kind: ConfigMap
metadata:
  labels:
    app.kubernetes.io/component: controller
    app.kubernetes.io/instance: ingress-nginx
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/version: 0.33.0
    helm.sh/chart: ingress-nginx-2.4.0
  name: ingress-nginx-controller
  namespace: ingress-nginx 

And created the following configmap named custom-headers:-

apiVersion: v1
data:
  server-names-hash-bucket-size: "128"  # <- This is the main thing which drives the addition of new server alias
kind: ConfigMap
metadata:
  name: custom-headers
  namespace: ingress-nginx
Was this page helpful?
0 / 5 - 0 ratings