✨ feat: add grpc timeouts with proxy settings if backend is grpc
This commit is contained in:
parent
cfe0daace1
commit
2db47315ee
2 changed files with 55 additions and 3 deletions
|
@ -1481,6 +1481,13 @@ stream {
|
||||||
proxy_next_upstream_timeout {{ $location.Proxy.NextUpstreamTimeout }};
|
proxy_next_upstream_timeout {{ $location.Proxy.NextUpstreamTimeout }};
|
||||||
proxy_next_upstream_tries {{ $location.Proxy.NextUpstreamTries }};
|
proxy_next_upstream_tries {{ $location.Proxy.NextUpstreamTries }};
|
||||||
|
|
||||||
|
# Grpc settings
|
||||||
|
{{ if or (eq $location.BackendProtocol "GRPC") (eq $location.BackendProtocol "GRPCS")}}
|
||||||
|
grpc_connect_timeout {{ $location.Proxy.ConnectTimeout }}s;
|
||||||
|
grpc_send_timeout {{ $location.Proxy.SendTimeout }}s;
|
||||||
|
grpc_read_timeout {{ $location.Proxy.ReadTimeout }}s;
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
{{/* Add any additional configuration defined */}}
|
{{/* Add any additional configuration defined */}}
|
||||||
{{ $location.ConfigurationSnippet }}
|
{{ $location.ConfigurationSnippet }}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,10 @@ import (
|
||||||
"k8s.io/ingress-nginx/test/e2e/framework"
|
"k8s.io/ingress-nginx/test/e2e/framework"
|
||||||
)
|
)
|
||||||
|
|
||||||
const echoHost = "echo"
|
const (
|
||||||
|
echoHost = "echo"
|
||||||
|
host = "grpc"
|
||||||
|
)
|
||||||
|
|
||||||
var _ = framework.DescribeAnnotation("backend-protocol - GRPC", func() {
|
var _ = framework.DescribeAnnotation("backend-protocol - GRPC", func() {
|
||||||
f := framework.NewDefaultFramework("grpc", framework.WithHTTPBunEnabled())
|
f := framework.NewDefaultFramework("grpc", framework.WithHTTPBunEnabled())
|
||||||
|
@ -43,8 +46,6 @@ var _ = framework.DescribeAnnotation("backend-protocol - GRPC", func() {
|
||||||
ginkgo.It("should use grpc_pass in the configuration file", func() {
|
ginkgo.It("should use grpc_pass in the configuration file", func() {
|
||||||
f.NewGRPCFortuneTellerDeployment()
|
f.NewGRPCFortuneTellerDeployment()
|
||||||
|
|
||||||
host := "grpc"
|
|
||||||
|
|
||||||
annotations := map[string]string{
|
annotations := map[string]string{
|
||||||
"nginx.ingress.kubernetes.io/backend-protocol": "GRPC",
|
"nginx.ingress.kubernetes.io/backend-protocol": "GRPC",
|
||||||
}
|
}
|
||||||
|
@ -259,4 +260,48 @@ var _ = framework.DescribeAnnotation("backend-protocol - GRPC", func() {
|
||||||
metadata := res.GetMetadata()
|
metadata := res.GetMetadata()
|
||||||
assert.Equal(ginkgo.GinkgoT(), metadata["content-type"].Values[0], "application/grpc")
|
assert.Equal(ginkgo.GinkgoT(), metadata["content-type"].Values[0], "application/grpc")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ginkgo.It("should set valid grpc timeouts for grpc", func() {
|
||||||
|
proxyConnectTimeout := "5"
|
||||||
|
proxySendTimeout := "30"
|
||||||
|
proxyReadtimeout := "30"
|
||||||
|
|
||||||
|
annotations := make(map[string]string)
|
||||||
|
annotations["nginx.ingress.kubernetes.io/backend-protocol"] = "grpc"
|
||||||
|
annotations["nginx.ingress.kubernetes.io/proxy-connect-timeout"] = proxyConnectTimeout
|
||||||
|
annotations["nginx.ingress.kubernetes.io/proxy-send-timeout"] = proxySendTimeout
|
||||||
|
annotations["nginx.ingress.kubernetes.io/proxy-read-timeout"] = proxyReadtimeout
|
||||||
|
|
||||||
|
ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, annotations)
|
||||||
|
f.EnsureIngress(ing)
|
||||||
|
|
||||||
|
f.WaitForNginxServer(host,
|
||||||
|
func(server string) bool {
|
||||||
|
return strings.Contains(server, fmt.Sprintf("grpc_connect_timeout %ss;", proxyConnectTimeout)) &&
|
||||||
|
strings.Contains(server, fmt.Sprintf("grpc_send_timeout %ss;", proxySendTimeout)) &&
|
||||||
|
strings.Contains(server, fmt.Sprintf("grpc_read_timeout %ss;", proxyReadtimeout))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
ginkgo.It("should set valid grpc timeouts for grpcs", func() {
|
||||||
|
proxyConnectTimeout := "5"
|
||||||
|
proxySendTimeout := "30"
|
||||||
|
proxyReadtimeout := "30"
|
||||||
|
|
||||||
|
annotations := make(map[string]string)
|
||||||
|
annotations["nginx.ingress.kubernetes.io/backend-protocol"] = "grpcs"
|
||||||
|
annotations["nginx.ingress.kubernetes.io/proxy-connect-timeout"] = proxyConnectTimeout
|
||||||
|
annotations["nginx.ingress.kubernetes.io/proxy-send-timeout"] = proxySendTimeout
|
||||||
|
annotations["nginx.ingress.kubernetes.io/proxy-read-timeout"] = proxyReadtimeout
|
||||||
|
|
||||||
|
ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, annotations)
|
||||||
|
f.EnsureIngress(ing)
|
||||||
|
|
||||||
|
f.WaitForNginxServer(host,
|
||||||
|
func(server string) bool {
|
||||||
|
return strings.Contains(server, fmt.Sprintf("grpc_connect_timeout %ss;", proxyConnectTimeout)) &&
|
||||||
|
strings.Contains(server, fmt.Sprintf("grpc_send_timeout %ss;", proxySendTimeout)) &&
|
||||||
|
strings.Contains(server, fmt.Sprintf("grpc_read_timeout %ss;", proxyReadtimeout))
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue