Skip to content
Merged
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
50 changes: 50 additions & 0 deletions src/resources/fleet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,36 @@ export interface AgonesFleet extends KubeObjectInterface {
};
};
template: object;
/**
* Labels/annotations to apply to GameServers when allocation count exceeds
* the desired replicas.
*
* @see {@link https://agones.dev/site/docs/reference/fleet/#allocation-overflow | Allocation Overflow}
*/
allocationOverflow?: {
labels?: Record<string, string>;
annotations?: Record<string, string>;
};
/**
* Scheduling priorities used to sort GameServers during allocation.
*
* @see {@link https://agones.dev/site/docs/advanced/scheduling-and-autoscaling/#fleet-scheduling | Fleet Scheduling}
*/
priorities?: Array<{
type: 'Counter' | 'List';
key: string;
order: 'Ascending' | 'Descending';
}>;
};
status?: {
replicas?: number;
readyReplicas?: number;
reservedReplicas?: number;
allocatedReplicas?: number;
/** Aggregate counter status across all GameServers in the Fleet. */
counters?: Record<string, { count: number; capacity: number }>;
/** Aggregate list status across all GameServers in the Fleet. */
lists?: Record<string, { values: string[]; capacity: number }>;
};
}

Expand Down Expand Up @@ -90,4 +114,30 @@ export class Fleet extends KubeObject<AgonesFleet> {
get maxUnavailable(): string | number | undefined {
return this.spec.strategy?.rollingUpdate?.maxUnavailable;
}

/**
* Allocation overflow metadata applied when allocation count exceeds desired replicas.
*
* @see {@link https://agones.dev/site/docs/reference/fleet/#allocation-overflow | Allocation Overflow}
*/
get allocationOverflow():
| { labels?: Record<string, string>; annotations?: Record<string, string> }
| undefined {
return this.spec.allocationOverflow;
}

/** Scheduling priorities for GameServer allocation ordering. */
get priorities(): Array<{ type: string; key: string; order: string }> {
return this.spec.priorities ?? [];
}

/** Aggregate counter status across all GameServers in the Fleet. */
get counters(): Record<string, { count: number; capacity: number }> {
return this.status.counters ?? {};
}

/** Aggregate list status across all GameServers in the Fleet. */
get lists(): Record<string, { values: string[]; capacity: number }> {
return this.status.lists ?? {};
}
}
24 changes: 22 additions & 2 deletions src/resources/fleetautoscaler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,29 @@ export interface AgonesFleetAutoscaler extends KubeObjectInterface {
port?: number;
};
};
/**
* WebAssembly-based autoscaling policy.
*
* @see {@link https://agones.dev/site/docs/advanced/scheduling-and-autoscaling/#custom-autoscaler-with-wasm | Wasm Autoscaler}
*/
wasm?: {
url: string;
requestsPerSecond?: number;
};
schedule?: {
between?: { start: string; end: string };
activePeriod?: { timezone: string; schedule: string };
between?: {
start: string;
end: string;
minReplicas: number;
maxReplicas: number;
};
activePeriod?: {
timezone: string;
/** Cron expression for when the period begins. */
startCron: string;
/** Duration of the active period (e.g. '2h', '30m'). */
duration: string;
};
policy: {
type: string;
buffer?: { bufferSize: number | string; minReplicas: number; maxReplicas: number };
Expand Down
46 changes: 46 additions & 0 deletions src/resources/gameserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,24 @@ export interface ListStatus {
capacity: number;
}

/**
* Eviction configuration for a GameServer.
*
* @see {@link https://agones.dev/site/docs/advanced/controlling-disruption/ | Controlling Disruption}
*/
export interface Eviction {
/** Safe strategy: 'Always' | 'OnUpgrade' | 'Never'. */
safe: string;
}

/**
* A routable address assigned to the GameServer (e.g. NodeInternalIP, NodeExternalIP).
*/
export interface NodeAddress {
type: string;
address: string;
}

export interface AgonesGameServer extends KubeObjectInterface {
spec: {
scheduling: string;
Expand All @@ -56,6 +74,8 @@ export interface AgonesGameServer extends KubeObjectInterface {
};
counters?: Record<string, { capacity: number }>;
lists?: Record<string, { capacity: number; values?: string[] }>;
/** Eviction tolerance of the GameServer. */
eviction?: Eviction;
};
status?: {
state?: string;
Expand All @@ -64,6 +84,10 @@ export interface AgonesGameServer extends KubeObjectInterface {
nodeName?: string;
counters?: Record<string, CounterStatus>;
lists?: Record<string, ListStatus>;
/** All routable addresses (NodeInternalIP, NodeExternalIP, etc.). */
addresses?: NodeAddress[];
/** ISO 8601 timestamp: the GameServer is reserved until this time. */
reservedUntil?: string;
};
}

Expand Down Expand Up @@ -115,6 +139,28 @@ export class GameServer extends KubeObject<AgonesGameServer> {
return this.status.lists ?? {};
}

/**
* Eviction safe mode for this GameServer.
*
* @see {@link https://agones.dev/site/docs/advanced/controlling-disruption/ | Controlling Disruption}
*/
get eviction(): string {
return this.spec.eviction?.safe ?? 'Never';
}

/** All routable addresses assigned to the GameServer. */
get addresses(): NodeAddress[] {
return this.status.addresses ?? [];
}

/**
* ISO 8601 timestamp until which the GameServer is reserved.
* Returns `undefined` if the server is not reserved.
*/
get reservedUntil(): string | undefined {
return this.status.reservedUntil;
}

/** Merged port info: spec metadata (policy, containerPort) + status (host port). */
get mergedPorts(): Array<{
name: string;
Expand Down
4 changes: 2 additions & 2 deletions src/views/fleetautoscalers/Detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function policyExtraInfo(item: FleetAutoscaler) {
return [
{
name: 'Cron Schedule',
value: policy.schedule?.activePeriod?.schedule ?? '—',
value: policy.schedule?.activePeriod?.startCron ?? '—',
},
{
name: 'Timezone',
Expand Down Expand Up @@ -152,7 +152,7 @@ function policyExplanation(item: FleetAutoscaler): string {
case 'Webhook':
return `Scaling decisions are delegated to an external webhook. The webhook receives current fleet state and responds with the desired replica count.`;
case 'Schedule': {
const sched = policy.schedule?.activePeriod?.schedule;
const sched = policy.schedule?.activePeriod?.startCron;
const tz = policy.schedule?.activePeriod?.timezone ?? 'UTC';
const nested = policy.schedule?.policy?.type ?? 'Buffer';
return sched
Expand Down
4 changes: 3 additions & 1 deletion src/views/overview/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ import { FleetAutoscaler } from '../../resources/fleetautoscaler';
import { GameServer } from '../../resources/gameserver';

const STATE_ORDER = [
'PortAllocation',
'Creating',
'Starting',
'Ready',
'Allocated',
'Reserved',
'Creating',
'Scheduled',
'RequestReady',
'Shutdown',
Expand Down