-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Labels
proposalAn issue that proposes a feature requestAn issue that proposes a feature request
Description
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
- Adjust the example in
examples/ingress-resources/complete-example
changing the field insideport
fromnumber: 80
toname: 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
- Apply this example with
kaf ./examples/ingress-resources/complete-example/
minikube tunnel
- Observer that you can
curl -k https://cafe.example.com/tea
andcurl -k https://cafe.example.com/coffee
- 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
kaf ./examples/ingress-resources/complete-example/
- 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.
btsuhako
Metadata
Metadata
Assignees
Labels
proposalAn issue that proposes a feature requestAn issue that proposes a feature request