-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add gRPC support #276
Add gRPC support #276
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see my comments
@@ -88,13 +94,23 @@ server { | |||
|
|||
proxy_connect_timeout {{$location.ProxyConnectTimeout}}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
grpc_connect_timeout, grpc_read_timeout
@@ -73,13 +77,15 @@ server { | |||
|
|||
{{range $location := $server.Locations}} | |||
location {{$location.Path}} { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps, it would look better we had separate locations for gRPC and non-gRPC, like below:
{{range $location := $server.Locations}}
{{ if $location.GRPC }}
location ...
{{ else }}
location ...
{{ end }}
{{range $location := $server.Locations}}
nginx-controller/nginx/nginx.go
Outdated
@@ -99,6 +100,7 @@ type Location struct { | |||
Websocket bool | |||
Rewrite string | |||
SSL bool | |||
Grpc bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grpc -> GRPC
{{- if $server.SSLRedirect}} | ||
if ($scheme = http) { | ||
return 301 https://$host:{{index $server.SSLPorts 0}}$request_uri; | ||
} | ||
{{- end}} | ||
{{end}} | ||
{{- if $server.HSTS}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HSTS not needed when gRPC only
func getGrpcServices(ingEx *IngressEx) map[string]bool { | ||
grpcServices := make(map[string]bool) | ||
|
||
if services, exists := ingEx.Ingress.Annotations["nginx.org/grpc-services"]; exists { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we have more than 0 gRPC services and HTTP/2 is not enabled, we must log an error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation comments
examples/grpc-services/README.md
Outdated
@@ -0,0 +1,39 @@ | |||
# Grpc support |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grpc -> gRPC
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see my comments
nginx-controller/Dockerfile
Outdated
@@ -1,4 +1,4 @@ | |||
FROM nginx:1.13.8 | |||
FROM nginx:1.13.10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please 1.13.12
nginx-controller/DockerfileForAlpine
Outdated
@@ -1,4 +1,4 @@ | |||
FROM nginx:1.13.8-alpine | |||
FROM nginx:1.13.10-alpine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1.13.12
for _, svc := range strings.Split(services, ",") { | ||
grpcServices[svc] = true | ||
} | ||
if len(grpcServices) > 0 && !ingCfg.HTTP2 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please move the condition and the log to generateNginxCfg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, but did you add a lot of whitespace in the template on purpose?
@@ -12,9 +12,11 @@ upstream {{$upstream.Name}} { | |||
|
|||
{{range $server := .Servers}} | |||
server { | |||
{{if not $server.GRPCOnly}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whitespace?
proxy_set_header X-Forwarded-Proto {{if $server.RedirectToHTTPS}}https{{else}}$scheme{{end}}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whitespace?
{{if $location.SSL}} | ||
proxy_pass https://{{$location.Upstream.Name}}{{$location.Rewrite}}; | ||
{{else}} | ||
proxy_pass http://{{$location.Upstream.Name}}{{$location.Rewrite}}; | ||
{{end}} | ||
|
||
{{end}} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whitespace?
fc48bc4
to
96910e5
Compare
Add gRPC support.