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

feat: Add CRD Changes and Feature Flag for chain policy #3880

Merged
merged 32 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
b85c279
define and add crd changes for new fleetautoscaler chain policy
indexjoseph Jun 20, 2024
ee507c0
Made API Changes for Chain Policy
indexjoseph Jun 21, 2024
4908d9e
API Changes for Fleet Autoscaler Policy and Chain Policy
indexjoseph Jun 23, 2024
b73e383
chain policy tests
indexjoseph Jun 23, 2024
cafb1ad
Merge pull request #2 from indexjoseph/main
indexjoseph Jun 23, 2024
618f76c
Merge pull request #3 from indexjoseph/api-changes
indexjoseph Jun 23, 2024
3809f8d
change feature flag stage to alpha
indexjoseph Jun 24, 2024
0e3c4a1
rollback api changes and add scheduled autoscaer as dev feature gate
indexjoseph Jun 24, 2024
154fdf6
remove added vendor files
indexjoseph Jun 24, 2024
9eb6a8c
fix example spacing
indexjoseph Jun 24, 2024
05a68a4
fix yaml lint
indexjoseph Jun 24, 2024
0c1cf36
fix enumerations for policies
indexjoseph Jun 24, 2024
bf4b616
fixed install yaml
indexjoseph Jun 25, 2024
2166707
remove extra character and add documentation
indexjoseph Jun 25, 2024
03105b0
fix documentation for example
indexjoseph Jun 25, 2024
3e47ddc
remove extra period...
indexjoseph Jun 25, 2024
17038c8
fix copyright dates, feature gate and include policy
indexjoseph Jun 26, 2024
8a8098e
Merge branch 'main' into scheduled-autoscalers
indexjoseph Jun 26, 2024
f4257ad
fix recursive chain policy issue
indexjoseph Jun 27, 2024
62fbb58
Merge branch 'scheduled-autoscalers' of github.com:indexjoseph/agones…
indexjoseph Jun 27, 2024
8e6b59e
remove extra indentation
indexjoseph Jun 27, 2024
f494f3c
Merge branch 'main' into scheduled-autoscalers
indexjoseph Jul 2, 2024
5c7c800
move timezone field into activePeriod and only allow for RFC3339 star…
indexjoseph Jul 9, 2024
da3eb4c
move timezone field into activePeriod and only allow for RFC3339 star…
indexjoseph Jul 9, 2024
40ed756
remove extra indentation
indexjoseph Jul 9, 2024
13e4e77
remove trailing spaces
indexjoseph Jul 9, 2024
c96d80b
reword timezone documentation
indexjoseph Jul 9, 2024
8dac8bb
add documentation to examples for defaulted duration
indexjoseph Jul 9, 2024
93fffb7
change from uid to id
indexjoseph Jul 9, 2024
6049f6c
add documentation for optional fields
indexjoseph Jul 9, 2024
59c4259
remove extra spacings
indexjoseph Jul 9, 2024
6a49905
Merge branch 'main' into scheduled-autoscalers
zmerlynn Jul 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions examples/chainfleetautoscaler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
---
# Copyright 2024 Google LLC All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#
# [Stage:Dev]
# [FeatureFlag:ScheduledAutoscaler]
# Example of a FleetAutoscaler - this is used to scale a Fleet based on a schedule.
#

#
# For a full reference and details: https://agones.dev/site/docs/reference/fleetautoscaler/
#
apiVersion: autoscaling.agones.dev/v1
kind: FleetAutoscaler
metadata:
name: chain-fleet-autoscaler
spec:
policy:
# Chain based policy for autoscaling.
type: Chain
chain:
# UID of chain entry. Optional.
- uid: "weekday"
indexjoseph marked this conversation as resolved.
Show resolved Hide resolved
type: Schedule # Schedule based condition.
schedule:
between:
# The policy becomes eligible for application starting on
# Feb 20, 2024 at 4:04 PM EST. Optional.
start: "2024-02-20T16:04:04-05:00"
# The policy becomes ineligible for application on
# Feb 23, 2024 at 4:04 PM EST. Optional.
end: "2024-02-23T16:04:04-05:00"
activePeriod:
# Timezone to be used for the startCron field. Optional.
indexjoseph marked this conversation as resolved.
Show resolved Hide resolved
timezone: "America/New_York"
# Start applying the bufferSize everyday at 1:00 AM EST.
# (Only eligible starting on Feb 20, 2024 at 4:04 PM.) Optional.
startCron: "0 1 * * 0"
# Only apply the bufferSize for this 5 hours
# Optional.
duration: "5h"
indexjoseph marked this conversation as resolved.
Show resolved Hide resolved
# Policy to be applied when the condition is met. Required.
policy:
type: Buffer
buffer:
bufferSize: 50
minReplicas: 100
maxReplicas: 2000
# UID of chain entry. Optional.
- uid: "weekend"
type: Schedule
schedule:
between:
# The policy becomes eligible for application starting on
# Feb 24, 2024 at 4:05 PM EST.
# Optional.
start: "2024-02-24T16:04:05-05:00"
# The policy becomes ineligible for application starting on
# Feb 26, 2024 at 4:05 PM EST.
# Optional.
end: "2024-02-26T16:04:05-05:00"
activePeriod:
# Timezone to be used for the startCron field. Optional.
timezone: "America/New_York"
# Start applying the bufferSize everyday at 1:00 AM EST.
# (Only eligible starting on Feb 24, 2024 at 4:05 PM EST)
# Optional.
startCron: "0 1 * * 0"
# Only apply the bufferSize for this 7 hours
# Optional.
duration: "7h"
# Policy to be applied when the condition is met. Required.
policy:
type: Counter
counter:
key: rooms
bufferSize: 10
minCapacity: 500
maxCapacity: 1000
# UID of chain entry.
- uid: "default"
# Policy will always be applied when no other policy is applicable. Required.
policy:
type: Buffer
buffer:
bufferSize: 5
minReplicas: 100
maxReplicas: 2000
1 change: 1 addition & 0 deletions install/helm/agones/defaultfeaturegates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ PortRanges: false
PortPolicyNone: false

# Dev features
ScheduledAutoscaler: false

# Example feature
Example: false
146 changes: 146 additions & 0 deletions install/helm/agones/templates/crds/_fleetautoscalerpolicy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# Copyright 2024 Google LLC All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---
{{/* schema for a fleet autoscaler policy */}}
{{- define "fleetautoscaler.policy" }}
policy:
type: object
required:
- type
properties:
type:
type: string
enum:
- Buffer
- Webhook
- Counter
- List
{{- if .includeChainPolicy }}
- Chain
{{- end }}
buffer:
type: object
nullable: true
required:
- maxReplicas
properties:
minReplicas:
type: integer
minimum: 0
maxReplicas:
type: integer
minimum: 1
bufferSize:
x-kubernetes-int-or-string: true
anyOf:
- type: integer
- type: string
webhook:
type: object
nullable: true
properties:
url:
type: string
service:
type: object
required:
- namespace
- name
properties:
namespace:
type: string
name:
type: string
path:
type: string
port:
type: integer
caBundle:
type: string
format: byte
counter:
type: object
nullable: true
required:
- key
- bufferSize
- maxCapacity
properties:
key: # The name of the Counter.
type: string
minCapacity: # Minimum aggregate counter capacity that can be provided by this FleetAutoscaler. If not specified, the actual minimum capacity will be bufferSize.
type: integer
minimum: 0
maxCapacity: # Maximum aggregate counter capacity that can be provided by this FleetAutoscaler. Required.
type: integer
minimum: 1
bufferSize: # Size of a buffer of counted items that are available in the Fleet (available capacity). It can be specified either in absolute (i.e. 5) or percentage format (i.e. 5%).
x-kubernetes-int-or-string: true
anyOf:
- type: integer
- type: string
list:
type: object
nullable: true
required:
- key
- bufferSize
- maxCapacity
properties:
key: # The name of the List.
type: string
minCapacity: # Minimum aggregate list capacity that can be provided by this FleetAutoscaler. If not specified, the actual minimum capacity will be bufferSize.
type: integer
minimum: 0
maxCapacity: # Maximum aggregate list capacity that can be provided by this FleetAutoscaler. Required.
type: integer
minimum: 1
bufferSize: # Size of a buffer based on the list capacity that is available over the current aggregate list length in the Fleet. It can be specified either in absolute (i.e. 5) or percentage format (i.e. 5%).
x-kubernetes-int-or-string: true
anyOf:
- type: integer
- type: string
{{- if .includeChainPolicy }}
chain:
type: array
nullable: true
items:
type: object
nullable: true
required:
- policy
properties:
uid: # The uid of a chain entry.
type: string
schedule: # Defines when the policy is applied.
type: object
properties:
between:
type: object
start: # Defines when to start evaluating the active period, must conform to RFC3339.
type: string
end: # Defines when to stop evaluating the active period, must conform to RFC3339.
type: string
activePeriod:
type: object
timezone: # Timezone to be used for the startCron field, must conform with the IANA Time Zone database (e.g. America/New_York).
type: string
startCron: # Cron expression defining when to start applying the policy. All TZ/CRON_TZ specification within startCron will be rejected, please use the timezone field above to specify a timezone. Must conform with UNIX CRON syntax.
type: string
duration: # The length of time the policy should be applied for (e.g. 2h45m).
type: string
{{- include "fleetautoscaler.policy" (dict "includeChainPolicy" false) | indent 12 }} # Defines which policy to apply during the active period. Required.
{{- end }}
{{- end }}
96 changes: 2 additions & 94 deletions install/helm/agones/templates/crds/fleetautoscaler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,100 +55,8 @@ spec:
minLength: 1
maxLength: 63
pattern: "^[a-z0-9]([-\\.a-z0-9]*[a-z0-9])?$"
policy:
type: object
required:
- type
properties:
type:
type: string
enum:
- Buffer
- Webhook
- Counter
- List
buffer:
type: object
nullable: true
required:
- maxReplicas
properties:
minReplicas:
type: integer
minimum: 0
maxReplicas:
type: integer
minimum: 1
bufferSize:
x-kubernetes-int-or-string: true
anyOf:
- type: integer
- type: string
webhook:
type: object
nullable: true
properties:
url:
type: string
service:
type: object
required:
- namespace
- name
properties:
namespace:
type: string
name:
type: string
path:
type: string
port:
type: integer
caBundle:
type: string
format: byte
counter:
type: object
nullable: true
required:
- key
- bufferSize
- maxCapacity
properties:
key: # The name of the Counter.
type: string
minCapacity: # Minimum aggregate counter capacity that can be provided by this FleetAutoscaler. If not specified, the actual minimum capacity will be bufferSize.
type: integer
minimum: 0
maxCapacity: # Maximum aggregate counter capacity that can be provided by this FleetAutoscaler. Required.
type: integer
minimum: 1
bufferSize: # Size of a buffer of counted items that are available in the Fleet (available capacity). It can be specified either in absolute (i.e. 5) or percentage format (i.e. 5%).
x-kubernetes-int-or-string: true
anyOf:
- type: integer
- type: string
list:
type: object
nullable: true
required:
- key
- bufferSize
- maxCapacity
properties:
key: # The name of the List.
type: string
minCapacity: # Minimum aggregate list capacity that can be provided by this FleetAutoscaler. If not specified, the actual minimum capacity will be bufferSize.
type: integer
minimum: 0
maxCapacity: # Maximum aggregate list capacity that can be provided by this FleetAutoscaler. Required.
type: integer
minimum: 1
bufferSize: # Size of a buffer based on the list capacity that is available over the current aggregate list length in the Fleet. It can be specified either in absolute (i.e. 5) or percentage format (i.e. 5%).
x-kubernetes-int-or-string: true
anyOf:
- type: integer
- type: string
{{- $featureGates := include "agones.featureGates" . | fromYaml }}
{{- include "fleetautoscaler.policy" (dict "includeChainPolicy" $featureGates.ScheduledAutoscaler) | indent 16 }}
sync:
type: object
required:
Expand Down
2 changes: 1 addition & 1 deletion install/yaml/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5672,7 +5672,7 @@ spec:
type: string
minLength: 1
maxLength: 63
pattern: "^[a-z0-9]([-\\.a-z0-9]*[a-z0-9])?$"
pattern: "^[a-z0-9]([-\\.a-z0-9]*[a-z0-9])?$"
indexjoseph marked this conversation as resolved.
Show resolved Hide resolved
policy:
type: object
required:
Expand Down
4 changes: 4 additions & 0 deletions pkg/util/runtime/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ const (
////////////////
// Dev features

// FeatureScheduledAutoscaler is a feature flag to enable/disable scheduled fleet autoscaling.
FeatureScheduledAutoscaler Feature = "ScheduledAutoscaler"

////////////////
// Example feature

Expand Down Expand Up @@ -141,6 +144,7 @@ var (
FeaturePortPolicyNone: false,

// Dev features
FeatureScheduledAutoscaler: false,

// Example feature
FeatureExample: false,
Expand Down
Loading