-
Notifications
You must be signed in to change notification settings - Fork 16
Add max connections configuration to GatewayClassConfig CRD #405
Changes from all commits
ccd85f5
a9e0b00
d960a0b
ec283d1
3101eb7
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:enhancement | ||
Add optional configuration for maximum upstream connections to GatewayClassConfig CRD. If unset, behavior is unchanged and Envoy's default will be used. | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,7 +102,8 @@ type GatewayID struct { | |
} | ||
|
||
type ResolvedGateway struct { | ||
ID GatewayID | ||
Meta map[string]string | ||
Listeners []ResolvedListener | ||
ID GatewayID | ||
Meta map[string]string | ||
Listeners []ResolvedListener | ||
MaxConnections *uint32 | ||
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 |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,13 @@ import ( | |
apigwv1alpha1 "github.com/hashicorp/consul-api-gateway/pkg/apis/v1alpha1" | ||
) | ||
|
||
const defaultListenerName = "default" | ||
const ( | ||
defaultListenerName = "default" | ||
|
||
gatewayMetaExternalSource = "external-source" | ||
gatewayMetaName = "consul-api-gateway/k8s/Gateway.Name" | ||
gatewayMetaNamespace = "consul-api-gateway/k8s/Gateway.Namespace" | ||
) | ||
|
||
var ( | ||
_ store.Gateway = (*K8sGateway)(nil) | ||
|
@@ -20,15 +26,15 @@ type K8sGateway struct { | |
*gwv1beta1.Gateway | ||
GatewayState *state.GatewayState | ||
|
||
config apigwv1alpha1.GatewayClassConfig | ||
Config apigwv1alpha1.GatewayClassConfig | ||
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. Exported this so that the JSON marshaler includes it when we serialize for writing to the store backend. If not exported, we don't have any idea what the max connections value is when rehydrating from the store and syncing into Consul, which we do at an interval in the background for resiliency. |
||
} | ||
|
||
// newK8sGateway | ||
func newK8sGateway(config apigwv1alpha1.GatewayClassConfig, gateway *gwv1beta1.Gateway, gatewayState *state.GatewayState) *K8sGateway { | ||
return &K8sGateway{ | ||
Gateway: gateway, | ||
GatewayState: gatewayState, | ||
config: config, | ||
Config: config, | ||
} | ||
} | ||
|
||
|
@@ -40,22 +46,30 @@ func (g *K8sGateway) ID() core.GatewayID { | |
} | ||
|
||
func (g *K8sGateway) Resolve() core.ResolvedGateway { | ||
listeners := []core.ResolvedListener{} | ||
var listeners []core.ResolvedListener | ||
for i, listener := range g.Gateway.Spec.Listeners { | ||
state := g.GatewayState.Listeners[i] | ||
if state.Valid() { | ||
listeners = append(listeners, g.resolveListener(state, listener)) | ||
} | ||
} | ||
return core.ResolvedGateway{ | ||
|
||
rgw := core.ResolvedGateway{ | ||
ID: g.ID(), | ||
Meta: map[string]string{ | ||
"external-source": "consul-api-gateway", | ||
"consul-api-gateway/k8s/Gateway.Name": g.Gateway.Name, | ||
"consul-api-gateway/k8s/Gateway.Namespace": g.Gateway.Namespace, | ||
gatewayMetaExternalSource: "consul-api-gateway", | ||
gatewayMetaName: g.Gateway.Name, | ||
gatewayMetaNamespace: g.Gateway.Namespace, | ||
}, | ||
Listeners: listeners, | ||
} | ||
|
||
if g.Config.Spec.ConnectionManagement.MaxConnections != nil { | ||
maxConns := uint32(*g.Config.Spec.ConnectionManagement.MaxConnections) | ||
rgw.MaxConnections = &maxConns | ||
} | ||
|
||
return rgw | ||
} | ||
|
||
func (g *K8sGateway) resolveListener(state *state.ListenerState, listener gwv1beta1.Listener) core.ResolvedListener { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
connectionManagement.maxConnections
is somewhat long; however, I opted not to abbreviate to something likeconnMgmt.maxConns
since we haven't abbreviated any other parts of the spec.