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

K8s Ingress spec: Headless services routing for StatefulSet pods #92639

Closed
ivanangelov opened this issue Jun 30, 2020 · 15 comments
Closed

K8s Ingress spec: Headless services routing for StatefulSet pods #92639

ivanangelov opened this issue Jun 30, 2020 · 15 comments
Assignees
Labels
kind/feature Categorizes issue or PR as related to a new feature. sig/network Categorizes an issue or PR as relevant to SIG Network.

Comments

@ivanangelov
Copy link

What would you like to be added:

K8s Ingress to be able to route external traffic to a specific pod of a StatefulSet which is exposed by a headless Service.

Example:

- host: <subdomain_1>.<ingress_host> 
  http:
    paths:
    - path: /
      backend:
        serviceName: <pod_name_1>.<headless_service_name>
        servicePort: <headless_service_port>

- host: <subdomain_2>.<ingress_host> 
  http:
    paths:
    - path: /
      backend:
        serviceName: <pod_name_2>.<headless_service_name>
        servicePort: <headless_service_port>

Why is this needed:

We are implementing a High availability setup for our K8s based solution. We are using a StatefulSet and would like to make use of the Horizontal Pod Autoscaler in order for our pods to be scaled on demand. We are using the NGINX Ingress Controller.

Furthermore, we have a logic that requires external traffic to be routed to a specific stateful pod based on the subdomain (or path) in the ingress host.

We observed that NGINX Ingress confirmed that if the above-described functionality is included in the K8s Ingress Spec they would implement it. kubernetes/ingress-nginx#3921

@ivanangelov ivanangelov added the kind/feature Categorizes issue or PR as related to a new feature. label Jun 30, 2020
@k8s-ci-robot k8s-ci-robot added the needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Jun 30, 2020
@ivanangelov
Copy link
Author

/sig network

@k8s-ci-robot k8s-ci-robot added sig/network Categorizes an issue or PR as relevant to SIG Network. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jun 30, 2020
@athenabot
Copy link

/triage unresolved

Comment /remove-triage unresolved when the issue is assessed and confirmed.

🤖 I am a bot run by vllry. 👩‍🔬

@k8s-ci-robot k8s-ci-robot added the triage/unresolved Indicates an issue that can not or will not be resolved. label Jun 30, 2020
@aojea
Copy link
Member

aojea commented Jun 30, 2020

@aledbf is not this something that is being done as part of https://github.com/kubernetes-sigs/service-apis ?

@PidgeyBE
Copy link

PidgeyBE commented Jul 1, 2020

If you are prepared to use voyager instead of nginx as ingress controller; they seem to support this already:
https://voyagermesh.com/docs/10.0.0/guides/ingress/http/statefulset-pod/#forward-traffic-to-specific-pods-of-a-statefulset

The same API would be very useful to have for standard kubernetes/nginx ingress API indeed!

@gaurimadhok
Copy link

/assign @robscott

@robscott
Copy link
Member

robscott commented Jul 9, 2020

Hey @ivanangelov, thanks for filing this issue! I think we may already have added something that would solve this in Kubernetes 1.19 with the option to target any resource, not just a Service, as a backend. I've got a docs PR that covers those updates and here's a preview of what those updates will look like.

@ivanangelov
Copy link
Author

ivanangelov commented Jul 13, 2020

Hello @robscott,

Thanks for the suggestion!
Actually, I need to target a backend resource of kind Pod on a specific port. Does this new feature support an explicit definition of the port of the backend resource? If so, would you provide an example?

@athenabot
Copy link

@robscott
If this issue has been triaged, please comment /remove-triage unresolved.

If you aren't able to handle this issue, consider unassigning yourself and/or adding the help-wanted label.

🤖 I am a bot run by vllry. 👩‍🔬

@ivanangelov
Copy link
Author

Hello @robscott,

I would kindly ask you to answer my previous question so we could have some clarity about how to proceed forward with the issue.

@robscott
Copy link
Member

robscott commented Aug 3, 2020

Thanks for the reminder, sorry I missed your follow up question! Although the API will support referencing arbitrary resources, it will depend on implementations to define which resources they want to support targeting. If you're planning on using a specific implementation, it might be good to ask the maintainers if they have plans to support targeting additional resource types in 1.19+. With that said, API config might look like this:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-resource-backend
spec:
  defaultBackend:
    resource:
      apiGroup: "v1"
      kind: Pod
      name: example
  rules:
    - http:
        paths:
          - path: /example
            pathType: Prefix
            backend:
              resource:
                apiGroup: "v1"
                kind: Pod
                name: example

/remove-triage unresolved

@k8s-ci-robot k8s-ci-robot removed the triage/unresolved Indicates an issue that can not or will not be resolved. label Aug 3, 2020
@ivanangelov
Copy link
Author

Hello @robscott,

Thanks for the example! However, what would happen if the pod example exposes multiple ports? Can we explicitly declare which port to use?
Would you direct me where I can ask the maintainers the same question?

@ivanangelov
Copy link
Author

Hello @robscott,

I would kindly ask you to answer my previous question so we could decide how to proceed forward with the issue.

@robscott
Copy link
Member

Hey @ivanangelov, that will depend on which Ingress controller you're using. At this point I'm not aware of any Ingress controllers that support targeting additional resource types yet. You could ask the maintainers of the controller if they have any plans for that. As an example, for ingress-nginx you might want to ask in the #ingress-nginx channel on Kubernetes Slack.

/close

@k8s-ci-robot
Copy link
Contributor

@robscott: Closing this issue.

In response to this:

Hey @ivanangelov, that will depend on which Ingress controller you're using. At this point I'm not aware of any Ingress controllers that support targeting additional resource types yet. You could ask the maintainers of the controller if they have any plans for that. As an example, for ingress-nginx you might want to ask in the #ingress-nginx channel on Kubernetes Slack.

/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/test-infra repository.

@ivanangelov
Copy link
Author

Hello @robscott, I would like to elaborate on the last two comments. Is it possible to include in the K8s Ingres API the option of targetting specific pod + port in the rules. Because it is common for applications running in pods to expose multiple ports. I think this would be a popular use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. sig/network Categorizes an issue or PR as relevant to SIG Network.
Projects
None yet
Development

No branches or pull requests

7 participants