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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.24 AS builder
FROM golang:1.25 AS builder
ARG TARGETOS
ARG TARGETARCH

Expand Down
214 changes: 173 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,67 @@
# Windrose Operator

Kubernetes operator for [Windrose](https://playwindrose.com) dedicated game servers using the official Linux container image [`windroseserver/windroseserver`](https://hub.docker.com/r/windroseserver/windroseserver).
Kubernetes operator for [Windrose](https://playwindrose.com) dedicated game servers using the official Linux image [`windroseserver/windroseserver`](https://hub.docker.com/r/windroseserver/windroseserver).

This project complements [windrose-server-k8s](https://github.com/DataKnifeAI/windrose-server-k8s), which packages a Wine-based server image. The operator targets the native Linux image published by the Windrose team.
This project complements [windrose-server-k8s](https://github.com/DataKnifeAI/windrose-server-k8s), which packages a Wine-based server image and static Kustomize manifests. The operator:

- Runs the **native Linux** image from the Windrose team (not the Wine fork)
- Manages servers declaratively via a `WindroseServer` custom resource
- Matches the **Envoy Gateway** exposure pattern used in DataKnife `prd-apps` (`game-servers` namespace)

## Comparison

| | windrose-operator | windrose-server-k8s |
|--|---------------------|---------------------|
| Image | `windroseserver/windroseserver` | Harbor Wine image (`indifferentbroccoli` fork) |
| Deployment | Operator-managed CR | Kustomize manifests |
| External access | Envoy Gateway (TCPRoute/UDPRoute) | Envoy Gateway (manual manifests today) |
| Config | `ServerDescription.json` ConfigMap | Env vars + generated JSON on disk |
| Mount path | `/home/ue_user/app/R5/...` | `/home/steam/server-files/...` |

## Features

- Declarative `WindroseServer` custom resource
- Manages Deployment, Service, PVC, and `ServerDescription.json` ConfigMap
- Direct IP connection mode enabled by default (required for Kubernetes)
- Persistent world saves on a PVC
- Resource defaults aligned with Windrose hardware guidance (4-player profile)
- `WindroseServer` CRD with status (phase, ready, connection address/port)
- Envoy Gateway exposure: Gateway, EnvoyProxy, TCPRoute, UDPRoute
- ClusterIP backend services (`{name}` and `{name}-envoy`)
- PVC for world saves, ConfigMap for `ServerDescription.json`
- Pod resources auto-selected from `maxPlayerCount` (override supported)

## Architecture

```
Clients → spec.gateway.address (Kube-VIP / MetalLB)
↓
{base}-gateway (GatewayClass: envoy)
↓
TCPRoute / UDPRoute → {name}-envoy (ClusterIP)
↓
{name} Deployment (windroseserver/windroseserver)
↓
PVC + ServerDescription.json (ConfigMap)
```

Each `WindroseServer` reconciles these Kubernetes resources:

| Kind | Default name (CR: `windrose-server`) |
|------|--------------------------------------|
| Deployment | `windrose-server` |
| PersistentVolumeClaim | `windrose-server-files` |
| ConfigMap | `windrose-server-config` |
| Service (ClusterIP) | `windrose-server` |
| Service (Envoy backend) | `windrose-server-envoy` |
| Gateway | `windrose-gateway` |
| EnvoyProxy | `game-windrose-kubevip` |
| TCPRoute | `windrose-game-tcp` |
| UDPRoute | `windrose-game-udp` |

Gateway-related names strip a trailing `-server` suffix from the CR name before applying the patterns above. Override with `spec.gateway.gatewayName` or `spec.gateway.envoyProxyName`.

## Prerequisites

- Kubernetes 1.28+
- A StorageClass for persistent volumes (35 Gi minimum recommended)
- LoadBalancer or NodePort support for exposing game traffic (TCP + UDP on the same port)
- [Envoy Gateway](https://gateway.envoyproxy.io/) installed with a `GatewayClass` named `envoy`
- A StorageClass for persistent volumes (35 Gi minimum per Windrose guidance)
- One dedicated external IP per server (`spec.gateway.address`), typically from Kube-VIP or MetalLB

## Quick start

Expand All @@ -26,39 +71,138 @@ Install the CRD and operator:
kubectl apply -k config/default
```

Create a server:
Create a server (adjust IP, namespace, and storage class for your cluster):

```shell
kubectl apply -f config/samples/windrose_v1alpha1_windroseserver.yaml
```

Watch status:
Check status:

```shell
kubectl get windroseserver my-windrose-server -w
kubectl get windroseserver -n game-servers
kubectl describe windroseserver windrose-server -n game-servers
```

Connect in-game via **Play → Connect to Server** using:

- Address: `.status.connectionAddress` (falls back to `spec.gateway.address`)
- Port: `.status.connectionPort` (defaults to `7777`)

## Example

```yaml
apiVersion: windrose.dataknife.ai/v1alpha1
kind: WindroseServer
metadata:
name: windrose-server
namespace: game-servers
spec:
serverImage: windroseserver/windroseserver:latest
gateway:
address: 192.168.14.186
className: envoy
useDirectConnection: true
directConnectionServerPort: 7777
directConnectionProxyAddress: 0.0.0.0
serverName: My Windrose Server
maxPlayerCount: 4
userSelectedRegion: EU
storageSize: 35Gi
storageClassName: truenas-csi-nfs
nodeSelector:
kubernetes.io/os: linux
kubernetes.io/arch: amd64
```

Connect in-game with **Play → Connect to Server** using the LoadBalancer address and port from `.status.connectionAddress` and `.status.connectionPort` when `useDirectConnection: true`.
## Spec reference

### Gateway (required)

| Field | Default | Description |
|-------|---------|-------------|
| `gateway.address` | *(required)* | External IP for this server (e.g. `192.168.14.186`) |
| `gateway.className` | `envoy` | GatewayClass name |
| `gateway.gatewayName` | `{base}-gateway` | Override Gateway resource name |
| `gateway.envoyProxyName` | `game-{base}-kubevip` | Override EnvoyProxy resource name |
| `gateway.externalTrafficPolicy` | `Cluster` | Envoy LoadBalancer traffic policy |

## WindroseServer spec
### Server image

| Field | Default | Description |
|-------|---------|-------------|
| `serverImage` | `windroseserver/windroseserver:latest` | Official Linux server image |
| `useDirectConnection` | `true` | Direct IP connections (recommended on Kubernetes) |
| `directConnectionServerPort` | `7777` | Game port (TCP + UDP) |
| `imagePullPolicy` | `IfNotPresent` | Container pull policy |
| `imagePullSecrets` | | Pull secrets for private registries |
| `nodeSelector` | | Pin the pod to specific nodes |

### Game settings

These fields are written to `ServerDescription.json`. See the [dedicated server guide](https://playwindrose.com/dedicated-server-guide) for semantics.

| Field | Default | Description |
|-------|---------|-------------|
| `useDirectConnection` | `true` | Direct IP connections (required for Kubernetes) |
| `directConnectionServerPort` | `7777` | Game port exposed via TCP and UDP |
| `directConnectionProxyAddress` | `0.0.0.0` | Bind address inside the container |
| `serverName` | | Display name in the server browser |
| `password` | | Optional server password |
| `maxPlayerCount` | `4` | Maximum simultaneous players |
| `userSelectedRegion` | | `SEA`, `CIS`, or `EU`; empty auto-selects |
| `storageSize` | `35Gi` | PVC size for world saves |
| `serviceType` | `LoadBalancer` | `LoadBalancer`, `NodePort`, or `ClusterIP` |
| `password` | | Server password (empty = public) |
| `maxPlayerCount` | `4` | Max simultaneous players (1–32) |
| `userSelectedRegion` | | `SEA`, `CIS`, or `EU`; empty = auto-detect |
| `inviteCode` | | Invite code when `useDirectConnection` is `false` |
| `p2pProxyAddress` | `127.0.0.1` | P2P proxy address for invite-code mode |
| `autoLoadLatestBackupIfHasBroken` | `true` | Restore broken saves from backups on launch |

Direct IP and invite-code modes are mutually exclusive in Windrose. Kubernetes deployments should use direct connection.

Settings map to [`ServerDescription.json`](https://playwindrose.com/dedicated-server-guide) fields. World configuration (`WorldDescription.json`) is created by the server on first boot and stored on the PVC.
### Storage

| Field | Default | Description |
|-------|---------|-------------|
| `storageSize` | `35Gi` | PVC capacity for world saves |
| `storageClassName` | | StorageClass for the saves PVC |

Saves are mounted at `/home/ue_user/app/R5/Saved`. `WorldDescription.json` is created by the server on first boot and stored on the PVC.

### Pod resources

When `spec.resources` is **omitted**, CPU and memory are derived from `maxPlayerCount` using [Windrose hardware guidance](https://playwindrose.com/dedicated-server-guide):

| Players | CPU request | Memory request | CPU limit | Memory limit |
|---------|-------------|----------------|-----------|--------------|
| 1–2 | 2 | 8Gi | 4 | 10Gi |
| 3–4 | 2 | 12Gi | 4 | 16Gi |
| 5–32 | 2 | 16Gi | 4 | 16Gi |

When `spec.resources` is **set** (requests or limits), it fully overrides auto-selection:

```yaml
spec:
maxPlayerCount: 10
resources:
requests:
cpu: 250m
memory: 2Gi
limits:
cpu: "4"
memory: 10Gi
```

## Status

| Field | Description |
|-------|-------------|
| `phase` | `Pending`, `Running`, or `Failed` |
| `ready` | `true` when the game server pod is ready |
| `connectionAddress` | IP clients connect to |
| `connectionPort` | Port clients connect to |
| `message` | Human-readable detail |

Short name: `kubectl get ws`

## Official Docker image layout

The operator mounts resources the same way as the upstream Docker instructions:
The operator mirrors the upstream Docker run invocation:

```shell
docker run --user ue_user --name WindroseServer \
Expand All @@ -68,33 +212,21 @@ docker run --user ue_user --name WindroseServer \
windroseserver/windroseserver:latest
```

## Hardware guidance

| Players | CPU | RAM | Storage |
|---------|-----|-----|---------|
| 2 | 2 cores @ 3.2 GHz | 8 GB | 35 GB SSD |
| 4 | 2 cores @ 3.2 GHz | 12 GB | 35 GB SSD |
| 10 | 2 cores @ 3.2 GHz | 16 GB | 35 GB SSD |

Adjust `spec.resources` on the `WindroseServer` CR for larger player counts.

## Development

```shell
make generate manifests
make test
make run
```

Build the operator image:
Requires Go 1.25+.

```shell
make generate manifests # CRD, RBAC, deepcopy
make test
make build # bin/manager
make run # local controller
make docker-build IMG=harbor.dataknife.net/library/windrose-operator:latest
```

## Related projects

- [DataKnifeAI/windrose-server-k8s](https://github.com/DataKnifeAI/windrose-server-k8s) — Wine-based Windrose server image and Kustomize manifests
- [DataKnifeAI/windrose-server-k8s](https://github.com/DataKnifeAI/windrose-server-k8s) — Wine-based image and Kustomize manifests
- [Windrose Dedicated Server Guide](https://playwindrose.com/dedicated-server-guide)
- [windroseserver/windroseserver on Docker Hub](https://hub.docker.com/r/windroseserver/windroseserver)

Expand Down
66 changes: 52 additions & 14 deletions api/v1alpha1/windroseserver_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,37 @@ const (
PhaseFailed = "Failed"
)

// GatewayConfig configures Envoy Gateway exposure for direct game connections.
// This matches the prd-apps game-servers pattern: Gateway + EnvoyProxy + TCPRoute/UDPRoute
// fronting ClusterIP backend services.
type GatewayConfig struct {
// Address is the external IP assigned to this server (Kube-VIP or MetalLB).
// +kubebuilder:validation:Required
// +kubebuilder:validation:Pattern=`^([0-9]{1,3}\.){3}[0-9]{1,3}$`
Address string `json:"address"`

// ClassName is the GatewayClass used for the Envoy Gateway controller.
// +kubebuilder:default="envoy"
// +optional
ClassName string `json:"className,omitempty"`

// GatewayName overrides the Gateway resource name.
// Default: {base-name}-gateway where base-name strips a trailing "-server" suffix.
// +optional
GatewayName string `json:"gatewayName,omitempty"`

// EnvoyProxyName overrides the EnvoyProxy resource name.
// Default: game-{base-name}-kubevip.
// +optional
EnvoyProxyName string `json:"envoyProxyName,omitempty"`

// ExternalTrafficPolicy for the Envoy LoadBalancer service.
// +kubebuilder:validation:Enum=Cluster;Local
// +kubebuilder:default=Cluster
// +optional
ExternalTrafficPolicy corev1.ServiceExternalTrafficPolicy `json:"externalTrafficPolicy,omitempty"`
}

// WindroseServerSpec defines the desired state of a Windrose dedicated game server.
// Settings map to ServerDescription.json fields documented at
// https://playwindrose.com/dedicated-server-guide and the official Docker image
Expand All @@ -21,13 +52,29 @@ type WindroseServerSpec struct {
// +optional
ServerImage string `json:"serverImage,omitempty"`

// ImagePullPolicy for the game server container.
// +kubebuilder:default=IfNotPresent
// +optional
ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"`

// ImagePullSecrets for private registries.
// +optional
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`

// NodeSelector pins the game server pod to specific nodes.
// +optional
NodeSelector map[string]string `json:"nodeSelector,omitempty"`

// Gateway configures Envoy Gateway exposure (required).
Gateway GatewayConfig `json:"gateway"`

// InviteCode is used when UseDirectConnection is false. Minimum 6 characters.
// +kubebuilder:validation:MinLength=6
// +kubebuilder:validation:MaxLength=32
// +optional
InviteCode string `json:"inviteCode,omitempty"`

// UseDirectConnection enables direct IP connections (recommended for Kubernetes).
// UseDirectConnection enables direct IP connections (required for Kubernetes).
// +kubebuilder:default=true
// +optional
UseDirectConnection *bool `json:"useDirectConnection,omitempty"`
Expand All @@ -53,6 +100,7 @@ type WindroseServerSpec struct {
Password string `json:"password,omitempty"`

// MaxPlayerCount is the maximum number of simultaneous players.
// When spec.resources is unset, pod CPU/memory are auto-selected from this value.
// +kubebuilder:default=4
// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:Maximum=32
Expand Down Expand Up @@ -84,21 +132,10 @@ type WindroseServerSpec struct {
// +optional
StorageClassName string `json:"storageClassName,omitempty"`

// Resources for the game server container. Defaults match Windrose docs for 4 players.
// Resources for the game server container.
// When set, overrides auto-selection based on maxPlayerCount.
// +optional
Resources corev1.ResourceRequirements `json:"resources,omitempty"`

// ServiceType exposes the game port outside the cluster.
// +kubebuilder:validation:Enum=LoadBalancer;NodePort;ClusterIP
// +kubebuilder:default=LoadBalancer
// +optional
ServiceType corev1.ServiceType `json:"serviceType,omitempty"`

// NodePort is used when ServiceType is NodePort. Must be in range 30000-32767 when set.
// +kubebuilder:validation:Minimum=30000
// +kubebuilder:validation:Maximum=32767
// +optional
NodePort int32 `json:"nodePort,omitempty"`
}

// WindroseServerStatus defines the observed state of WindroseServer.
Expand Down Expand Up @@ -137,6 +174,7 @@ type WindroseServerStatus struct {
// +kubebuilder:resource:shortName=ws
// +kubebuilder:printcolumn:name="Phase",type=string,JSONPath=`.status.phase`
// +kubebuilder:printcolumn:name="Ready",type=boolean,JSONPath=`.status.ready`
// +kubebuilder:printcolumn:name="Address",type=string,JSONPath=`.status.connectionAddress`
// +kubebuilder:printcolumn:name="Port",type=integer,JSONPath=`.status.connectionPort`
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`

Expand Down
Loading
Loading