Skip to content

Commit

Permalink
feat: add more options to configure FGW (#89)
Browse files Browse the repository at this point in the history
* feat: add more options to configure FGW

Signed-off-by: Lin Yang <[email protected]>

* fix: make chart-readme

Signed-off-by: Lin Yang <[email protected]>

---------

Signed-off-by: Lin Yang <[email protected]>
  • Loading branch information
reaver-flomesh committed Oct 28, 2023
1 parent 0e4331a commit 4c05d89
Show file tree
Hide file tree
Showing 13 changed files with 263 additions and 10 deletions.
5 changes: 5 additions & 0 deletions charts/fsm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,12 @@ The following table lists the configurable parameters of the fsm chart and their
| fsm.fsmController.resource | object | `{"limits":{"cpu":"1.5","memory":"1G"},"requests":{"cpu":"0.5","memory":"128M"}}` | FSM controller's container resource parameters. See https://docs.flomesh.io/docs/guides/ha_scale/scale/ for more details. |
| fsm.fsmController.tolerations | list | `[]` | Node tolerations applied to control plane pods. The specified tolerations allow pods to schedule onto nodes with matching taints. |
| fsm.fsmGateway.enabled | bool | `false` | |
| fsm.fsmGateway.fgwLogLevel | string | `"info"` | |
| fsm.fsmGateway.http1PerRequestLoadBalancing | bool | `false` | |
| fsm.fsmGateway.http2PerRequestLoadBalancing | bool | `true` | |
| fsm.fsmGateway.logLevel | string | `"info"` | |
| fsm.fsmGateway.sslPassthroughUpstreamPort | int | `443` | |
| fsm.fsmGateway.stripAnyHostPort | bool | `true` | |
| fsm.fsmIngress.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[0].key | string | `"kubernetes.io/os"` | |
| fsm.fsmIngress.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[0].operator | string | `"In"` | |
| fsm.fsmIngress.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[0].values[0] | string | `"linux"` | |
Expand Down
7 changes: 6 additions & 1 deletion charts/fsm/templates/preset-mesh-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,12 @@ data:
},
"gatewayAPI": {
"enabled": {{ and .Values.fsm.fsmGateway.enabled (not .Values.fsm.fsmIngress.enabled) }},
"logLevel": "{{ .Values.fsm.fsmGateway.logLevel }}"
"logLevel": "{{ .Values.fsm.fsmGateway.logLevel }}",
"fgwLogLevel": "{{ .Values.fsm.fsmGateway.fgwLogLevel }}",
"stripAnyHostPort": {{ .Values.fsm.fsmGateway.stripAnyHostPort }},
"sslPassthroughUpstreamPort": {{ .Values.fsm.fsmGateway.sslPassthroughUpstreamPort }},
"http1PerRequestLoadBalancing": {{ .Values.fsm.fsmGateway.http1PerRequestLoadBalancing }},
"http2PerRequestLoadBalancing": {{ .Values.fsm.fsmGateway.http2PerRequestLoadBalancing }}
},
"serviceLB": {
"enabled": {{ .Values.fsm.serviceLB.enabled }},
Expand Down
32 changes: 31 additions & 1 deletion charts/fsm/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1830,7 +1830,12 @@
"title": "The gatewayApi Schema",
"required": [
"enabled",
"logLevel"
"logLevel",
"fgwLogLevel",
"stripAnyHostPort",
"sslPassthroughUpstreamPort",
"http1PerRequestLoadBalancing",
"http2PerRequestLoadBalancing"
],
"properties": {
"enabled": {
Expand All @@ -1842,6 +1847,31 @@
"type": "string",
"default": "info",
"title": "The logLevel Schema"
},
"fgwLogLevel": {
"type": "string",
"default": "info",
"title": "The FGW logLevel Schema"
},
"stripAnyHostPort": {
"type": "boolean",
"default": true,
"title": "The stripAnyHostPort Schema"
},
"sslPassthroughUpstreamPort": {
"type": "integer",
"default": 443,
"title": "The sslPassthroughUpstreamPort Schema"
},
"http1PerRequestLoadBalancing": {
"type": "boolean",
"default": false,
"title": "The http1PerRequestLoadBalancing Schema"
},
"http2PerRequestLoadBalancing": {
"type": "boolean",
"default": true,
"title": "The http2PerRequestLoadBalancing Schema"
}
}
},
Expand Down
5 changes: 5 additions & 0 deletions charts/fsm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,11 @@ fsm:
fsmGateway:
enabled: false
logLevel: info
fgwLogLevel: info
stripAnyHostPort: true
sslPassthroughUpstreamPort: 443
http1PerRequestLoadBalancing: false
http2PerRequestLoadBalancing: true

#
# -- FSM ServiceLB parameters
Expand Down
39 changes: 39 additions & 0 deletions cmd/fsm-bootstrap/crds/config.flomesh.io_meshconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1440,10 +1440,38 @@ spec:
gatewayAPI:
description: GatewayAPI defines the configurations of GatewayAPI features.
properties:
StripAnyHostPort:
default: false
description: StripAnyHostPort defines if strip any host port is
enabled.
type: boolean
enabled:
default: false
description: Enabled defines if gateway api is enabled.
type: boolean
fgwLogLevel:
default: info
description: FGWLogLevel defines the log level of FGW.
enum:
- trace
- debug
- info
- warn
- error
- fatal
- panic
- disabled
type: string
http1PerRequestLoadBalancing:
default: false
description: HTTP1PerRequestLoadBalancing defines if load balancing
based on per-request is enabled for http1.
type: boolean
http2PerRequestLoadBalancing:
default: false
description: HTTP2PerRequestLoadBalancing defines if load balancing
based on per-request is enabled for http2.
type: boolean
logLevel:
default: info
description: LogLevel defines the log level of gateway api.
Expand All @@ -1457,9 +1485,20 @@ spec:
- panic
- disabled
type: string
sslPassthroughUpstreamPort:
default: 443
description: SSLPassthroughUpstreamPort defines the default upstream
port of SSL passthrough.
format: int32
type: integer
required:
- StripAnyHostPort
- enabled
- fgwLogLevel
- http1PerRequestLoadBalancing
- http2PerRequestLoadBalancing
- logLevel
- sslPassthroughUpstreamPort
type: object
image:
description: Image defines the configurations of Image info
Expand Down
21 changes: 21 additions & 0 deletions pkg/apis/config/v1alpha3/mesh_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,27 @@ type GatewayAPISpec struct {
// +kubebuilder:validation:Enum=trace;debug;info;warn;error;fatal;panic;disabled
// LogLevel defines the log level of gateway api.
LogLevel string `json:"logLevel"`

// +kubebuilder:default=info
// +kubebuilder:validation:Enum=trace;debug;info;warn;error;fatal;panic;disabled
// FGWLogLevel defines the log level of FGW.
FGWLogLevel string `json:"fgwLogLevel"`

// +kubebuilder:default=false
// StripAnyHostPort defines if strip any host port is enabled.
StripAnyHostPort bool `json:"StripAnyHostPort"`

// +kubebuilder:default=443
// SSLPassthroughUpstreamPort defines the default upstream port of SSL passthrough.
SSLPassthroughUpstreamPort int32 `json:"sslPassthroughUpstreamPort"`

// +kubebuilder:default=false
// HTTP1PerRequestLoadBalancing defines if load balancing based on per-request is enabled for http1.
HTTP1PerRequestLoadBalancing bool `json:"http1PerRequestLoadBalancing"`

// +kubebuilder:default=false
// HTTP2PerRequestLoadBalancing defines if load balancing based on per-request is enabled for http2.
HTTP2PerRequestLoadBalancing bool `json:"http2PerRequestLoadBalancing"`
}

// ServiceLBSpec is the type to represent service lb.
Expand Down
30 changes: 30 additions & 0 deletions pkg/configurator/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,36 @@ func (c *Client) GetFSMGatewayLogLevel() string {
return mcSpec.GatewayAPI.LogLevel
}

// GetFGWLogLevel returns log level of FGW
func (c *Client) GetFGWLogLevel() string {
mcSpec := c.getMeshConfig().Spec
return mcSpec.GatewayAPI.FGWLogLevel
}

// IsFGWStripAnyHostPort returns whether to strip any host port
func (c *Client) IsFGWStripAnyHostPort() bool {
mcSpec := c.getMeshConfig().Spec
return mcSpec.GatewayAPI.StripAnyHostPort
}

// GetFGWSSLPassthroughUpstreamPort returns the default upstream port that FGW used for SSL Passthrough
func (c *Client) GetFGWSSLPassthroughUpstreamPort() int32 {
mcSpec := c.getMeshConfig().Spec
return mcSpec.GatewayAPI.SSLPassthroughUpstreamPort
}

// IsFGWHTTP1PerRequestLoadBalancingEnabled returns whether per-request load balancing is enabled for HTTP1 protocol
func (c *Client) IsFGWHTTP1PerRequestLoadBalancingEnabled() bool {
mcSpec := c.getMeshConfig().Spec
return mcSpec.GatewayAPI.HTTP1PerRequestLoadBalancing
}

// IsFGWHTTP2PerRequestLoadBalancingEnabled returns whether per-request load balancing is enabled for HTTP2 protocol
func (c *Client) IsFGWHTTP2PerRequestLoadBalancingEnabled() bool {
mcSpec := c.getMeshConfig().Spec
return mcSpec.GatewayAPI.HTTP2PerRequestLoadBalancing
}

// IsIngressEnabled returns whether Ingress is enabled
func (c *Client) IsIngressEnabled() bool {
mcSpec := c.getMeshConfig().Spec
Expand Down
70 changes: 70 additions & 0 deletions pkg/configurator/mock_client_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions pkg/configurator/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,21 @@ type Configurator interface {
// GetFSMGatewayLogLevel returns log level of FSM Gateway
GetFSMGatewayLogLevel() string

// GetFGWLogLevel returns log level of FSM Gateway
GetFGWLogLevel() string

// IsFGWStripAnyHostPort returns whether to strip any host port
IsFGWStripAnyHostPort() bool

// GetFGWSSLPassthroughUpstreamPort returns the default upstream port that FGW used for SSL Passthrough
GetFGWSSLPassthroughUpstreamPort() int32

// IsFGWHTTP1PerRequestLoadBalancingEnabled returns whether per-request load balancing is enabled for HTTP1 protocol
IsFGWHTTP1PerRequestLoadBalancingEnabled() bool

// IsFGWHTTP2PerRequestLoadBalancingEnabled returns whether per-request load balancing is enabled for HTTP2 protocol
IsFGWHTTP2PerRequestLoadBalancingEnabled() bool

// IsIngressEnabled returns whether Ingress is enabled
IsIngressEnabled() bool

Expand Down
8 changes: 5 additions & 3 deletions pkg/gateway/cache/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,15 @@ func (c *GatewayCache) getVersionOfConfigJSON(basepath string) (string, error) {
func (c *GatewayCache) defaults() routecfg.Defaults {
return routecfg.Defaults{
EnableDebug: c.isDebugEnabled(),
DefaultPassthroughUpstreamPort: 443, // TODO: enrich this from config
StripAnyHostPort: true, // TODO: enrich this from config
DefaultPassthroughUpstreamPort: c.cfg.GetFGWSSLPassthroughUpstreamPort(),
StripAnyHostPort: c.cfg.IsFGWStripAnyHostPort(),
HTTP1PerRequestLoadBalancing: c.cfg.IsFGWHTTP1PerRequestLoadBalancingEnabled(),
HTTP2PerRequestLoadBalancing: c.cfg.IsFGWHTTP2PerRequestLoadBalancingEnabled(),
}
}

func (c *GatewayCache) isDebugEnabled() bool {
switch c.cfg.GetFSMGatewayLogLevel() {
switch c.cfg.GetFGWLogLevel() {
case "debug", "trace":
return true
default:
Expand Down
8 changes: 5 additions & 3 deletions pkg/gateway/routecfg/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ type ConfigSpec struct {

// Defaults is the default configuration
type Defaults struct {
EnableDebug bool `json:"EnableDebug"`
DefaultPassthroughUpstreamPort uint32 `json:"DefaultPassthroughUpstreamPort"`
StripAnyHostPort bool `json:"StripAnyHostPort"`
EnableDebug bool `json:"EnableDebug"`
DefaultPassthroughUpstreamPort int32 `json:"DefaultPassthroughUpstreamPort"`
StripAnyHostPort bool `json:"StripAnyHostPort"`
HTTP1PerRequestLoadBalancing bool `json:"HTTP1PerRequestLoadBalancing"`
HTTP2PerRequestLoadBalancing bool `json:"HTTP2PerRequestLoadBalancing"`
}

// Listener is the listener configuration
Expand Down
25 changes: 25 additions & 0 deletions pkg/manager/listeners/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,31 @@ type client struct {
mc *configv1alpha3.MeshConfig
}

func (c *client) GetFGWLogLevel() string {
//TODO implement me
panic("implement me")
}

func (c *client) IsFGWStripAnyHostPort() bool {
//TODO implement me
panic("implement me")
}

func (c *client) GetFGWSSLPassthroughUpstreamPort() int32 {
//TODO implement me
panic("implement me")
}

func (c *client) IsFGWHTTP1PerRequestLoadBalancingEnabled() bool {
//TODO implement me
panic("implement me")
}

func (c *client) IsFGWHTTP2PerRequestLoadBalancingEnabled() bool {
//TODO implement me
panic("implement me")
}

func (c *client) GetRemoteLoggingLevel() uint16 {
//TODO implement me
panic("implement me")
Expand Down
8 changes: 6 additions & 2 deletions pkg/messaging/broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -823,8 +823,12 @@ func gatewayInterestedConfigChanged(msg events.PubSubMessage) *gatewayUpdateEven
prevSpec := prevMeshConfig.Spec
newSpec := newMeshConfig.Spec

if prevSpec.GatewayAPI.LogLevel != newSpec.GatewayAPI.LogLevel ||
prevSpec.FeatureFlags.EnableGatewayAgentService != newSpec.FeatureFlags.EnableGatewayAgentService {
if prevSpec.GatewayAPI.FGWLogLevel != newSpec.GatewayAPI.FGWLogLevel ||
prevSpec.FeatureFlags.EnableGatewayAgentService != newSpec.FeatureFlags.EnableGatewayAgentService ||
prevSpec.GatewayAPI.StripAnyHostPort != newSpec.GatewayAPI.StripAnyHostPort ||
prevSpec.GatewayAPI.SSLPassthroughUpstreamPort != newSpec.GatewayAPI.SSLPassthroughUpstreamPort ||
prevSpec.GatewayAPI.HTTP1PerRequestLoadBalancing != newSpec.GatewayAPI.HTTP1PerRequestLoadBalancing ||
prevSpec.GatewayAPI.HTTP2PerRequestLoadBalancing != newSpec.GatewayAPI.HTTP2PerRequestLoadBalancing {
return &gatewayUpdateEvent{
msg: msg,
topic: announcements.GatewayUpdate.String(),
Expand Down

0 comments on commit 4c05d89

Please sign in to comment.