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

NIC Fails to Resolve Named Ports with nginx.org/use-cluster-ip Annotation #4970

Closed
j1m-ryan opened this issue Jan 23, 2024 · 2 comments · Fixed by #5456
Closed

NIC Fails to Resolve Named Ports with nginx.org/use-cluster-ip Annotation #4970

j1m-ryan opened this issue Jan 23, 2024 · 2 comments · Fixed by #5456
Labels
proposal An issue that proposes a feature request

Comments

@j1m-ryan
Copy link
Member

Describe the bug

@btsuhako encountered a bug with the current implementation of the nginx.org/use-cluster-ip annotation. It does not currently account for named ports.

To Reproduce

  1. Adjust the example in examples/ingress-resources/complete-example changing the field inside port from number: 80 to name: http
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: cafe-ingress
spec:
  ingressClassName: nginx
  tls:
  - hosts:
    - cafe.example.com
    secretName: cafe-secret
  rules:
  - host: cafe.example.com
    http:
      paths:
      - path: /tea
        pathType: Prefix
        backend:
          service:
            name: tea-svc
            port:
              name: http 
      - path: /coffee
        pathType: Prefix
        backend:
          service:
            name: coffee-svc
            port:
              name: http
  1. Apply this example with kaf ./examples/ingress-resources/complete-example/
  2. minikube tunnel
  3. Observer that you can curl -k https://cafe.example.com/tea and curl -k https://cafe.example.com/coffee
  4. Now add the use-cluster-ip annotation as follows.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: cafe-ingress
  annotations:
    nginx.org/use-cluster-ip: "True"
spec:
  ingressClassName: nginx
  tls:
  - hosts:
    - cafe.example.com
    secretName: cafe-secret
  rules:
  - host: cafe.example.com
    http:
      paths:
      - path: /tea
        pathType: Prefix
        backend:
          service:
            name: tea-svc
            port:
              name: http 
      - path: /coffee
        pathType: Prefix
        backend:
          service:
            name: coffee-svc
            port:
              name: http
  1. kaf ./examples/ingress-resources/complete-example/
  2. Observe the following error in the config
I0123 17:23:46.869185       1 event.go:364] Event(v1.ObjectReference{Kind:"Ingress", Namespace:"default", Name:"cafe-ingress", UID:"ac9ee504-ef49-4e2c-8cac-458da477078f", APIVersion:"networking.k8s.io/v1", ResourceVersion:"2009", FieldPath:""}): type: 'Warning' reason: 'AddedOrUpdatedWithError' Configuration for default/cafe-ingress was added or updated ; but was not applied: error reloading NGINX for default/cafe-ingress: nginx reload failed: command /usr/sbin/nginx -s reload -e stderr stdout: ""
stderr: "2024/01/23 17:23:46 [emerg] 77#77: invalid port in upstream \"coffee-svc.default.svc.cluster.local:0\" in /etc/nginx/conf.d/default-cafe-ingress.conf:4\n"

Expected behavior
NIC handles the two mutually exclusive ways of defining a Port for the use-cluster-ip annotation. Number, or Name

Your environment

  • Version of the Ingress Controller: 3.4.2-snapshot
  • Version of Kubernetes: 1.28
  • Kubernetes platform (e.g. Mini-kube or GCP): minikube
  • Using NGINX or NGINX Plus: NGINX

Additional context
Add any other context about the problem here. Any log files you want to share.

@shaun-nx shaun-nx added bug An issue reporting a potential bug proposal An issue that proposes a feature request and removed bug An issue reporting a potential bug labels Feb 26, 2024
@btsuhako
Copy link

btsuhako commented Apr 9, 2024

any updates on this?

@j1m-ryan
Copy link
Member Author

Hi @btsuhako , apologies for the delay on this. I have a PR up for it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal An issue that proposes a feature request
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants