-
Notifications
You must be signed in to change notification settings - Fork 100
support http2 protocol (#1523) #2306
Changes from 2 commits
f1e3179
160eab9
02b82ac
3e0e94f
7ca4aa3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
package service | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/acorn-io/baaah/pkg/router" | ||
v1 "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1" | ||
"github.com/acorn-io/runtime/pkg/ports" | ||
"github.com/acorn-io/runtime/pkg/publish" | ||
"github.com/acorn-io/runtime/pkg/services" | ||
) | ||
|
@@ -13,25 +16,49 @@ func RenderServices(req router.Request, resp router.Response) error { | |
// reset, should get repopulated | ||
svcInstance.Status.Endpoints = nil | ||
|
||
objs, _, err := services.ToK8sService(req, svcInstance) | ||
if err != nil { | ||
return err | ||
var svcList []*v1.ServiceInstance | ||
http2Ports := ports.ByProtocol(svcInstance.Spec.Ports, true, v1.ProtocolHTTP2) | ||
StrongMonkey marked this conversation as resolved.
Show resolved
Hide resolved
|
||
otherPorts := ports.ByProtocol(svcInstance.Spec.Ports, false, v1.ProtocolHTTP2) | ||
if len(http2Ports) > 0 { | ||
svcCopy := svcInstance.DeepCopy() | ||
svcCopy.Spec.Ports = http2Ports | ||
svcCopy.Name = fmt.Sprintf("%s-%s", svcInstance.Name, v1.ProtocolHTTP2) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am agreeing with @StrongMonkey here. Creating an additional Would it be possible to render the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Spoke offline about a slightly different approach that would alleviate the concerns above. |
||
if svcCopy.Spec.Annotations == nil { | ||
svcCopy.Spec.Annotations = map[string]string{} | ||
} | ||
svcCopy.Spec.Annotations["traefik.ingress.kubernetes.io/service.serversscheme"] = "h2c" | ||
svcList = append(svcList, svcCopy) | ||
StrongMonkey marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
resp.Objects(objs...) | ||
svcInstance.Status.HasService = len(objs) > 0 | ||
|
||
objs, err = publish.ServiceLoadBalancer(req, svcInstance) | ||
if err != nil { | ||
return err | ||
if len(otherPorts) > 0 { | ||
svcCopy := svcInstance.DeepCopy() | ||
svcCopy.Spec.Ports = otherPorts | ||
svcList = append(svcList, svcCopy) | ||
} | ||
resp.Objects(objs...) | ||
svcInstance.Status.HasService = svcInstance.Status.HasService || len(objs) > 0 | ||
|
||
objs, err = publish.Ingress(req, svcInstance) | ||
if err != nil { | ||
return err | ||
for _, svc := range svcList { | ||
objs, _, err := services.ToK8sService(req, svc) | ||
if err != nil { | ||
return err | ||
} | ||
resp.Objects(objs...) | ||
svcInstance.Status.HasService = svcInstance.Status.HasService || len(objs) > 0 | ||
|
||
objs, err = publish.ServiceLoadBalancer(req, svc) | ||
if err != nil { | ||
return err | ||
} | ||
resp.Objects(objs...) | ||
svcInstance.Status.HasService = svcInstance.Status.HasService || len(objs) > 0 | ||
|
||
objs, err = publish.Ingress(req, svc) | ||
if err != nil { | ||
return err | ||
} | ||
resp.Objects(objs...) | ||
|
||
// Copy all modifications made by the above publish.Ingress call | ||
svcInstance.Status.Endpoints = append(svcInstance.Status.Endpoints, svc.Status.Endpoints...) | ||
} | ||
resp.Objects(objs...) | ||
|
||
resp.Objects(svcInstance) | ||
return nil | ||
|
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.
nit: all of these cases can be put on the same line: