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
6 changes: 6 additions & 0 deletions charts/hytale-server/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: hytale-server
description: Helm chart for Hytale server (Docker by indifferentbroccoli)
type: application
version: 0.1.0
appVersion: 'v1.0.6'
96 changes: 96 additions & 0 deletions charts/hytale-server/MIGRATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Hytale Server Migration Guide

This guide explains how to migrate your existing Hytale server data to a new server managed by the Hytale Server Helm Chart.

## Prerequisites

* You have `kubectl` installed and configured to connect to your Kubernetes cluster.
* You have an existing Hytale server with data you want to migrate.
* You have a PersistentVolumeClaim (PVC) with your Hytale server data.

## Migration Steps

### 1. Find the name of your existing PVC

First, you need to find the name of the PersistentVolumeClaim that your existing Hytale server uses. You can list all PVCs in your namespace with the following command:

```bash
kubectl get pvc
```

Identify the name of the PVC that contains your Hytale server data.

### 2. Update the `migration-pod.yaml`

Open the `migration-pod.yaml` file and replace `<DEIN-PVC-NAME>` with the actual name of your PVC that you found in the previous step.

For example, if your PVC is named `my-hytale-server-data`, the file should look like this:

```yaml
apiVersion: v1
kind: Pod
metadata:
name: hytale-server-migration
spec:
containers:
- name: migration-container
image: busybox
command: ["/bin/sh", "-c", "sleep 3600"]
volumeMounts:
- name: hytale-data
mountPath: /data
volumes:
- name: hytale-data
persistentVolumeClaim:
claimName: my-hytale-server-data
```

### 3. Deploy the migration pod

Now, deploy the migration pod to your Kubernetes cluster:

```bash
kubectl apply -f migration-pod.yaml
```

This will create a new pod named `hytale-server-migration` that mounts your existing PVC at `/data`.

### 4. Access the migration pod

Once the pod is running, you can get a shell inside the container:

```bash
kubectl exec -it hytale-server-migration -- /bin/sh
```

You are now inside the migration pod. Your Hytale server data is available in the `/data` directory.

### 5. Install and deploy the new Hytale Server via Helm

Install the Hytale Server Helm chart in the same namespace. Make sure that the `persistence.existingClaim` value in your `values.yaml` is set to the name of your PVC.

Example `values.yaml`:
```yaml
persistence:
enabled: true
existingClaim: <DEIN-PVC-NAME> # Replace with your PVC name
...
```

Then install the chart:

```bash
helm install hytale-server ./charts/hytale-server -f values.yaml
```

The new Hytale server pod will now start and use your existing data.

### 6. Clean up

After you have successfully migrated your data and the new Hytale server is running correctly, you can delete the migration pod:

```bash
kubectl delete pod hytale-server-migration
```

You have now successfully migrated your Hytale server data.
17 changes: 17 additions & 0 deletions charts/hytale-server/migration-pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
kind: Pod
metadata:
name: hytale-server-migration
namespace: hytale-server
spec:
containers:
- name: migration-container
image: busybox
command: ['/bin/sh', '-c', 'sleep 3600']
volumeMounts:
- name: hytale-data
mountPath: /data
volumes:
- name: hytale-data
persistentVolumeClaim:
claimName: hytale-server
15 changes: 15 additions & 0 deletions charts/hytale-server/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Congratulations! Your Hyatale server has been successfully deployed.

To access your Hytale server, use the following information:

Service Name: {{ .Release.Name }}-{{ .Chart.Name }}
Namespace: {{ .Release.Namespace }}

The Hytale server does use the following port:
- UDP: 5520

After a view seconds check the logs to authenticate the server:
kubectl logs -n {{ .Release.Namespace }} deployments/{{ include "hytale-server.name" . }}-server

Further information and configuration options can be found in the README of the project:
https://github.com/indifferentbroccoli/hytale-server-docker
40 changes: 40 additions & 0 deletions charts/hytale-server/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "hytale-server.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Define the namespace where the chart will be installed.
*/}}
{{- define "hytale-server.namespace" -}}
{{- default .Release.Namespace .Values.namespaceOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "hytale-server.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "hytale-server.labels" -}}
helm.sh/chart: {{ include "hytale-server.chart" . }}
{{ include "hytale-server.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "hytale-server.selectorLabels" -}}
app.kubernetes.io/name: {{ include "hytale-server.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
15 changes: 15 additions & 0 deletions charts/hytale-server/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "hytale-server.name" . }}-config
labels: {{- include "hytale-server.labels" . | nindent 4 }}
data:
{{- range $key, $value := .Values.hytaleConfig }}
{{- if ne $key "MAX_MEMORY" }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end }}
{{- /* Logic for MAX_MEMORY: Use hytaleConfig override OR (limits.memory - 1) */ -}}
{{- $limitInt := .Values.resources.limits.memory | toString | replace "Gi" "" | replace "G" "" | int }}
MAX_MEMORY: {{ .Values.hytaleConfig.MAX_MEMORY | default (printf "%dG" (sub $limitInt 1)) | quote }}
DEFAULT_PORT: {{ .Values.service.port | quote }}
44 changes: 44 additions & 0 deletions charts/hytale-server/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "hytale-server.name" . }}-server
namespace: {{ include "hytale-server.namespace" . }}
labels: {{- include "hytale-server.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicas }}
strategy:
type: Recreate
selector:
matchLabels: {{- include "hytale-server.selectorLabels" . | nindent 8 }}
template:
metadata:
labels: {{- include "hytale-server.labels" . | nindent 10 }}
spec:
containers:
- name: hytale
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
tty: true
stdin: true
ports:
- containerPort: {{ .Values.service.port }}
{{- if .Values.useHostPort }}
hostPort: {{ .Values.service.port }}
{{- end }}
protocol: UDP
envFrom:
- configMapRef:
name: {{ include "hytale-server.name" . }}-config
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- name: data
mountPath: /home/hytale/server-files
volumes:
- name: data
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ include "hytale-server.name" . }}
{{- else }}
emptyDir: {}
{{- end }}
20 changes: 20 additions & 0 deletions charts/hytale-server/templates/gateway.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{- if .Values.gateway.create }}
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: {{ include "hytale-server.name" . }}
labels: {{- include "hytale-server.labels" . | nindent 4 }}
spec:
gatewayClassName: {{ .Values.gateway.className }}
listeners:
{{- range .Values.gateway.listeners }}
- name: {{ .name }}
port:
protocol: UDP
allowedRoutes:
namespaces:
from: {{ include "hytale-server.namespace" . }}
kinds:
- kind: UDPRoute
{{- end }}
{{- end }}
25 changes: 25 additions & 0 deletions charts/hytale-server/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{- if .Values.persistence.enabled }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ include "hytale-server.name" . }}
namespace: {{ include "hytale-server.namespace" . }}
labels:
{{- include "hytale-server.labels" . | nindent 4 }}
{{- with .Values.persistence.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.persistence.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
accessModes:
- {{ .Values.persistence.accessMode }}
{{- if .Values.persistence.storageClassName }}
storageClassName: {{ .Values.persistence.storageClassName }}
{{- end }}
resources:
requests:
storage: {{ .Values.persistence.size }}
{{- end }}
13 changes: 13 additions & 0 deletions charts/hytale-server/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "hytale-server.name" . }}
namespace: {{ include "hytale-server.namespace" . }}
labels: {{- include "hytale-server.labels" . | nindent 4 }}
spec:
selector: {{- include "hytale-server.selectorLabels" . | nindent 4 }}
type: {{ .Values.service.type }}
ports:
- protocol: UDP
port: {{ .Values.service.port }}
targetPort: {{ .Values.service.port }}
28 changes: 28 additions & 0 deletions charts/hytale-server/templates/tests/connection-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "hytale-server.name" . }}-test-connection"
namespace: {{ include "hytale-server.namespace" . }}
labels:
{{- include "hytale-server.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
"helm.sh/hook-delete-policy": hook-succeeded,hook-failed
spec:
containers:
- name: nc
image: busybox:1.36
command: ['/bin/sh', '-c']
args:
- |
echo "Attempting to connect to UDP service {{ include "hytale-server.name" . }}:{{ .Values.service.port }}..."
# The -w flag sets a timeout. -z scans for listening daemons without sending data. -u is for UDP.
nc -w 5 -z -u {{ include "hytale-server.name" . }} {{ .Values.service.port }}
if [ $? -eq 0 ]; then
echo "Success: Service is reachable on UDP port {{ .Values.service.port }}."
exit 0
else
echo "Failure: Could not connect to service on UDP port {{ .Values.service.port }}."
exit 1
fi
restartPolicy: Never
25 changes: 25 additions & 0 deletions charts/hytale-server/templates/udproute.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{- if .Values.udpRoute.enabled }}
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: UDPRoute
metadata:
name: {{ include "hytale-server.name" . }}
namespace: {{ include "hytale-server.namespace" . }}
labels: {{- include "hytale-server.labels" . | nindent 4 }}
spec:
parentRefs:
{{- range .Values.udpRoute.parentRefs }}
- name: {{ .name }}
{{- if .sectionName }}
sectionName: {{ .sectionName }}
{{- end }}
{{- if .namespace }}
namespace: {{ .namespace }}
{{- end }}
{{- end }}
rules:
- backendRefs:
- name: {{ include "hytale-server.name" . }}
port: {{ .Values.service.port }}
group: ""
kind: Service
{{- end }}
Loading