Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unrelated ingresses targeting the same service/port: annotations for session stickyness not respected #12399

Open
mitchese opened this issue Nov 21, 2024 · 5 comments
Assignees
Labels
kind/support Categorizes issue or PR as a support question. needs-priority needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. triage/needs-information Indicates an issue needs more information in order to work on it.

Comments

@mitchese
Copy link

mitchese commented Nov 21, 2024

We have two ingresses on separate hostnames which target the same service and port. When we annotated the second ingress with
nginx.ingress.kubernetes.io/upstream-hash-by: $remote_addr

this was not added to the nginx configuration and session stickyness did not work. We were able to trace it down to the list provided by

kubectl ingress-nginx backends

which would show that the upstream hash

         "upstreamHashByConfig": {
          "upstream-hash-by-subset-size": 3
     }, 

for both ingresses because it is in a section labeled by the namespace-service-port triplicate.

NGINX Ingress controller version 1.10.

Kubernetes version v1.29.9

Environment:

  • Cloud provider or hardware configuration: onprem bare metal
  • OS (e.g. from /etc/os-release): flatcar (various versions 3975.2.2)
  • Kernel (e.g. uname -a): 6.6.54-flatcar

How to reproduce this issue:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/upstream-hash-by: $remote_addr
  name: a-public-ingress-sticky
spec:
  ingressClassName: nginx
  rules:
  - host: sticky.example.com
      http:
      paths:
      - backend:
          service:
            name: echo-server
            port:
              name: test
        path: /
        pathType: Prefix
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: private-ingress
spec:
  ingressClassName: nginx
  rules:
  - host: service.kubernetes.internal
      http:
      paths:
      - backend:
          service:
            name: echo-server
            port:
              name: test
        path: /
        pathType: Prefix

It is important that both ingresses in the above example are in the same namespace, and both point to the same service and same port, and that the first is alphabetically before the second.

The session stickyness annotation will not be applied and can be verified with
kubectl ingress-nginx backends

and looking for the presence of "upstream-hash-by": "$remote_addr", in the output.

Because these are two separate hostnames I would expect the ingress controller to handle them separately, and that annotations on the seemingly unrelated ingress

I can follow up later with a minikube example

@mitchese mitchese added the kind/bug Categorizes issue or PR as related to a bug. label Nov 21, 2024
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Nov 21, 2024
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If Ingress contributors determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@longwuyuan
Copy link
Contributor

/assign

@longwuyuan
Copy link
Contributor

/remove-kind bug

  • Please look at the questions asked in the template of a new bug report by clicking the new bug report button
  • Edit the description of this issue and answer the questions asked in the template, here in this issue
  • Make sure to use markdown format as shown in the template
  • Make sure to answer all questions so there is data for analysis

Right now, its not even known if you are using the controller released by this project. Or if so, then which version

An attempt to reproduce with 5 replicas of a pod using --image nginx:alpine and even one single ingress with that annotations fails to show the hash directive under the related server block.

/triage needs-information

@k8s-ci-robot k8s-ci-robot added triage/needs-information Indicates an issue needs more information in order to work on it. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. and removed kind/bug Categorizes issue or PR as related to a bug. labels Nov 22, 2024
@longwuyuan
Copy link
Contributor

/kind support

@k8s-ci-robot k8s-ci-robot added kind/support Categorizes issue or PR as a support question. and removed needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Nov 22, 2024
@longwuyuan
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/support Categorizes issue or PR as a support question. needs-priority needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. triage/needs-information Indicates an issue needs more information in order to work on it.
Projects
Development

No branches or pull requests

3 participants