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

when the service port changes, the ingress cannot detect the change and adjust the upstream port. #12209

Closed
zzzzoy opened this issue Oct 18, 2024 · 3 comments
Labels
needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-priority needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.

Comments

@zzzzoy
Copy link

zzzzoy commented Oct 18, 2024

What happened:

To illustrate this problem in a simple example,

  1. I created an nginx service, and used the wrong targetPort port:

deploy.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
name: tony
namespace: test
spec:
replicas: 1
selector:
matchLabels:
app: tony
version: v1
template:
metadata:
labels:
app: tony
version: v1
spec:
containers:
- image: nginx:latest
imagePullPolicy: IfNotPresent
name: container-0
imagePullSecrets:
- name: default-secret
restartPolicy: Always
schedulerName: default-scheduler

service.yaml:

apiVersion: v1
kind: Service
metadata:
labels:
app: tony
name: tony
namespace: test
spec:
internalTrafficPolicy: Cluster
ports:

  • name: cce-service-0
    port: 80
    protocol: TCP
    targetPort: 81
    selector:
    app: tony
    type: ClusterIP
  1. create ingress for this service, now we can try to access www.test.com but ingress will response 502 Bad Gateway

ingress.yaml:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: test
namespace: test
spec:
rules:

  • host: www.test.com
    http:
    paths:
    • backend:
      service:
      name: tony
      port:
      number: 80
      path: /
      pathType: ImplementationSpecific
  1. modify the targetPort of service and apply

service.yaml:

apiVersion: v1
kind: Service
metadata:
labels:
app: tony
name: tony
namespace: test
spec:
internalTrafficPolicy: Cluster
ports:

  • name: cce-service-0
    port: 80
    protocol: TCP
    targetPort: 81
    selector:
    app: tony
    type: ClusterIP
  1. try to access www.test.com but still get response 502 Bad Gateway, i have to rebuild ingress by kubectl delete -f ingress.yaml && kubectl apply -f ingress.yaml and get correct response message

What you expected to happen:

when I modify a service, the ingress should reload the service to ensure the correctness of the forwarding result.
i wonder, is this a normal situation? or ingress cannot be supported this feature for some reason

maybe the ingress cannot identify service changes

NGINX Ingress controller version (exec into the pod and run nginx-ingress-controller --version.):

Kubernetes version (use kubectl version):

Environment:

  • Cloud provider or hardware configuration:

  • OS (e.g. from /etc/os-release): Centos 7.6

  • Kernel (e.g. uname -a):

  • Linux 192-168-0-174 3.10.0-862.14.4.el7.x86_64 Basic structure  #1 SMP Wed Sep 26 15:12:11 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

  • Install tools:
    kubeadm

  • Basic cluster related info:

    • kubectl version
    • v1.23.15
    • kubectl get nodes -o wide
    • NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
      192.168.0.121 Ready 3d21h v1.23.15 192.168.0.121 CentOS Linux 7 (Core) 3.10.0-862.14.4.el7.x86_64 docker://18.9.0
      192.168.0.174 Ready etcd,master 4d1h v1.23.15 192.168.0.174 CentOS Linux 7 (Core) 3.10.0-862.14.4.el7.x86_64 docker://18.9.0
      192.168.0.185 Ready etcd,master 4d1h v1.23.15 192.168.0.185 CentOS Linux 7 (Core) 3.10.0-957.el7.x86_64 docker://18.9.0
      192.168.0.57 Ready etcd,master 4d1h v1.23.15 192.168.0.57 CentOS Linux 7 (Core) 3.10.0-957.el7.x86_64 docker://18.9.0
  • How was the ingress-nginx-controller installed: helm

  • Current State of the controller: running

@zzzzoy zzzzoy added the kind/bug Categorizes issue or PR as related to a bug. label Oct 18, 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 Oct 18, 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.

@zzzzoy zzzzoy changed the title when the service port changes, the ingress cannot detect the change and adjust the forwarding port. when the service port changes, the ingress cannot detect the change and adjust the upstream port. Oct 18, 2024
@longwuyuan
Copy link
Contributor

  • The information you have provided is very very vague as it can not be used for reproducing a problem in a way that helps
  • You can help the readers by first looking at the template of a new bug report and answer the questions that are asked in the template, here, by editing the issue description of this issue
  • You can also help by ensuring markdown format because right now its harder to read the data
  • Looks like you changes some specs and want to see response change but its not even clear if you get a response from a cache like a browser cache
  • After you have provided the info as suggested above, please try to help the readers here by providing precise instructions that someone can copy/paste from , to reproduce the problem you are having. Do not make it vague like refreshing a browser

Once the information in the issue description is helpful to readers here, then you can re-open this issue. I will close it for now as there is no action item here.

/remove-kind bug
/close

@k8s-ci-robot k8s-ci-robot added 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 Oct 18, 2024
@k8s-ci-robot
Copy link
Contributor

@longwuyuan: Closing this issue.

In response to this:

  • The information you have provided is very very vague as it can not be used for reproducing a problem in a way that helps
  • You can help the readers by first looking at the template of a new bug report and answer the questions that are asked in the template, here, by editing the issue description of this issue
  • You can also help by ensuring markdown format because right now its harder to read the data
  • Looks like you changes some specs and want to see response change but its not even clear if you get a response from a cache like a browser cache
  • After you have provided the info as suggested above, please try to help the readers here by providing precise instructions that someone can copy/paste from , to reproduce the problem you are having. Do not make it vague like refreshing a browser

Once the information in the issue description is helpful to readers here, then you can re-open this issue. I will close it for now as there is no action item here.

/remove-kind bug
/close

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.

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

No branches or pull requests

3 participants