Skip to content

Commit

Permalink
feat: slow starting warm-up feature (#622)
Browse files Browse the repository at this point in the history
add slow starting warm-up feature

Signed-off-by: Cybwan <[email protected]>
Signed-off-by: Lin Yang <[email protected]>
  • Loading branch information
cybwan authored Jan 7, 2025
1 parent db70296 commit 2a59b50
Show file tree
Hide file tree
Showing 35 changed files with 1,088 additions and 35 deletions.
4 changes: 4 additions & 0 deletions charts/fsm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ The following table lists the configurable parameters of the fsm chart and their
| fsm.featureFlags.enableSidecarActiveHealthChecks | bool | `false` | Enable Sidecar active health checks |
| fsm.featureFlags.enableSidecarPrettyConfig | bool | `true` | Enable Sidecar Pretty Config |
| fsm.featureFlags.enableSnapshotCacheMode | bool | `false` | Enables SnapshotCache feature for Sidecar xDS server. |
| fsm.featureFlags.enableTrafficWarmupPolicy | bool | `false` | Enables traffic warmup feature |
| fsm.featureFlags.enableValidateGRPCRouteHostnames | bool | `true` | Enable validate GRPC route hostnames, enforce the hostname is DNS name not IP address |
| fsm.featureFlags.enableValidateGatewayListenerHostname | bool | `true` | Enable validate Gateway listener hostname, enforce the hostname is DNS name not IP address |
| fsm.featureFlags.enableValidateHTTPRouteHostnames | bool | `true` | Enable validate HTTP route hostnames, enforce the hostname is DNS name not IP address |
Expand Down Expand Up @@ -487,6 +488,9 @@ The following table lists the configurable parameters of the fsm chart and their
| fsm.vault.secret.key | string | `""` | The Kubernetes secret key with the value bring the Vault token |
| fsm.vault.secret.name | string | `""` | The Kubernetes secret name storing the Vault token used in FSM |
| fsm.vault.token | string | `""` | token that should be used to connect to Vault |
| fsm.warmup | object | `{"duration":"90s","enable":false,"maxWeight":100,"minWeight":10}` | Global Traffic Warmup policy |
| fsm.warmup.maxWeight | int | `100` | MaxWeight configures the maximum percentage of origin weight -- If unspecified, defaults to 100 |
| fsm.warmup.minWeight | int | `10` | MinWeight configures the minimum percentage of origin weight -- If unspecified, defaults to 10 |
| fsm.webhookConfigNamePrefix | string | `"fsm-webhook"` | Prefix used in name of the webhook configuration resources |
| smi.validateTrafficTarget | bool | `true` | Enables validation of SMI Traffic Target |

Expand Down
4 changes: 2 additions & 2 deletions charts/fsm/templates/fsm-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ rules:

# FSM's custom policy API
- apiGroups: ["policy.flomesh.io"]
resources: ["egresses", "egressgateways", "ingressbackends", "accesscontrols", "accesscerts", "isolations", "retries", "upstreamtrafficsettings"]
resources: ["egresses", "egressgateways", "ingressbackends", "accesscontrols", "accesscerts", "isolations", "retries", "upstreamtrafficsettings", "trafficwarmups"]
verbs: ["list", "get", "watch"]
- apiGroups: ["policy.flomesh.io"]
resources: ["ingressbackends/status", "accesscontrols/status", "accesscerts/status", "upstreamtrafficsettings/status"]
resources: ["ingressbackends/status", "accesscontrols/status", "accesscerts/status", "upstreamtrafficsettings/status", "trafficwarmup/status"]
verbs: ["update"]

# FSM's MultiCluster resource API
Expand Down
7 changes: 7 additions & 0 deletions charts/fsm/templates/preset-mesh-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ data:
"outboundIPRangeInclusionList": {{.Values.fsm.outboundIPRangeInclusionList | mustToJson}},
"networkInterfaceExclusionList": {{.Values.fsm.networkInterfaceExclusionList | mustToJson}}
},
"warmup": {
"enable": {{.Values.fsm.warmup.enable | mustToJson}},
"duration": {{.Values.fsm.warmup.duration | mustToJson}},
"minWeight": {{.Values.fsm.warmup.minWeight | mustToJson}},
"maxWeight": {{.Values.fsm.warmup.maxWeight | mustToJson}}
},
"observability": {
"fsmLogLevel": {{.Values.fsm.controllerLogLevel | mustToJson}},
"tracing": {
Expand Down Expand Up @@ -86,6 +92,7 @@ data:
"enableIngressBackendPolicy": {{.Values.fsm.featureFlags.enableIngressBackendPolicy | mustToJson}},
"enableAccessControlPolicy": {{.Values.fsm.featureFlags.enableAccessControlPolicy | mustToJson}},
"enableAccessCertPolicy": {{.Values.fsm.featureFlags.enableAccessCertPolicy | mustToJson}},
"enableTrafficWarmupPolicy": {{.Values.fsm.featureFlags.enableTrafficWarmupPolicy | mustToJson}},
"enableSidecarPrettyConfig": {{.Values.fsm.featureFlags.enableSidecarPrettyConfig | mustToJson}},
"enableSidecarActiveHealthChecks": {{.Values.fsm.featureFlags.enableSidecarActiveHealthChecks | mustToJson}},
"enableRetryPolicy": {{.Values.fsm.featureFlags.enableRetryPolicy | mustToJson}},
Expand Down
51 changes: 51 additions & 0 deletions charts/fsm/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,47 @@
}
}
},
"warmup": {
"$id": "#/properties/fsm/properties/warmup",
"type": "object",
"title": "The traffic warmup schema",
"required": [
"enable",
"duration",
"minWeight",
"maxWeight"
],
"properties": {
"enable": {
"$id": "#/properties/fsm/properties/warmup/properties/enable",
"type": "boolean",
"title": "The enable schema for traffic warmup",
"examples": [
true
]
},
"duration": {
"$id": "#/properties/fsm/properties/warmup/properties/duration",
"type": "string",
"title": "The duration schema",
"description": "The traffic warmup duration.",
"examples": [
"90s"
]
},
"minWeight": {
"$id": "#/properties/fsm/properties/warmup/properties/minWeight",
"type": "integer",
"title": "minWeight configures the minimum percentage"
},
"maxWeight": {
"$id": "#/properties/fsm/properties/warmup/properties/maxWeight",
"type": "integer",
"title": "maxWeight configures the maximum percentage"
}
},
"additionalProperties": false
},
"trustDomain": {
"$id": "#/properties/fsm/properties/trustDomain",
"type": "string",
Expand Down Expand Up @@ -2417,6 +2458,7 @@
"enableIngressBackendPolicy",
"enableAccessControlPolicy",
"enableAccessCertPolicy",
"enableTrafficWarmupPolicy",
"enableSidecarPrettyConfig",
"enableSidecarActiveHealthChecks",
"enableSnapshotCacheMode",
Expand Down Expand Up @@ -2477,6 +2519,15 @@
true
]
},
"enableTrafficWarmupPolicy": {
"$id": "#/properties/fsm/properties/featureFlags/properties/enableTrafficWarmupPolicy",
"type": "boolean",
"title": "Enable traffic warmup feature",
"description": "Enable traffic warmup feature",
"examples": [
true
]
},
"enableSidecarPrettyConfig": {
"$id": "#/properties/fsm/properties/featureFlags/properties/enableSidecarPrettyConfig",
"type": "boolean",
Expand Down
13 changes: 13 additions & 0 deletions charts/fsm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,17 @@ fsm:
# -- codebase is the folder used by fsmController.
codebase: ""

# -- Global Traffic Warmup policy
warmup:
enable: false
duration: 90s
# -- MinWeight configures the minimum percentage of origin weight
# -- If unspecified, defaults to 10
minWeight: 10
# -- MaxWeight configures the maximum percentage of origin weight
# -- If unspecified, defaults to 100
maxWeight: 100

pluginChains:
inbound-tcp:
- plugin: modules/inbound-tls-termination
Expand Down Expand Up @@ -780,6 +791,8 @@ fsm:
enableAccessControlPolicy: true
# When enabled, FSM can issue certificates for external services.
enableAccessCertPolicy: false
# -- Enables traffic warmup feature
enableTrafficWarmupPolicy: false
# -- Enable Sidecar Pretty Config
enableSidecarPrettyConfig: true
# -- Enable Sidecar active health checks
Expand Down
42 changes: 42 additions & 0 deletions cmd/fsm-bootstrap/crds/config.flomesh.io_meshconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1473,6 +1473,10 @@ spec:
description: EnableSnapshotCacheMode defines if XDS server starts
with snapshot cache.
type: boolean
enableTrafficWarmupPolicy:
description: EnableTrafficWarmupPolicy defines if FSM will use
the TrafficWarmup API to allow traffic warmup
type: boolean
enableValidateGRPCRouteHostnames:
description: EnableValidateGRPCRouteHostnames defines if validate
grpc route hostnames is enabled.
Expand Down Expand Up @@ -1506,6 +1510,7 @@ spec:
- enableSidecarActiveHealthChecks
- enableSidecarPrettyConfig
- enableSnapshotCacheMode
- enableTrafficWarmupPolicy
- enableValidateGRPCRouteHostnames
- enableValidateGatewayListenerHostname
- enableValidateHTTPRouteHostnames
Expand Down Expand Up @@ -2451,6 +2456,43 @@ spec:
- outboundPortExclusionList
- serviceAccessMode
type: object
warmup:
description: Warmup defines the traffic warm up policy
properties:
aggression:
default: 1
description: |-
Aggression controls the speed of traffic increase over the warmup duration. Defaults to 1.0, so that endpoints would
get linearly increasing amount of traffic. When increasing the value for this parameter,
the speed of traffic ramp-up increases non-linearly.
minimum: 1
type: number
duration:
default: 90s
format: duration
type: string
enable:
default: true
type: boolean
maxWeight:
default: 100
description: |-
MaxWeight configures the maximum percentage of origin weight
If unspecified, defaults to 100
format: int64
maximum: 100
minimum: 0
type: integer
minWeight:
default: 10
description: |-
MinWeight configures the minimum percentage of origin weight
If unspecified, defaults to 10
format: int64
maximum: 100
minimum: 0
type: integer
type: object
required:
- connector
- image
Expand Down
97 changes: 97 additions & 0 deletions cmd/fsm-bootstrap/crds/policy.flomesh.io_trafficwarmups.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.16.5
labels:
app.kubernetes.io/name: flomesh.io
name: trafficwarmups.policy.flomesh.io
spec:
group: policy.flomesh.io
names:
kind: TrafficWarmup
listKind: TrafficWarmupList
plural: trafficwarmups
shortNames:
- trafficwarmup
singular: trafficwarmup
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: TrafficWarmup is the type used to represent a traffic warmup
policy.
properties:
apiVersion:
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
type: string
kind:
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
metadata:
type: object
spec:
description: |-
Specification of the desired behavior of the traffic raffic warmup.
More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status
properties:
aggression:
default: 1
description: |-
Aggression controls the speed of traffic increase over the warmup duration. Defaults to 1.0, so that endpoints would
get linearly increasing amount of traffic. When increasing the value for this parameter,
the speed of traffic ramp-up increases non-linearly.
minimum: 1
type: number
duration:
default: 90s
format: duration
type: string
enable:
default: true
type: boolean
maxWeight:
default: 100
description: |-
MaxWeight configures the maximum percentage of origin weight
If unspecified, defaults to 100
format: int64
maximum: 100
minimum: 0
type: integer
minWeight:
default: 10
description: |-
MinWeight configures the minimum percentage of origin weight
If unspecified, defaults to 10
format: int64
maximum: 100
minimum: 0
type: integer
type: object
status:
description: Status defines the current state of TrafficWarmup.
properties:
currentStatus:
description: CurrentStatus defines the current status of a traffic
warmup resource.
type: string
reason:
description: Reason defines the reason for the current status of a
raffic warmup resource.
type: string
type: object
type: object
served: true
storage: true
9 changes: 9 additions & 0 deletions pkg/announcements/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,15 @@ const (
// RetryPolicyUpdated is the type of announcement emitted when we observe an update to retries.policy.flomesh.io
RetryPolicyUpdated Kind = "retry-updated"

// TrafficWarmupAdded is the type of announcement emitted when we observe an addition of trafficwarmups.policy.flomesh.io
TrafficWarmupAdded Kind = "trafficwarmup-added"

// TrafficWarmupDeleted the type of announcement emitted when we observe a deletion of trafficwarmups.policy.flomesh.io
TrafficWarmupDeleted Kind = "trafficwarmup-deleted"

// TrafficWarmupUpdated is the type of announcement emitted when we observe an update to trafficwarmups.policy.flomesh.io
TrafficWarmupUpdated Kind = "trafficwarmup-updated"

// UpstreamTrafficSettingAdded is the type of announcement emitted when we observe an addition of upstreamtrafficsettings.policy.flomesh.io
UpstreamTrafficSettingAdded Kind = "upstreamtrafficsetting-added"

Expand Down
Loading

0 comments on commit 2a59b50

Please sign in to comment.