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

Add gRPC support #276

Merged
merged 1 commit into from
Apr 30, 2018
Merged

Add gRPC support #276

merged 1 commit into from
Apr 30, 2018

Conversation

Dean-Coakley
Copy link
Contributor

@Dean-Coakley Dean-Coakley commented Apr 27, 2018

Add gRPC support.

  • gRPC support
  • Updated docker files
  • Example
  • Documentation
  • Logging

Copy link
Contributor

@pleshakov pleshakov left a 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}};
Copy link
Contributor

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}} {
Copy link
Contributor

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}}

@@ -99,6 +100,7 @@ type Location struct {
Websocket bool
Rewrite string
SSL bool
Grpc bool
Copy link
Contributor

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}}
Copy link
Contributor

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 {
Copy link
Contributor

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

Copy link
Contributor

@pleshakov pleshakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation comments

@@ -0,0 +1,39 @@
# Grpc support
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grpc -> gRPC

Copy link
Contributor

@pleshakov pleshakov left a 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

@@ -1,4 +1,4 @@
FROM nginx:1.13.8
FROM nginx:1.13.10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please 1.13.12

@@ -1,4 +1,4 @@
FROM nginx:1.13.8-alpine
FROM nginx:1.13.10-alpine
Copy link
Contributor

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 {
Copy link
Contributor

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

Copy link
Contributor

@isaachawley isaachawley left a 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}}
Copy link
Contributor

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}};

Copy link
Contributor

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}}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whitespace?

@pleshakov pleshakov merged commit a4b2701 into nginxinc:master Apr 30, 2018
@Dean-Coakley Dean-Coakley deleted the grpc-support branch April 30, 2018 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants