ingress-nginx: Support `grpc_read_timeout` and `grpc_send_timeout` in annotations

What do you want to happen?

We want to configure the grpc_read_timeout and grpc_send_timeout with annotations on ingress.

Since the server-snippet has some potential risk, we have to migrate all snippets to common annotations. https://github.com/search?q=repo%3Akubernetes%2Fingress-nginx+path%3A%2F^internal\%2Fingress\%2Fannotations\%2F%2F+parser.AnnotationRiskCritical&type=code

Is there currently another issue associated with this?

https://github.com/kubernetes/ingress-nginx/issues/2475, but it’s inactive and closed.

Does it require a particular kubernetes version?

No

Solutions

1. Add new annotations, e.g.

...
annotations:
  nginx.ingress.kubernetes.io/grpc_read_timeout: 3600
  nginx.ingress.kubernetes.io/grpc_send_timeout: 3600
...

2. Set grpc_read_timeout and grpc_send_timeout with the same value in proxy_read_timeout

Similar like nginx-ingress-controller, just set grpc with proxy settings by default

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 5
  • Comments: 17 (15 by maintainers)

Most upvoted comments

Hi @strongjz , maybe this should be noted as breaking change in release notes for 1.11 Because we are using:

      nginx.ingress.kubernetes.io/configuration-snippet: |
        grpc_next_upstream_tries X;
        grpc_read_timeout Xs;
        grpc_send_timeout Xs;

and after upgrade from 1.10 to 1.11 we ended up with these errors:

Error: exit status 1
2024/08/19 12:10:49 [emerg] 60#60: "grpc_read_timeout" directive is duplicate in /tmp/nginx/nginx-cfg658058193:2367
nginx: [emerg] "grpc_read_timeout" directive is duplicate in /tmp/nginx/nginx-cfg658058193:2367
nginx: configuration file /tmp/nginx/nginx-cfg658058193 test failed

In the /tmp/nginx/nginx-cfg658058193 there really are duplicated directives for grpc (default values from annotations and our values from configuration-snippet

			# Grpc settings
			grpc_connect_timeout                    5s;
			grpc_send_timeout                       60s;
			grpc_read_timeout                       60s;

			grpc_next_upstream error timeout http_502 http_503 http_504 non_idempotent;
			grpc_next_upstream_tries X;
			grpc_read_timeout Xs;
			grpc_send_timeout Xs;

We will switch from snippet to annotations to fix this, but I think it’s better to know about this from release notes.

Yeah, that’s another option how to deal with it (except “breaking change” note) I’m in the beggining of the upgrade process in our clusters and I will investigate how big problem is this for us. But it will deffinitely make the whole process harder

Possible merge mechanism - just don’t apply default values from annotations when GRPC is used?

ok, the solution 1 would be safer – add new annotations, it doesn’t break the existing “configurations”, you can add new annotations and remove snippets at the same time.

how do you think? @tao12345666333 @longwuyuan

I raised issue #11866

Thank you, I know why it happend. Question is how should I know it before the upgrade? No any mentions to “check all your snippets or everything would be down” in changelogs.