Skip to content

Commit ef3c39b

Browse files
committed
added a comprehensive Deployment Examples section to the README
1 parent 6d221a4 commit ef3c39b

1 file changed

Lines changed: 354 additions & 0 deletions

File tree

README.md

Lines changed: 354 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,360 @@ View distance is the main driver for RAM usage. Limit maximum view distance to 1
165165
# Configure in config.json or via server arguments
166166
```
167167

168+
## Deployment Examples
169+
170+
### Kubernetes
171+
172+
Deploy a Hytale server on Kubernetes with persistent storage:
173+
174+
```yaml
175+
# hytale-server-deployment.yaml
176+
apiVersion: v1
177+
kind: Secret
178+
metadata:
179+
name: hytale-server-secrets
180+
type: Opaque
181+
stringData:
182+
session-token: "<your-session-token>"
183+
identity-token: "<your-identity-token>"
184+
owner-uuid: "<your-owner-uuid>"
185+
---
186+
apiVersion: v1
187+
kind: PersistentVolumeClaim
188+
metadata:
189+
name: hytale-server-data
190+
spec:
191+
accessModes:
192+
- ReadWriteOnce
193+
resources:
194+
requests:
195+
storage: 10Gi
196+
---
197+
apiVersion: apps/v1
198+
kind: Deployment
199+
metadata:
200+
name: hytale-server
201+
labels:
202+
app: hytale-server
203+
spec:
204+
replicas: 1
205+
selector:
206+
matchLabels:
207+
app: hytale-server
208+
template:
209+
metadata:
210+
labels:
211+
app: hytale-server
212+
spec:
213+
containers:
214+
- name: hytale-server
215+
image: ghcr.io/<username>/hytale-server-docker:latest
216+
ports:
217+
- containerPort: 5520
218+
protocol: UDP
219+
env:
220+
- name: HYTALE_SERVER_SESSION_TOKEN
221+
valueFrom:
222+
secretKeyRef:
223+
name: hytale-server-secrets
224+
key: session-token
225+
- name: HYTALE_SERVER_IDENTITY_TOKEN
226+
valueFrom:
227+
secretKeyRef:
228+
name: hytale-server-secrets
229+
key: identity-token
230+
- name: HYTALE_SERVER_OWNER_UUID
231+
valueFrom:
232+
secretKeyRef:
233+
name: hytale-server-secrets
234+
key: owner-uuid
235+
volumeMounts:
236+
- name: server-data
237+
mountPath: /app/universe
238+
subPath: universe
239+
- name: server-data
240+
mountPath: /app/mods
241+
subPath: mods
242+
- name: server-data
243+
mountPath: /app/logs
244+
subPath: logs
245+
resources:
246+
requests:
247+
memory: "4Gi"
248+
cpu: "1"
249+
limits:
250+
memory: "8Gi"
251+
cpu: "4"
252+
volumes:
253+
- name: server-data
254+
persistentVolumeClaim:
255+
claimName: hytale-server-data
256+
---
257+
apiVersion: v1
258+
kind: Service
259+
metadata:
260+
name: hytale-server
261+
spec:
262+
type: LoadBalancer
263+
selector:
264+
app: hytale-server
265+
ports:
266+
- port: 5520
267+
targetPort: 5520
268+
protocol: UDP
269+
```
270+
271+
Apply with:
272+
273+
```bash
274+
kubectl apply -f hytale-server-deployment.yaml
275+
```
276+
277+
### Terraform (AWS ECS)
278+
279+
Deploy to AWS ECS using Terraform:
280+
281+
```hcl
282+
# main.tf
283+
terraform {
284+
required_providers {
285+
aws = {
286+
source = "hashicorp/aws"
287+
version = "~> 5.0"
288+
}
289+
}
290+
}
291+
292+
provider "aws" {
293+
region = var.aws_region
294+
}
295+
296+
variable "aws_region" {
297+
default = "us-east-1"
298+
}
299+
300+
variable "hytale_session_token" {
301+
sensitive = true
302+
}
303+
304+
variable "hytale_identity_token" {
305+
sensitive = true
306+
}
307+
308+
variable "hytale_owner_uuid" {
309+
sensitive = true
310+
}
311+
312+
resource "aws_ecs_cluster" "hytale" {
313+
name = "hytale-server-cluster"
314+
}
315+
316+
resource "aws_ecs_task_definition" "hytale_server" {
317+
family = "hytale-server"
318+
network_mode = "awsvpc"
319+
requires_compatibilities = ["FARGATE"]
320+
cpu = "2048"
321+
memory = "4096"
322+
323+
container_definitions = jsonencode([
324+
{
325+
name = "hytale-server"
326+
image = "ghcr.io/<username>/hytale-server-docker:latest"
327+
essential = true
328+
329+
portMappings = [
330+
{
331+
containerPort = 5520
332+
hostPort = 5520
333+
protocol = "udp"
334+
}
335+
]
336+
337+
environment = [
338+
{
339+
name = "HYTALE_SERVER_SESSION_TOKEN"
340+
value = var.hytale_session_token
341+
},
342+
{
343+
name = "HYTALE_SERVER_IDENTITY_TOKEN"
344+
value = var.hytale_identity_token
345+
},
346+
{
347+
name = "HYTALE_SERVER_OWNER_UUID"
348+
value = var.hytale_owner_uuid
349+
}
350+
]
351+
352+
logConfiguration = {
353+
logDriver = "awslogs"
354+
options = {
355+
"awslogs-group" = "/ecs/hytale-server"
356+
"awslogs-region" = var.aws_region
357+
"awslogs-stream-prefix" = "ecs"
358+
}
359+
}
360+
}
361+
])
362+
}
363+
364+
resource "aws_cloudwatch_log_group" "hytale" {
365+
name = "/ecs/hytale-server"
366+
retention_in_days = 7
367+
}
368+
369+
resource "aws_ecs_service" "hytale_server" {
370+
name = "hytale-server"
371+
cluster = aws_ecs_cluster.hytale.id
372+
task_definition = aws_ecs_task_definition.hytale_server.arn
373+
desired_count = 1
374+
launch_type = "FARGATE"
375+
376+
network_configuration {
377+
subnets = var.subnet_ids
378+
security_groups = [aws_security_group.hytale.id]
379+
assign_public_ip = true
380+
}
381+
}
382+
383+
resource "aws_security_group" "hytale" {
384+
name = "hytale-server-sg"
385+
description = "Security group for Hytale server"
386+
vpc_id = var.vpc_id
387+
388+
ingress {
389+
from_port = 5520
390+
to_port = 5520
391+
protocol = "udp"
392+
cidr_blocks = ["0.0.0.0/0"]
393+
}
394+
395+
egress {
396+
from_port = 0
397+
to_port = 0
398+
protocol = "-1"
399+
cidr_blocks = ["0.0.0.0/0"]
400+
}
401+
}
402+
403+
variable "vpc_id" {
404+
description = "VPC ID for the ECS service"
405+
}
406+
407+
variable "subnet_ids" {
408+
description = "Subnet IDs for the ECS service"
409+
type = list(string)
410+
}
411+
412+
output "cluster_name" {
413+
value = aws_ecs_cluster.hytale.name
414+
}
415+
```
416+
417+
Deploy with:
418+
419+
```bash
420+
terraform init
421+
terraform apply \
422+
-var="hytale_session_token=<your-token>" \
423+
-var="hytale_identity_token=<your-token>" \
424+
-var="hytale_owner_uuid=<your-uuid>" \
425+
-var="vpc_id=vpc-xxxxx" \
426+
-var="subnet_ids=[\"subnet-xxxxx\"]"
427+
```
428+
429+
### Ansible
430+
431+
Deploy to a remote server using Ansible:
432+
433+
```yaml
434+
# playbook.yml
435+
---
436+
- name: Deploy Hytale Server
437+
hosts: game_servers
438+
become: yes
439+
vars:
440+
hytale_server_port: 5520
441+
hytale_data_path: /opt/hytale
442+
hytale_image: "ghcr.io/<username>/hytale-server-docker:latest"
443+
vars_prompt:
444+
- name: hytale_session_token
445+
prompt: "Enter Hytale session token"
446+
private: yes
447+
- name: hytale_identity_token
448+
prompt: "Enter Hytale identity token"
449+
private: yes
450+
- name: hytale_owner_uuid
451+
prompt: "Enter Hytale owner UUID"
452+
private: no
453+
454+
tasks:
455+
- name: Install Docker dependencies
456+
apt:
457+
name:
458+
- docker.io
459+
- docker-compose-plugin
460+
state: present
461+
update_cache: yes
462+
463+
- name: Start and enable Docker service
464+
systemd:
465+
name: docker
466+
state: started
467+
enabled: yes
468+
469+
- name: Create Hytale data directories
470+
file:
471+
path: "{{ hytale_data_path }}/{{ item }}"
472+
state: directory
473+
mode: "0755"
474+
loop:
475+
- universe
476+
- mods
477+
- logs
478+
479+
- name: Pull Hytale server image
480+
community.docker.docker_image:
481+
name: "{{ hytale_image }}"
482+
source: pull
483+
484+
- name: Deploy Hytale server container
485+
community.docker.docker_container:
486+
name: hytale-server
487+
image: "{{ hytale_image }}"
488+
state: started
489+
restart_policy: unless-stopped
490+
ports:
491+
- "{{ hytale_server_port }}:5520/udp"
492+
env:
493+
HYTALE_SERVER_SESSION_TOKEN: "{{ hytale_session_token }}"
494+
HYTALE_SERVER_IDENTITY_TOKEN: "{{ hytale_identity_token }}"
495+
HYTALE_SERVER_OWNER_UUID: "{{ hytale_owner_uuid }}"
496+
volumes:
497+
- "{{ hytale_data_path }}/universe:/app/universe"
498+
- "{{ hytale_data_path }}/mods:/app/mods"
499+
- "{{ hytale_data_path }}/logs:/app/logs"
500+
501+
- name: Configure firewall for Hytale
502+
ufw:
503+
rule: allow
504+
port: "{{ hytale_server_port }}"
505+
proto: udp
506+
```
507+
508+
Create an inventory file:
509+
510+
```ini
511+
# inventory.ini
512+
[game_servers]
513+
hytale-server-1 ansible_host=192.168.1.100 ansible_user=ubuntu
514+
```
515+
516+
Run the playbook:
517+
518+
```bash
519+
ansible-playbook -i inventory.ini playbook.yml
520+
```
521+
168522
## System Requirements
169523

170524
| Resource | Recommendation |

0 commit comments

Comments
 (0)