Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
42 changes: 42 additions & 0 deletions examples/simple-game-server/gameserver-scheduled-restart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
# Copyright Contributors to Agones a Series of LF Projects, LLC.
#
# 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.
apiVersion: agones.dev/v1
kind: GameServer
metadata:
name: simple-scheduled-restart
spec:
container: simple-game-server
ports:
- name: default
containerPort: 7654
# Restart the game server container every night at 4 AM UTC.
# If the server is still in use, wait up to 6 hours (soft deadline).
# After 2 days of deferral, force-restart regardless (hard deadline).
restartPolicy:
schedule: "0 4 * * *"
softDeadlineDuration: "6h"
hardDeadlineDuration: "48h"
template:
spec:
containers:
- name: simple-game-server
image: us-docker.pkg.dev/agones-images/examples/simple-game-server:0.35
resources:
requests:
memory: 64Mi
cpu: 20m
limits:
memory: 64Mi
cpu: 20m
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ require (
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.22.0
github.com/robfig/cron/v3 v3.0.1
github.com/robfig/cron/v3 v3.0.0
github.com/sirupsen/logrus v1.9.3
github.com/spf13/pflag v1.0.6
github.com/spf13/viper v1.7.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,8 @@ github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7z
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/robfig/cron/v3 v3.0.0 h1:kQ6Cb7aHOHTSzNVNEhmp8EcWKLb4CbiMW9h9VyIhO4E=
github.com/robfig/cron/v3 v3.0.0/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
Expand Down
50 changes: 49 additions & 1 deletion install/helm/agones/templates/crds/_gameserverspecschema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,55 @@ properties:
- Always
- OnUpgrade
- Never
immutableReplicas:
restartPolicy:
description: >
[Alpha, GameServerScheduledRestart feature flag]
RestartPolicy configures scheduled in-place restarts of the game
server container without deleting the Pod. This avoids expensive pod
churn while still allowing a clean container restart on a schedule.
When enabled, the RestartController watches this field and the SDK
sidecar will exit (triggering a Kubernetes container restart) when
conditions are met.
type: object
nullable: true
required:
- schedule
properties:
schedule:
type: string
minLength: 9
maxLength: 256
description: >
A standard 5-field cron expression defining when the restart
should be attempted. The expression is evaluated in UTC.
Example: "0 4 * * *" restarts every day at 04:00 UTC.
See https://en.wikipedia.org/wiki/Cron for format details.
softDeadlineDuration:
type: string
nullable: true
description: >
How long the RestartController will wait for the GameServer to
become idle (state=Ready, zero players) after the scheduled
trigger fires, before giving up and deferring to the next
scheduled window. Uses Go duration format, e.g. "2h" or "30m".
When omitted (default), the controller retries every reconcile
loop until the next cron window without an explicit timeout.
pattern: "^([0-9]+(h|m|s))+$"
hardDeadlineDuration:
type: string
nullable: true
description: >
Maximum total time to wait after the first soft-deadline trigger
before forcing a restart regardless of player state or game
server readiness. When the wall-clock time since
"restart-pending-since" annotation exceeds this value, the
restart is forced immediately.
Uses Go duration format, e.g. "48h".
When omitted (default), forced restarts are never performed;
the controller simply defers to the next cron window after each
soft deadline expiry.
pattern: "^([0-9]+(h|m|s))+$"
immutableReplicas:
type: integer
title: Immutable count of Pods to a GameServer. Always 1. (Implementation detail of implementing the Scale subresource.)
default: 1
Expand Down
11 changes: 11 additions & 0 deletions install/helm/agones/templates/crds/_gameserverstatus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,17 @@ status:
- Always
- OnUpgrade
- Never
nextRestartTime:
description: >
[Alpha, GameServerScheduledRestart feature flag]
The wall-clock time at which the next scheduled in-place
restart will be attempted. Only populated when
spec.restartPolicy is configured.
Written by the RestartController; cleared and re-set after
each restart cycle.
type: string
format: date-time
nullable: true
immutableReplicas:
type: integer
title: Immutable count of Pods to a GameServer. Always 1. (Implementation detail of implementing the Scale subresource.)
Expand Down
161 changes: 158 additions & 3 deletions install/yaml/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6560,7 +6560,55 @@ spec:
- Always
- OnUpgrade
- Never
immutableReplicas:
restartPolicy:
description: >
[Alpha, GameServerScheduledRestart feature flag]
RestartPolicy configures scheduled in-place restarts of the game
server container without deleting the Pod. This avoids expensive pod
churn while still allowing a clean container restart on a schedule.
When enabled, the RestartController watches this field and the SDK
sidecar will exit (triggering a Kubernetes container restart) when
conditions are met.
type: object
nullable: true
required:
- schedule
properties:
schedule:
type: string
minLength: 9
maxLength: 256
description: >
A standard 5-field cron expression defining when the restart
should be attempted. The expression is evaluated in UTC.
Example: "0 4 * * *" restarts every day at 04:00 UTC.
See https://en.wikipedia.org/wiki/Cron for format details.
softDeadlineDuration:
type: string
nullable: true
description: >
How long the RestartController will wait for the GameServer to
become idle (state=Ready, zero players) after the scheduled
trigger fires, before giving up and deferring to the next
scheduled window. Uses Go duration format, e.g. "2h" or "30m".
When omitted (default), the controller retries every reconcile
loop until the next cron window without an explicit timeout.
pattern: "^([0-9]+(h|m|s))+$"
hardDeadlineDuration:
type: string
nullable: true
description: >
Maximum total time to wait after the first soft-deadline trigger
before forcing a restart regardless of player state or game
server readiness. When the wall-clock time since
"restart-pending-since" annotation exceeds this value, the
restart is forced immediately.
Uses Go duration format, e.g. "48h".
When omitted (default), forced restarts are never performed;
the controller simply defers to the next cron window after each
soft deadline expiry.
pattern: "^([0-9]+(h|m|s))+$"
immutableReplicas:
type: integer
title: Immutable count of Pods to a GameServer. Always 1. (Implementation detail of implementing the Scale subresource.)
default: 1
Expand Down Expand Up @@ -13532,7 +13580,55 @@ spec:
- Always
- OnUpgrade
- Never
immutableReplicas:
restartPolicy:
description: >
[Alpha, GameServerScheduledRestart feature flag]
RestartPolicy configures scheduled in-place restarts of the game
server container without deleting the Pod. This avoids expensive pod
churn while still allowing a clean container restart on a schedule.
When enabled, the RestartController watches this field and the SDK
sidecar will exit (triggering a Kubernetes container restart) when
conditions are met.
type: object
nullable: true
required:
- schedule
properties:
schedule:
type: string
minLength: 9
maxLength: 256
description: >
A standard 5-field cron expression defining when the restart
should be attempted. The expression is evaluated in UTC.
Example: "0 4 * * *" restarts every day at 04:00 UTC.
See https://en.wikipedia.org/wiki/Cron for format details.
softDeadlineDuration:
type: string
nullable: true
description: >
How long the RestartController will wait for the GameServer to
become idle (state=Ready, zero players) after the scheduled
trigger fires, before giving up and deferring to the next
scheduled window. Uses Go duration format, e.g. "2h" or "30m".
When omitted (default), the controller retries every reconcile
loop until the next cron window without an explicit timeout.
pattern: "^([0-9]+(h|m|s))+$"
hardDeadlineDuration:
type: string
nullable: true
description: >
Maximum total time to wait after the first soft-deadline trigger
before forcing a restart regardless of player state or game
server readiness. When the wall-clock time since
"restart-pending-since" annotation exceeds this value, the
restart is forced immediately.
Uses Go duration format, e.g. "48h".
When omitted (default), forced restarts are never performed;
the controller simply defers to the next cron window after each
soft deadline expiry.
pattern: "^([0-9]+(h|m|s))+$"
immutableReplicas:
type: integer
title: Immutable count of Pods to a GameServer. Always 1. (Implementation detail of implementing the Scale subresource.)
default: 1
Expand Down Expand Up @@ -13648,6 +13744,17 @@ spec:
- Always
- OnUpgrade
- Never
nextRestartTime:
description: >
[Alpha, GameServerScheduledRestart feature flag]
The wall-clock time at which the next scheduled in-place
restart will be attempted. Only populated when
spec.restartPolicy is configured.
Written by the RestartController; cleared and re-set after
each restart cycle.
type: string
format: date-time
nullable: true
immutableReplicas:
type: integer
title: Immutable count of Pods to a GameServer. Always 1. (Implementation detail of implementing the Scale subresource.)
Expand Down Expand Up @@ -20104,7 +20211,55 @@ spec:
- Always
- OnUpgrade
- Never
immutableReplicas:
restartPolicy:
description: >
[Alpha, GameServerScheduledRestart feature flag]
RestartPolicy configures scheduled in-place restarts of the game
server container without deleting the Pod. This avoids expensive pod
churn while still allowing a clean container restart on a schedule.
When enabled, the RestartController watches this field and the SDK
sidecar will exit (triggering a Kubernetes container restart) when
conditions are met.
type: object
nullable: true
required:
- schedule
properties:
schedule:
type: string
minLength: 9
maxLength: 256
description: >
A standard 5-field cron expression defining when the restart
should be attempted. The expression is evaluated in UTC.
Example: "0 4 * * *" restarts every day at 04:00 UTC.
See https://en.wikipedia.org/wiki/Cron for format details.
softDeadlineDuration:
type: string
nullable: true
description: >
How long the RestartController will wait for the GameServer to
become idle (state=Ready, zero players) after the scheduled
trigger fires, before giving up and deferring to the next
scheduled window. Uses Go duration format, e.g. "2h" or "30m".
When omitted (default), the controller retries every reconcile
loop until the next cron window without an explicit timeout.
pattern: "^([0-9]+(h|m|s))+$"
hardDeadlineDuration:
type: string
nullable: true
description: >
Maximum total time to wait after the first soft-deadline trigger
before forcing a restart regardless of player state or game
server readiness. When the wall-clock time since
"restart-pending-since" annotation exceeds this value, the
restart is forced immediately.
Uses Go duration format, e.g. "48h".
When omitted (default), forced restarts are never performed;
the controller simply defers to the next cron window after each
soft deadline expiry.
pattern: "^([0-9]+(h|m|s))+$"
immutableReplicas:
type: integer
title: Immutable count of Pods to a GameServer. Always 1. (Implementation detail of implementing the Scale subresource.)
default: 1
Expand Down
Loading
Loading