From 635d1cda01038217247e981dc2f4147b186a9a91 Mon Sep 17 00:00:00 2001 From: Benedikt Iltisberger Date: Tue, 23 Jan 2024 10:48:06 +0100 Subject: [PATCH 1/2] fix: added basic yamls for kubernetes support. --- k8s/deployment.yaml | 54 +++++++++++++++++++++++++++++++++++++++++++++ k8s/pvc.yaml | 15 +++++++++++++ k8s/readme.md | 5 +++++ k8s/service.yaml | 24 ++++++++++++++++++++ 4 files changed, 98 insertions(+) create mode 100644 k8s/deployment.yaml create mode 100644 k8s/pvc.yaml create mode 100644 k8s/readme.md create mode 100644 k8s/service.yaml diff --git a/k8s/deployment.yaml b/k8s/deployment.yaml new file mode 100644 index 000000000..b93f6c3a8 --- /dev/null +++ b/k8s/deployment.yaml @@ -0,0 +1,54 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: palworld-server + name: palworld-server + namespace: default +spec: + replicas: 1 + selector: + matchLabels: + app: palworld-server + template: + metadata: + labels: + app: palworld-server + spec: + containers: + - env: + - name: "PLAYERS" + value: "16" + - name: "PORT" + value: "8211" + - name: "MULTITHREADING" + value: "true" + - name: "COMMUNITY" + value: "true" + - name: "SERVER_NAME" + value: "YOUR SERVER NAME" + - name: "ADMIN_PASSWORD" + value: "YOURPASSWORD" + - name: "UPDATE_ON_BOOT" + value: "true" + image: thijsvanloef/palworld-server-docker + imagePullPolicy: IfNotPresent + name: palworld-server + ports: + - containerPort: 8211 + name: "8211-palworld" + protocol: UDP + - containerPort: 27015 + name: "27015-palworld" + protocol: UDP + resources: + requests: + cpu: 500m + memory: 512Mi + volumeMounts: + - mountPath: /palworld + name: datadir + volumes: + - name: datadir + persistentVolumeClaim: + claimName: palworld-server-datadir \ No newline at end of file diff --git a/k8s/pvc.yaml b/k8s/pvc.yaml new file mode 100644 index 000000000..63470cce0 --- /dev/null +++ b/k8s/pvc.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + labels: + app: palworld-server + name: palworld-server-datadir + namespace: default +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 10Gi + storageClassName: local-path + volumeMode: Filesystem \ No newline at end of file diff --git a/k8s/readme.md b/k8s/readme.md new file mode 100644 index 000000000..56c8f5727 --- /dev/null +++ b/k8s/readme.md @@ -0,0 +1,5 @@ +# Setup Palworld in kubernetes + +kubectl apply -f pvc.yaml +kubectl apply -f service.yaml +kubectl apply -f deployment.yaml \ No newline at end of file diff --git a/k8s/service.yaml b/k8s/service.yaml new file mode 100644 index 000000000..25b970a00 --- /dev/null +++ b/k8s/service.yaml @@ -0,0 +1,24 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + app: palworld-server + name: palworld-server + namespace: default +spec: + externalTrafficPolicy: Cluster + internalTrafficPolicy: Cluster + ipFamilies: + - IPv4 + ports: + - name: palworld1 + port: 8211 + protocol: UDP + targetPort: 8211 + - name: palworld2 + port: 27015 + protocol: UDP + targetPort: 27015 + selector: + app: palworld-server + type: LoadBalancer \ No newline at end of file From 280b77d9dd19c02797893d0aec30cf768e367ef4 Mon Sep 17 00:00:00 2001 From: Benedikt Iltisberger Date: Wed, 24 Jan 2024 09:05:00 +0100 Subject: [PATCH 2/2] fix: minor improvements. --- k8s/configmap.yaml | 16 +++++++++++++ k8s/deployment.yaml | 55 ++++++++++++++++++--------------------------- k8s/pvc.yaml | 5 +---- k8s/readme.md | 2 ++ k8s/secret.yaml | 7 ++++++ k8s/service.yaml | 13 ++++------- 6 files changed, 52 insertions(+), 46 deletions(-) create mode 100644 k8s/configmap.yaml create mode 100644 k8s/secret.yaml diff --git a/k8s/configmap.yaml b/k8s/configmap.yaml new file mode 100644 index 000000000..41785c39a --- /dev/null +++ b/k8s/configmap.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: palworld-cm +data: + PUID: "1000" + PGID: "1000" + PORT: "8211" # Optional but recommended + PLAYERS: "16" # Optional but recommended + MULTITHREADING: "true" + RCON_ENABLED: "true" + RCON_PORT: "25575" + COMMUNITY: "false" # Enable this if you want your server to show up in the community servers tab, USE WITH SERVER_PASSWORD! + # Enable the environment variables below if you have COMMUNITY=true + # SERVER_PASSWORD: "yourServerPassword" + SERVER_NAME: "Server_Name" # Note, it seems spaces are not supported, so use underlines. \ No newline at end of file diff --git a/k8s/deployment.yaml b/k8s/deployment.yaml index b93f6c3a8..3169897fd 100644 --- a/k8s/deployment.yaml +++ b/k8s/deployment.yaml @@ -4,7 +4,6 @@ metadata: labels: app: palworld-server name: palworld-server - namespace: default spec: replicas: 1 selector: @@ -16,38 +15,28 @@ spec: app: palworld-server spec: containers: - - env: - - name: "PLAYERS" - value: "16" - - name: "PORT" - value: "8211" - - name: "MULTITHREADING" - value: "true" - - name: "COMMUNITY" - value: "true" - - name: "SERVER_NAME" - value: "YOUR SERVER NAME" - - name: "ADMIN_PASSWORD" - value: "YOURPASSWORD" - - name: "UPDATE_ON_BOOT" - value: "true" - image: thijsvanloef/palworld-server-docker - imagePullPolicy: IfNotPresent - name: palworld-server - ports: - - containerPort: 8211 - name: "8211-palworld" - protocol: UDP - - containerPort: 27015 - name: "27015-palworld" - protocol: UDP - resources: - requests: - cpu: 500m - memory: 512Mi - volumeMounts: - - mountPath: /palworld - name: datadir + - name: palworld-server + image: thijsvanloef/palworld-server-docker + imagePullPolicy: IfNotPresent + ports: + - containerPort: 8211 + name: 8211-palworld + protocol: UDP + - containerPort: 27015 + name: 27015-palworld + protocol: UDP + env: + - name: ADMIN_PASSWORD + valueFrom: + secretKeyRef: + name: palworld-secrets + key: rconPassword + envFrom: + - configMapRef: + name: palworld-cm + volumeMounts: + - mountPath: /palworld + name: datadir volumes: - name: datadir persistentVolumeClaim: diff --git a/k8s/pvc.yaml b/k8s/pvc.yaml index 63470cce0..db0ce456c 100644 --- a/k8s/pvc.yaml +++ b/k8s/pvc.yaml @@ -4,12 +4,9 @@ metadata: labels: app: palworld-server name: palworld-server-datadir - namespace: default spec: accessModes: - ReadWriteOnce resources: requests: - storage: 10Gi - storageClassName: local-path - volumeMode: Filesystem \ No newline at end of file + storage: 10Gi \ No newline at end of file diff --git a/k8s/readme.md b/k8s/readme.md index 56c8f5727..b5ed4cb44 100644 --- a/k8s/readme.md +++ b/k8s/readme.md @@ -1,5 +1,7 @@ # Setup Palworld in kubernetes kubectl apply -f pvc.yaml +kubectl apply -f configmap.yaml +kubectl apply -f secret.yaml kubectl apply -f service.yaml kubectl apply -f deployment.yaml \ No newline at end of file diff --git a/k8s/secret.yaml b/k8s/secret.yaml new file mode 100644 index 000000000..e4301e30f --- /dev/null +++ b/k8s/secret.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: Secret +metadata: + name: palworld-secrets +type: Opaque +stringData: + rconPassword: yourRconPassword \ No newline at end of file diff --git a/k8s/service.yaml b/k8s/service.yaml index 25b970a00..41c8b15df 100644 --- a/k8s/service.yaml +++ b/k8s/service.yaml @@ -4,21 +4,16 @@ metadata: labels: app: palworld-server name: palworld-server - namespace: default spec: - externalTrafficPolicy: Cluster - internalTrafficPolicy: Cluster - ipFamilies: - - IPv4 ports: - - name: palworld1 + - name: 8211-palworld port: 8211 protocol: UDP - targetPort: 8211 - - name: palworld2 + targetPort: 8211-palworld + - name: 27015-palworld port: 27015 protocol: UDP - targetPort: 27015 + targetPort: 27015-palworld selector: app: palworld-server type: LoadBalancer \ No newline at end of file