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

Method Based Routing in Nginx Ingress #11363

Open
abhijitvikash opened this issue May 15, 2024 · 2 comments
Open

Method Based Routing in Nginx Ingress #11363

abhijitvikash opened this issue May 15, 2024 · 2 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature. needs-priority needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.

Comments

@abhijitvikash
Copy link

Hi Nginx, I want to implement method based routing(GET PUT OPTIONS) in Nginx Ingress. But seems like this is not supported either using :
nginx.ingress.kubernetes.io/configuration-snippet
nginx.ingress.kubernetes.io/server-snippet:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: testing-ingress-01
annotations:
nginx.ingress.kubernetes.io/server-snippet: |
lua_shared_dict targets 1m;
init_by_lua_block {
ngx.shared.targets:set("default", "httpd-service.default.svc.cluster.local");
}
rewrite_by_lua_block {
local method = ngx.req.get_method()
local backend = ngx.shared.targets:get("default")
if method == "PUT" then
backend = "httpd-service.default.svc.cluster.local" -- Change this if you want different service
elseif method == "GET" then
backend = "httpd-service.default.svc.cluster.local" -- Change this if you want different service
end
ngx.var.target_backend = backend
}
location / {
proxy_pass http://$target_backend;
}
spec:
ingressClassName: nginx
rules:

  • http:
    paths:
    • path: /
      pathType: ImplementationSpecific
      backend:
      service:
      name: httpd-service
      port:
      number: 80
@abhijitvikash abhijitvikash added the kind/bug Categorizes issue or PR as related to a bug. label May 15, 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 May 15, 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

/remove-kind bug
/kind feature

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. and removed kind/bug Categorizes issue or PR as related to a bug. labels May 15, 2024
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. 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