From 8846070b5366b3a1ca0ed4e5359afe617aab243e Mon Sep 17 00:00:00 2001 From: Twinki Date: Thu, 8 Feb 2024 21:33:41 -0500 Subject: [PATCH 01/10] Remove helm chart --- .github/workflows/release.yml | 34 +-- README.md | 2 +- charts/cr.yaml | 2 - charts/palworld/Chart.yaml | 37 --- charts/palworld/README.md | 32 --- charts/palworld/VALUES_SUMMARY.md | 80 ------- charts/palworld/templates/configmaps.yaml | 77 ------ charts/palworld/templates/cronjob.yaml | 37 --- charts/palworld/templates/deployments.yaml | 77 ------ charts/palworld/templates/pvcs.yaml | 31 --- charts/palworld/templates/role.yaml | 14 -- charts/palworld/templates/rolebinding.yaml | 15 -- charts/palworld/templates/secrets.yaml | 25 -- charts/palworld/templates/serviceaccount.yaml | 7 - charts/palworld/templates/services.yaml | 34 --- charts/palworld/values.yaml | 224 ------------------ 16 files changed, 2 insertions(+), 726 deletions(-) delete mode 100644 charts/cr.yaml delete mode 100644 charts/palworld/Chart.yaml delete mode 100644 charts/palworld/README.md delete mode 100644 charts/palworld/VALUES_SUMMARY.md delete mode 100644 charts/palworld/templates/configmaps.yaml delete mode 100644 charts/palworld/templates/cronjob.yaml delete mode 100644 charts/palworld/templates/deployments.yaml delete mode 100644 charts/palworld/templates/pvcs.yaml delete mode 100644 charts/palworld/templates/role.yaml delete mode 100644 charts/palworld/templates/rolebinding.yaml delete mode 100644 charts/palworld/templates/secrets.yaml delete mode 100644 charts/palworld/templates/serviceaccount.yaml delete mode 100644 charts/palworld/templates/services.yaml delete mode 100644 charts/palworld/values.yaml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bd41022f3..63e7d5ccd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,6 +1,6 @@ --- name: Release -on: # yamllint disable-line rule:truthy +on: # yamllint disable-line rule:truthy release: types: [published] @@ -80,35 +80,3 @@ jobs: platforms: linux/arm64 push: true tags: ${{ steps.meta.outputs.tags }} - - # Generates a new release specifically for the helm chart, using the helm charts version - # Only generates a new release if the helm charts version has changed since the last release - # Will then update the gh-pages branch & helm repository - release-helm: - name: Release - Helm chart - runs-on: ubuntu-latest - permissions: - contents: write - pages: write - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Git - Configure - run: | - git config user.name "$GITHUB_ACTOR" - git config user.email "$GITHUB_ACTOR@users.noreply.github.com" - - # Will push updates to a index.yaml file in the gh-pages branch - - name: Helm - chart-releaser - uses: helm/chart-releaser-action@v1.6.0 - with: - charts_dir: charts - pages_branch: gh-pages - mark_as_latest: false - skip_existing: true - config: ./charts/cr.yaml - env: - CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/README.md b/README.md index 63ca9f12d..c488dee4d 100644 --- a/README.md +++ b/README.md @@ -161,7 +161,7 @@ Follow the steps in the [README.md here](k8s/readme.md) to deploy it. #### Using helm chart -Follow up the docs on the [README.md for the helm chart](./charts/palworld/README.md) to deploy. +The official helm chart can be found in a seperate repository, [palworld-server-chart](https://github.com/Twinki14/palworld-server-chart) ### Environment variables diff --git a/charts/cr.yaml b/charts/cr.yaml deleted file mode 100644 index d7790b91a..000000000 --- a/charts/cr.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -release-name-template: "chart-{{ .Version }}" diff --git a/charts/palworld/Chart.yaml b/charts/palworld/Chart.yaml deleted file mode 100644 index 4bac46cd0..000000000 --- a/charts/palworld/Chart.yaml +++ /dev/null @@ -1,37 +0,0 @@ ---- -apiVersion: v2 -name: palworld -version: 0.1.0 -description: This chart will provide a Palworld server installation on a kubernetes cluster -type: application -keywords: - - palworld - - server - - kubernetes - - helm -home: https://github.com/thijsvanloef/palworld-server-docker -sources: - - https://github.com/thijsvanloef/palworld-server-docker -maintainers: - - name: Filipe Souza - email: filipe.souza@mestre8d.com - url: https://github.com/Filipe-Souza - - name: Twinki - url: https://github.com/Twinki14 -icon: https://cdn.akamai.steamstatic.com/steam/apps/1623730/header.jpg -appVersion: "latest" -deprecated: false -annotations: - artifacthub.io/alternativeName: palworld-server - artifacthub.io/license: MIT - artifacthub.io/links: | - - name: Chart source - url: https://github.com/thijsvanloef/palworld-server-docker/tree/main/charts/palworld - - name: Docker image source - url: https://github.com/thijsvanloef/palworld-server-docker - artifacthub.io/images: | - - name: palworld-server-docker - image: thijsvanloef/palworld-server-docker:latest - artifacthub.io/screenshots: | - - title: PalWorld - url: https://cdn.akamai.steamstatic.com/steam/apps/1623730/header.jpg diff --git a/charts/palworld/README.md b/charts/palworld/README.md deleted file mode 100644 index 81d7b7f68..000000000 --- a/charts/palworld/README.md +++ /dev/null @@ -1,32 +0,0 @@ -# Palworld Helm Chart - -Allows you to deploy the usage of [Palworld Server docker](https://github.com/Filipe-Souza/palworld-server-docker) as -a helm chart and with helm deployments. - -This is an advanced method of installation and can be quite difficult to non-technical trying to set it up. - -## Dependencies - -You will need the [Helm client](https://helm.sh/docs/intro/install/) and a Kubernetes cluster. - -## Install the chart - -There is no helm package available yet, so you need to clone this repo and setup it manually, or with some GitOps tool -like ArgoCD/FluxCD. - -After cloning the repository, you can create a new file, e.g.: values.override.yaml to store your custom values. - -After copying, modify your values.override.yaml as needed. You can look up the -[values summary](VALUES_SUMMARY.md) to see the parameter documentation. - -After that, you can apply the chart: - -```bash -helm install --create-namespace --namespace palworld palworld chart/ --values values.override.yaml -``` - -You can remove all the resources created (except the PVC) with the following command: - -```bash -helm uninstall -n palworld palworld -``` diff --git a/charts/palworld/VALUES_SUMMARY.md b/charts/palworld/VALUES_SUMMARY.md deleted file mode 100644 index 02aa0cc0c..000000000 --- a/charts/palworld/VALUES_SUMMARY.md +++ /dev/null @@ -1,80 +0,0 @@ -# palworld - -![Version: 0.0.2](https://img.shields.io/badge/Version-0.0.2-informational?style=flat-square) -![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) -![AppVersion: latest](https://img.shields.io/badge/AppVersion-latest-informational?style=flat-square) - -This chart will provide a Palworld server installation on a kubernetes cluster - -**Homepage:** - -## Maintainers - -| Name | Email | Url | -| ---- | ------ | --- | -| Filipe Souza | | | -| Twinki | | | - -## Source Code - -* - -## Values - -| Key | Type | Default | Description | -|-----|------|---------|-------------| -| namespace | string | `"palworld"` | Namespace where the resources will be created | -| server | dict | | The server configuration | -| server.annotations | object | `{}` | Additional annotations to the resources | -| server.config | dict | | Change the game server configuration. If you change those, make sure to change the service.ports and server.ports accordingly. Those are directly connected with the container image, providing multiple environment variables to the scripts. | -| server.config.annotations | object | `{}` | Additional annotations to the resources | -| server.config.community.enable | bool | `true` | Enables/disables the visibility of this server on Steam community servers list. | -| server.config.community.password | string | `""` | If not provided, a random password will be generated and stored on the secret. | -| server.config.daily_reboot.enable | bool | `false` | Enable daily reboot. Disabled by default | -| server.config.daily_reboot.role | string | `"daily-reboot"` | The name of the role performing the daily reboot. | -| server.config.daily_reboot.serviceAccount | string | `"daily-reboot"` | The name of the Service Account used to perform the reboot. | -| server.config.daily_reboot.time | string | `"30 9 * * *"` | The time (UTC) the server will perform the reboot. By default, this schedules the restart at 9:30am UTC. Please note, this is using cron syntax. | -| server.config.labels | object | `{}` | Additional labels to the resources | -| server.config.max_players | int | `16` | The max number of players supported. | -| server.config.multithreading | bool | `true` | Enables the multithreading, allowing the usage of up to 4 cores (needs citation) | -| server.config.public_ip | string | `""` | You can manually specify the global IP address of the network on which the server running. If not specified, it will be detected automatically. If it does not work well, try manual configuration. | -| server.config.public_port | string | `""` | You can manually specify the port number of the network on which the server running. If not specified, it will be detected automatically. If it does not work well, try manual configuration. | -| server.config.query_port | string | `27015` | The query port of the game. | -| server.config.rcon | dict | | Remote connection configuration. Allows the remote connection and management for the server. Those are directly connected with the container image, providing multiple environment variables to the scripts. | -| server.config.rcon.enable | bool | `true` | Enables/disables the rcon port. | -| server.config.rcon.password | string | `""` | If not provided, a random password will be generated and stored on the secret. | -| server.config.rcon.port | string | `25575` | The port for rcon. If you change this, make sure to change the service.ports and server.ports accordingly. | -| server.config.server_description | string | `""` | Your server description to be shown in game | -| server.config.timezone | string | `"UTC"` | The timezone used for time stamping backup server. Use the IANA TZ format with Area/Location See the [list of TZ database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#Time_Zone_abbreviations) | -| server.config.update_on_boot | string | `true` | Update/Install the server when the container starts. THIS HAS TO BE ENABLED THE FIRST TIME YOU RUN THE CONTAINER | -| server.config.world_parameters | object | | Configures the game world settings. The key:values here should represent in game accepted values. Wrap all values with quotes here to avoid validation issues. | -| server.image | dict | | Define the parameters for the server image container | -| server.image.imagePullPolicy | string | `"IfNotPresent"` | Define the pull policy for the server image. | -| server.image.repository | string | `"thijsvanloef/palworld-server-docker"` | Repository of the image, without the tag. | -| server.image.tag | string | `"latest"` | The tag of the image. | -| server.labels | object | `{}` | Additional labels to the resources | -| server.ports | dict | | Change the ports to be mapped to the pod. If you change those, make sure to change the service.ports and server.config accordingly. | -| server.ports[0] | dict | `{"containerPort":8211,"name":"game","protocol":"UDP"}` | The "game" port definition. If you change this, make sure to change the service.ports.game and server.config accordingly. | -| server.ports[1] | dict | `{"containerPort":27015,"name":"query","protocol":"UDP"}` | The "query" port definition . If you change this, make sure to change the service.ports.query_port and server.config accordingly. | -| server.ports[2] | dict | `{"containerPort":25575,"name":"rcon","protocol":"UDP"}` | The "rcon" port definition . If you change this, make sure to change the service.ports.rcon and server.config accordingly. | -| server.resources | dict | `{"limits":{"cpu":4,"memory":"12Gi"},"requests":{"cpu":4,"memory":"8Gi"}}` | Resources limits for the container. | -| server.service | dict | | Change the service configuration. If you change those, make sure to change the server.config and server.ports accordingly. | -| server.service.annotations | object | `{}` | Additional annotations to the resources | -| server.service.enabled | bool | `true` | Enables the creation of the service component. | -| server.service.healthz | dict | `{"enabled":false,"name":"healthz","port":80,"protocol":"TCP","targetPort":80}` | The "healthz" definition . Use if you need to create a TCP health check for load balancers on cloud services. | -| server.service.labels | object | `{}` | Additional labels to the resources | -| server.service.ports | dict | | Change the ports to be mapped to the service. If you change those, make sure to change the server.config and server.ports accordingly. | -| server.service.ports[0] | dict | `{"name":"game","port":8211,"protocol":"UDP","targetPort":8211}` | The "game" port definition. If you change this, make sure to change the server.ports.game and server.config.port accordingly. | -| server.service.ports[1] | dict | `{"name":"query","port":27015,"protocol":"UDP","targetPort":27015}` | The "query" port definition . If you change this, make sure to change the server.ports.query and server.config.query_port accordingly. | -| server.service.ports[2] | dict | `{"name":"rcon","port":25575,"protocol":"UDP","targetPort":25575}` | The "rcon" port definition . If you change this, make sure to change the server.ports.rcon and server.config.rcon.port accordingly. | -| server.service.type | string | `"ClusterIP"` | The type of service to be created. For minikube, set this to NodePort, elsewhere use LoadBalancer Use ClusterIP if your setup includes ingress controller | -| server.storage | dict | `{"external":false,"externalName":"","preventDelete":false,"size":"12Gi","storageClassName":""}` | Define some parameters for the storage volume | -| server.storage.external | bool | `false` | Define if it will use an existing PVC containing the installation data. | -| server.storage.externalName | bool | `""` | The external PVC name to use. | -| server.storage.preventDelete | bool | `false` | Keeps helm from deleting the PVC. By default, helm does not delete pvcs. | -| server.storage.size | string | `"12Gi"` | The size of the pvc storage. | -| server.storage.storageClassName | string | `""` | The storage class name. | -| server.strategy | string | `"Recreate"` | Change the deployment strategy | - ----------------------------------------------- -Autogenerated from chart metadata using [helm-docs v1.11.2](https://github.com/norwoodj/helm-docs/releases/v1.11.2) diff --git a/charts/palworld/templates/configmaps.yaml b/charts/palworld/templates/configmaps.yaml deleted file mode 100644 index c9a73eb19..000000000 --- a/charts/palworld/templates/configmaps.yaml +++ /dev/null @@ -1,77 +0,0 @@ -{{- $cPwd := randAlphaNum 12 | nospace -}} -{{- $sName := "" -}} -apiVersion: v1 -kind: ConfigMap -metadata: - namespace: {{ .Values.namespace }} - name: "{{ .Release.Name }}-env-config" - annotations: - {{- with .Values.server.config.annotations }} - {{- toYaml . | nindent 4 }} - {{- end }} - labels: - helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} - app.kubernetes.io/name: "{{ .Release.Name }}-config" - app.kubernetes.io/managed-by: {{ .Release.Service }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/component: "{{ .Release.Name }}-config" - app.kubernetes.io/version: {{ .Chart.AppVersion }} - {{- with .Values.server.config.labels }} - {{- toYaml . | nindent 4 }} - {{- end }} -data: - PUID: "{{ .Values.server.config.puid }}" - PGID: "{{ .Values.server.config.pgid }}" - PORT: "{{ .Values.server.config.port }}" - PLAYERS: "{{ .Values.server.config.max_players }}" - MULTITHREADING: "{{ .Values.server.config.multithreading }}" - {{ if .Values.server.config.rcon.enable }} - RCON_ENABLED: "true" - RCON_PORT: "{{ .Values.server.config.rcon.port }}" - {{ end }} - {{ if .Values.server.config.community.enable }} - COMMUNITY: "true" - SERVER_PASSWORD: {{- if .Values.server.config.community.password }} "{{ .Values.server.config.community.password }}" {{ else }} {{ $cPwd }} {{ end }} - {{ end }} - {{ if .Values.server.config.server_name }} - SERVER_NAME: {{ regexReplaceAll "\\W+" .Values.server.config.server_name "_" }} - {{ else }} - SERVER_NAME: {{ printf "%s_%s" "palworld" (randAlphaNum 6 | nospace) }} - {{ end }} - TZ: {{ .Values.server.config.timezone }} - PUBLIC_IP: {{ .Values.server.config.public_ip | quote }} - PUBLIC_PORT: {{ .Values.server.config.public_port | quote }} - SERVER_DESCRIPTION: {{ .Values.server.config.server_description }} - UPDATE_ON_BOOT: {{ .Values.server.config.update_on_boot | quote }} - QUERY_PORT: {{ .Values.server.config.query_port | quote }} - {{ if .Values.server.config.world_parameters }} - {{- with .Values.server.config.world_parameters }} - {{- toYaml . | nindent 2 }} - {{- end }} - {{ if .Values.server.config.daily_reboot.enable }} - restart-deployment.sh: | - #!/bin/bash - cont=$(kubectl -n {{ .Values.namespace }} get pods -o=jsonpath='{.items[?(@.metadata.labels.app\.kubernetes\.io/name=="{{ .Release.Name }}-server")].metadata.name}') - - function exec_rcon_cmd() { - kubectl exec -n {{ .Values.namespace }} -i pod/$cont rcon-cli "$1" - } - - exec_rcon_cmd "Broadcast Saving_Server_Data..." - exec_rcon_cmd save - sleep 30 - exec_rcon_cmd "Broadcast Backing_up_Server_Data..." - exec_rcon_cmd backup - sleep 30 - - step=5 - for i in $(seq 30 -$step 1); do - exec_rcon_cmd "Broadcast Rebooting_in_$i_seconds..." - sleep $step - done - - exec_rcon_cmd "Shutdown 1" - sleep 30 - kubectl -n {{ .Values.namespace }} rollout restart deployment/{{ .Release.Name }}-server - {{ end }} - {{ end }} diff --git a/charts/palworld/templates/cronjob.yaml b/charts/palworld/templates/cronjob.yaml deleted file mode 100644 index dbdffb41c..000000000 --- a/charts/palworld/templates/cronjob.yaml +++ /dev/null @@ -1,37 +0,0 @@ -{{ if .Values.server.config.daily_reboot.enable }} -apiVersion: batch/v1 -kind: CronJob -metadata: - name: "{{ .Values.server.config.daily_reboot.serviceAccount }}" - namespace: {{ .Values.namespace }} -spec: - concurrencyPolicy: Forbid - schedule: "{{ .Values.server.config.daily_reboot.time }}" - jobTemplate: - spec: - backoffLimit: 1 - activeDeadlineSeconds: 600 - template: - spec: - serviceAccountName: "{{ .Values.server.config.daily_reboot.serviceAccount }}" - restartPolicy: Never - containers: - - name: kubectl - image: bitnami/kubectl - command: - - /bin/sh - - -c - - /restart-script/restart-deployment.sh - volumeMounts: - - name: restart-script - mountPath: "/restart-script" - readOnly: true - volumes: - - name: restart-script - configMap: - name: "{{ .Release.Name }}-env-config" - defaultMode: 0777 - items: - - key: "restart-deployment.sh" - path: "restart-deployment.sh" -{{ end }} \ No newline at end of file diff --git a/charts/palworld/templates/deployments.yaml b/charts/palworld/templates/deployments.yaml deleted file mode 100644 index 0759d98bd..000000000 --- a/charts/palworld/templates/deployments.yaml +++ /dev/null @@ -1,77 +0,0 @@ ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - namespace: {{ .Values.namespace }} - name: "{{ .Release.Name }}-server" -spec: - selector: - matchLabels: - app.kubernetes.io/component: "{{ .Release.Name }}-server" - strategy: - type: "{{ .Values.server.strategy }}" - template: - metadata: - annotations: - {{- with .Values.server.annotations }} - {{- toYaml . | nindent 4 }} - {{- end }} - labels: - helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} - app.kubernetes.io/name: "{{ .Release.Name }}-server" - app.kubernetes.io/managed-by: {{ .Release.Service }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/component: "{{ .Release.Name }}-server" - app.kubernetes.io/version: {{ .Chart.AppVersion }} - {{- with .Values.server.labels }} - {{- toYaml . | nindent 4 }} - {{- end }} - spec: - containers: - {{ if .Values.server.service.healthz.enabled }} - - name: healthz - image: "chussenot/tiny-server:latest" - imagePullPolicy: {{ .Values.server.image.imagePullPolicy }} - ports: - - name: healthz - containerPort: 80 - protocol: TCP - {{ end }} - - name: server - image: "{{ .Values.server.image.repository }}:{{ .Values.server.image.tag }}" - imagePullPolicy: {{ .Values.server.image.imagePullPolicy }} - lifecycle: - preStop: - exec: - command: - - "sh" - - "-c" - - rcon-cli save && backup - resources: - {{- with .Values.server.resources }} - {{- toYaml . | nindent 12 }} - {{- end }} - ports: - {{- with .Values.server.ports }} - {{- toYaml . | nindent 12 }} - {{- end }} - env: - - name: ADMIN_PASSWORD - valueFrom: - secretKeyRef: - name: "{{ .Release.Name }}-rcon-password" - key: "rconPassword" - envFrom: - - configMapRef: - name: "{{ .Release.Name }}-env-config" - volumeMounts: - - mountPath: /palworld - name: datadir - volumes: - - name: datadir - persistentVolumeClaim: - {{- if not .Values.server.storage.external }} - claimName: "{{ .Release.Name }}-datadir-pvc" - {{ else }} - claimName: "{{ .Values.server.storage.externalName }}" - {{ end }} diff --git a/charts/palworld/templates/pvcs.yaml b/charts/palworld/templates/pvcs.yaml deleted file mode 100644 index 4ece1da36..000000000 --- a/charts/palworld/templates/pvcs.yaml +++ /dev/null @@ -1,31 +0,0 @@ -{{- if not .Values.server.storage.external }} -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - namespace: {{ .Values.namespace }} - name: "{{ .Release.Name }}-datadir-pvc" - annotations: - {{- with .Values.server.config.annotations }} - {{- toYaml . | nindent 4 }} - {{- end }} - labels: - helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} - app.kubernetes.io/name: "{{ .Release.Name }}-datadir-pvc" - app.kubernetes.io/managed-by: {{ .Release.Service }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/component: "{{ .Release.Name }}-datadir-pvc" - app.kubernetes.io/version: {{ .Chart.AppVersion }} - {{- if .Values.server.storage.preventDelete }} - helm.sh/resource-policy: keep - {{ end }} - {{- with .Values.server.config.labels }} - {{- toYaml . | nindent 4 }} - {{- end }} -spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: {{ .Values.server.storage.size }} - storageClassName: {{ .Values.server.storage.storageClassName }} -{{ end }} \ No newline at end of file diff --git a/charts/palworld/templates/role.yaml b/charts/palworld/templates/role.yaml deleted file mode 100644 index f1c955027..000000000 --- a/charts/palworld/templates/role.yaml +++ /dev/null @@ -1,14 +0,0 @@ -{{ if .Values.server.config.daily_reboot.enable }} -apiVersion: rbac.authorization.k8s.io/v1 -kind: Role -metadata: - name: "{{ .Values.server.config.daily_reboot.role }}" - namespace: {{ .Values.namespace }} -rules: - - apiGroups: ["apps", "extensions"] - resources: ["deployments", "pods"] - verbs: ["get", "patch", "list", "watch"] - - apiGroups: [""] - resources: ["pods/exec", "pods"] - verbs: ["get", "list", "create"] -{{ end }} diff --git a/charts/palworld/templates/rolebinding.yaml b/charts/palworld/templates/rolebinding.yaml deleted file mode 100644 index efd2f3f8b..000000000 --- a/charts/palworld/templates/rolebinding.yaml +++ /dev/null @@ -1,15 +0,0 @@ -{{ if .Values.server.config.daily_reboot.enable }} -apiVersion: rbac.authorization.k8s.io/v1 -kind: RoleBinding -metadata: - name: "{{ .Values.server.config.daily_reboot.role }}-binding" - namespace: {{ .Values.namespace }} -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: Role - name: "{{ .Values.server.config.daily_reboot.role }}" -subjects: - - kind: ServiceAccount - name: {{ .Values.server.config.daily_reboot.serviceAccount }} - namespace: {{ .Values.namespace }} -{{ end }} diff --git a/charts/palworld/templates/secrets.yaml b/charts/palworld/templates/secrets.yaml deleted file mode 100644 index 6e695d4f7..000000000 --- a/charts/palworld/templates/secrets.yaml +++ /dev/null @@ -1,25 +0,0 @@ -{{- define "server.rcon.password" -}} -{{- randAlphaNum 24 | nospace -}} -{{- end -}} -apiVersion: v1 -kind: Secret -metadata: - namespace: {{ .Values.namespace }} - name: "{{ .Release.Name }}-rcon-password" - annotations: - {{- with .Values.server.config.annotations }} - {{- toYaml . | nindent 4 }} - {{- end }} - labels: - helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} - app.kubernetes.io/name: "{{ .Release.Name }}-rcon-password" - app.kubernetes.io/managed-by: {{ .Release.Service }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/component: "{{ .Release.Name }}-rcon-password" - app.kubernetes.io/version: {{ .Chart.AppVersion }} - {{- with .Values.server.config.labels }} - {{- toYaml . | nindent 4 }} - {{- end }} -type: Opaque -stringData: - rconPassword: {{- if .Values.server.config.rcon.password }} "{{ .Values.server.config.rcon.password }}" {{ else }} "{{ include "server.rcon.password" .}}" {{ end }} \ No newline at end of file diff --git a/charts/palworld/templates/serviceaccount.yaml b/charts/palworld/templates/serviceaccount.yaml deleted file mode 100644 index 03419297a..000000000 --- a/charts/palworld/templates/serviceaccount.yaml +++ /dev/null @@ -1,7 +0,0 @@ -{{ if .Values.server.config.daily_reboot.enable }} -apiVersion: v1 -kind: ServiceAccount -metadata: - name: {{ .Values.server.config.daily_reboot.serviceAccount }} - namespace: {{ .Values.namespace }} -{{ end }} \ No newline at end of file diff --git a/charts/palworld/templates/services.yaml b/charts/palworld/templates/services.yaml deleted file mode 100644 index 5396c5e6f..000000000 --- a/charts/palworld/templates/services.yaml +++ /dev/null @@ -1,34 +0,0 @@ ---- -apiVersion: v1 -kind: Service -metadata: - namespace: {{ .Values.namespace }} - name: "{{ .Release.Name }}-svc" - labels: - helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} - app.kubernetes.io/name: "{{ .Release.Name }}-svc" - app.kubernetes.io/managed-by: {{ .Release.Service }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/component: "{{ .Release.Name }}-svc" - app.kubernetes.io/version: {{ .Chart.AppVersion }} - {{- with .Values.server.service.labels }} - {{- toYaml . | nindent 4 }} - {{- end }} - annotations: - {{- with .Values.server.service.annotations }} - {{- toYaml . | nindent 4 }} - {{- end }} -spec: - selector: - app.kubernetes.io/component: "{{ .Release.Name }}-server" - ports: - {{ if .Values.server.service.healthz.enabled }} - - name: {{ .Values.server.service.healthz.name }} - port: {{ .Values.server.service.healthz.port }} - protocol: {{ .Values.server.service.healthz.protocol }} - targetPort: {{ .Values.server.service.healthz.targetPort }} - {{ end }} - {{- with .Values.server.service.ports }} - {{- toYaml . | nindent 4 }} - {{- end }} - type: {{ .Values.server.service.type }} \ No newline at end of file diff --git a/charts/palworld/values.yaml b/charts/palworld/values.yaml deleted file mode 100644 index 3f734a012..000000000 --- a/charts/palworld/values.yaml +++ /dev/null @@ -1,224 +0,0 @@ ---- -# -- Namespace where the resources will be created -namespace: palworld -# -- (dict) The server configuration -# @notationType -- bigValue -server: - # -- Additional annotations to the resources - annotations: {} - # -- Additional labels to the resources - labels: {} - # -- (dict) Resources limits for the container. - resources: - limits: - cpu: 4 - memory: "12Gi" - requests: - cpu: 4 - memory: "8Gi" - # -- (dict) Define some parameters for the storage volume - storage: - # -- (bool) Define if it will use an existing PVC containing the installation data. - external: false - # -- (bool) The external PVC name to use. - externalName: "" - # -- Keeps helm from deleting the PVC. By default, helm does not delete pvcs. - preventDelete: false - # -- The size of the pvc storage. - size: 12Gi - # -- The storage class name. - storageClassName: "" - # -- (dict) Define the parameters for the server image container - # @notationType -- bigValue - image: - # -- Repository of the image, without the tag. - repository: thijsvanloef/palworld-server-docker - # -- The tag of the image. - tag: latest - # -- Define the pull policy for the server image. - imagePullPolicy: IfNotPresent - - # -- (dict) Change the ports to be mapped to the pod. - # If you change those, make sure to change the service.ports and server.config accordingly. - # @notationType -- bigValue - ports: - # -- (dict) The "game" port definition. - # If you change this, make sure to change the service.ports.game and server.config accordingly. - - name: game - containerPort: 8211 - protocol: UDP - # -- (dict) The "query" port definition . - # If you change this, make sure to change the service.ports.query_port and server.config accordingly. - - name: query - containerPort: 27015 - protocol: UDP - # -- (dict) The "rcon" port definition . - # If you change this, make sure to change the service.ports.rcon and server.config accordingly. - - name: rcon - containerPort: 25575 - protocol: UDP - # -- (string) Change the deployment strategy - strategy: Recreate - - # -- (dict) Change the service configuration. - # If you change those, make sure to change the server.config and server.ports accordingly. - # @notationType -- bigValue - service: - # -- (bool) Enables the creation of the service component. - enabled: true - # -- Additional annotations to the resources - annotations: {} - # -- Additional labels to the resources - labels: {} - # -- (string) The type of service to be created. - # For minikube, set this to NodePort, elsewhere use LoadBalancer - # Use ClusterIP if your setup includes ingress controller - type: ClusterIP - # -- (dict) The "healthz" definition . - # Use if you need to create a TCP health check for load balancers on cloud services. - healthz: - enabled: false - name: healthz - port: 80 - protocol: TCP - targetPort: 80 - # -- (dict) Change the ports to be mapped to the service. - # If you change those, make sure to change the server.config and server.ports accordingly. - # @notationType -- bigValue - ports: - # -- (dict) The "game" port definition. - # If you change this, make sure to change the server.ports.game and server.config.port accordingly. - - name: game - port: 8211 - protocol: UDP - targetPort: 8211 - # -- (dict) The "query" port definition . - # If you change this, make sure to change the server.ports.query and server.config.query_port accordingly. - - name: query - port: 27015 - protocol: UDP - targetPort: 27015 - # -- (dict) The "rcon" port definition . - # If you change this, make sure to change the server.ports.rcon and server.config.rcon.port accordingly. - - name: rcon - port: 25575 - protocol: UDP - targetPort: 25575 - # -- (dict) Change the game server configuration. - # If you change those, make sure to change the service.ports and server.ports accordingly. - # Those are directly connected with the container image, providing multiple environment variables to the scripts. - # @notationType -- bigValue - config: - # -- Additional annotations to the resources - annotations: {} - # -- Additional labels to the resources - labels: {} - puid: 1000 - pgid: 1000 - port: 8211 - # -- (string) The query port of the game. - query_port: 27015 - # -- The max number of players supported. - max_players: 16 - # -- (bool) Enables the multithreading, allowing the usage of up to 4 cores (needs citation) - multithreading: true - # -- (dict) Remote connection configuration. - # Allows the remote connection and management for the server. - # Those are directly connected with the container image, providing multiple environment variables to the scripts. - # @notationType -- bigValue - rcon: - # -- (bool) Enables/disables the rcon port. - enable: true - # -- (string) The port for rcon. If you change this, make sure to change the service.ports and server.ports accordingly. - port: 25575 - # -- (string) If not provided, a random password will be generated and stored on the secret. - password: "" - community: - # -- (bool) Enables/disables the visibility of this server on Steam community servers list. - enable: true - # -- (string) If not provided, a random password will be generated and stored on the secret. - password: "" - # -- (string) If not provided, a random server name will be generated with the "palworld_" prefix. - server_name: "" - # -- (string) The timezone used for time stamping backup server. Use the IANA TZ format with Area/Location - # See the [list of TZ database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#Time_Zone_abbreviations) - timezone: "UTC" - # -- (string) You can manually specify the global IP address of the network on which the server running. - # If not specified, it will be detected automatically. If it does not work well, try manual configuration. - public_ip: "" - # -- (string) You can manually specify the port number of the network on which the server running. - # If not specified, it will be detected automatically. If it does not work well, try manual configuration. - public_port: "" - # -- (string) Your server description to be shown in game - server_description: "" - # -- (string) Update/Install the server when the container starts. - # THIS HAS TO BE ENABLED THE FIRST TIME YOU RUN THE CONTAINER - update_on_boot: true - daily_reboot: - # -- (bool) Enable daily reboot. - # Disabled by default - enable: false - # -- (string) The time (UTC) the server will perform the reboot. - # By default, this schedules the restart at 9:30am UTC. Please note, this is using cron syntax. - time: "30 9 * * *" - # -- (string) The name of the role performing the daily reboot. - role: "daily-reboot" - # -- (string) The name of the Service Account used to perform the reboot. - serviceAccount: "daily-reboot" - # -- (object) Configures the game world settings. - # The key:values here should represent in game accepted values. - # Wrap all values with quotes here to avoid validation issues. - # @notationType -- bigValue - world_parameters: - DAYTIME_SPEEDRATE: "1.000000" - NIGHTTIME_SPEEDRATE: "1.000000" - EXP_RATE: "1.000000" - PAL_CAPTURE_RATE: "1.000000" - PAL_SPAWN_NUM_RATE: "1.000000" - PAL_DAMAGE_RATE_ATTACK: "1.000000" - PAL_DAMAGE_RATE_DEFENSE: "1.000000" - PLAYER_DAMAGE_RATE_ATTACK: "1.000000" - PLAYER_DAMAGE_RATE_DEFENSE: "1.000000" - PLAYER_STOMACH_DECREASE_RATE: "1.000000" - PLAYER_STAMINA_DECREASE_RATE: "1.000000" - PLAYER_AUTO_HP_REGEN_RATE: "1.000000" - PLAYER_AUTO_HP_REGEN_RATE_IN_SLEEP: "1.000000" - PAL_STOMACH_DECREASE_RATE: "1.000000" - PAL_STAMINA_DECREASE_RATE: "1.000000" - PAL_AUTO_HP_REGEN_RATE: "1.000000" - PAL_AUTO_HP_REGEN_RATE_IN_SLEEP: "1.000000" - BUILD_OBJECT_DAMAGE_RATE: "1.000000" - BUILD_OBJECT_DETERIORATION_DAMAGE_RATE: "1.000000" - COLLECTION_DROP_RATE: "1.000000" - COLLECTION_OBJECT_HP_RATE: "1.000000" - COLLECTION_OBJECT_RESPAWN_SPEED_RATE: "1.000000" - ENEMY_DROP_ITEM_RATE: "1.000000" - DEATH_PENALTY: "All" - ENABLE_PLAYER_TO_PLAYER_DAMAGE: "False" - ENABLE_FRIENDLY_FIRE: "False" - ENABLE_INVADER_ENEMY: "True" - ACTIVE_UNKO: "True" - ENABLE_AIM_ASSIST_PAD: "True" - ENABLE_AIM_ASSIST_KEYBOARD: "False" - DROP_ITEM_MAX_NUM: "3000" - DROP_ITEM_MAX_NUM_UNKO: "1000" - BASE_CAMP_MAX_NUM: "128" - BASE_CAMP_WORKER_MAX_NUM: "15" - DROP_ITEM_ALIVE_MAX_HOURS: "1.000000" - AUTO_RESET_GUILD_NO_ONLINE_PLAYERS: "False" - AUTO_RESET_GUILD_TIME_NO_ONLINE_PLAYERS: "72.000000" - GUILD_PLAYER_MAX_NUM: "3" - PAL_EGG_DEFAULT_HATCHING_TIME: "72.000000" - WORK_SPEED_RATE: "1.000000" - IS_MULTIPLAY: "False" - IS_PVP: "False" - CAN_PICKUP_OTHER_GUILD_DEATH_PENALTY_DROP: "False" - ENABLE_NON_LOGIN_PENALTY: "True" - ENABLE_FAST_TRAVEL: "True" - IS_START_LOCATION_SELECT_BY_MAP: "True" - EXIST_PLAYER_AFTER_LOGOUT: "False" - ENABLE_DEFENSE_OTHER_GUILD_PLAYER: "False" - COOP_PLAYER_MAX_NUM: "4" - REGION: "" - USEAUTH: "True" - BAN_LIST_URL: "https://api.palworldgame.com/api/banlist.txt" From bd89236851bf9713f8abc1f36f999e6df4ae85ad Mon Sep 17 00:00:00 2001 From: "Carlos M. Martinez" Date: Thu, 8 Feb 2024 21:50:44 -0500 Subject: [PATCH 02/10] Changed array of environmential variables to map --- docker-compose.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index c8778f6e4..31faf442c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,18 +9,18 @@ services: - 8211:8211/udp - 27015:27015/udp # Required if you want your server to show up in the community servers tab environment: - - PUID=1000 - - PGID=1000 - - PORT=8211 # Optional but recommended - - PLAYERS=16 # Optional but recommended - - SERVER_PASSWORD=worldofpals # Optional but recommended - - MULTITHREADING=true - - RCON_ENABLED=true - - RCON_PORT=25575 - - TZ=UTC - - ADMIN_PASSWORD=adminPasswordHere - - COMMUNITY=false # Enable this if you want your server to show up in the community servers tab, USE WITH SERVER_PASSWORD! - - SERVER_NAME=World of Pals - - SERVER_DESCRIPTION=palworld-server-docker by Thijs van Loef + PUID: 1000 + PGID: 1000 + PORT: 8211 # Optional but recommended + PLAYERS: 16 # Optional but recommended + SERVER_PASSWORD: "worldofpals" # Optional but recommended + MULTITHREADING: true + RCON_ENABLED: true + RCON_PORT: 25575 + TZ: UTC + ADMIN_PASSWORD: "adminPasswordHere" + COMMUNITY: false # Enable this if you want your server to show up in the community servers tab, USE WITH SERVER_PASSWORD! + SERVER_NAME: "World of Pals" + SERVER_DESCRIPTION: "palworld-server-docker by Thijs van Loef" volumes: - ./palworld:/palworld/ From 38b3636714dccadad03035ba6685b992f084e1ba Mon Sep 17 00:00:00 2001 From: "Carlos M. Martinez" Date: Thu, 8 Feb 2024 21:53:35 -0500 Subject: [PATCH 03/10] Added quotes around TZ --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 31faf442c..993579833 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,7 +17,7 @@ services: MULTITHREADING: true RCON_ENABLED: true RCON_PORT: 25575 - TZ: UTC + TZ: "UTC" ADMIN_PASSWORD: "adminPasswordHere" COMMUNITY: false # Enable this if you want your server to show up in the community servers tab, USE WITH SERVER_PASSWORD! SERVER_NAME: "World of Pals" From 770d2ee0432d2c44b11cb8ac05ce60ff362bfcc6 Mon Sep 17 00:00:00 2001 From: "Carlos M. Martinez" Date: Thu, 8 Feb 2024 21:53:51 -0500 Subject: [PATCH 04/10] Updated readme --- README.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 63ca9f12d..2e525412f 100644 --- a/README.md +++ b/README.md @@ -72,19 +72,19 @@ services: - 8211:8211/udp - 27015:27015/udp environment: - - PUID=1000 - - PGID=1000 - - PORT=8211 # Optional but recommended - - PLAYERS=16 # Optional but recommended - - SERVER_PASSWORD=worldofpals # Optional but recommended - - MULTITHREADING=true - - RCON_ENABLED=true - - RCON_PORT=25575 - - TZ=UTC - - ADMIN_PASSWORD=adminPasswordHere - - COMMUNITY=false # Enable this if you want your server to show up in the community servers tab, USE WITH SERVER_PASSWORD! - - SERVER_NAME=World of Pals - - SERVER_DESCRIPTION=palworld-server-docker by Thijs van Loef + PUID: 1000 + PGID: 1000 + PORT: 8211 # Optional but recommended + PLAYERS: 16 # Optional but recommended + SERVER_PASSWORD: "worldofpals" # Optional but recommended + MULTITHREADING: true + RCON_ENABLED: true + RCON_PORT: 25575 + TZ: "UTC" + ADMIN_PASSWORD: "adminPasswordHere" + COMMUNITY: false # Enable this if you want your server to show up in the community servers tab, USE WITH SERVER_PASSWORD! + SERVER_NAME: "World of Pals" + SERVER_DESCRIPTION: "palworld-server-docker by Thijs van Loef" volumes: - ./palworld:/palworld/ ``` From f60bc08459b716489b57a88a54d843dadaced2a8 Mon Sep 17 00:00:00 2001 From: Twinki Date: Fri, 9 Feb 2024 18:24:29 -0500 Subject: [PATCH 05/10] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c488dee4d..17638ad5d 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ [![Discord](https://img.shields.io/discord/1200397673329594459?logo=discord&label=Discord&link=https%3A%2F%2Fdiscord.gg%2FUxBxStPAAE)](https://discord.com/invite/UxBxStPAAE) [![Docker Hub](https://img.shields.io/badge/Docker_Hub-palworld-blue?logo=docker)](https://hub.docker.com/r/thijsvanloef/palworld-server-docker) -[![Artifact Hub](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/palworld)](https://artifacthub.io/packages/search?repo=palworld) +[![Artifact Hub](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/palworld-server-chart)](https://artifacthub.io/packages/search?repo=palworld-server-chart) [Chat with the community on Discord](https://discord.gg/UxBxStPAAE) From 25fd8730a097fffcd8f420e15754da9c8c8321bf Mon Sep 17 00:00:00 2001 From: Manuel Raimann Date: Sat, 10 Feb 2024 12:59:04 +0100 Subject: [PATCH 06/10] Add option to reboot even if there are players online --- .env.example | 1 + Dockerfile | 1 + Dockerfile.arm64 | 1 + README.md | 1 + scripts/auto_reboot.sh | 9 +++++++++ 5 files changed, 13 insertions(+) diff --git a/.env.example b/.env.example index bc302b960..63e62c78b 100644 --- a/.env.example +++ b/.env.example @@ -23,6 +23,7 @@ AUTO_UPDATE_ENABLED=false AUTO_UPDATE_CRON_EXPRESSION=0 * * * * AUTO_UPDATE_WARN_MINUTES=30 AUTO_REBOOT_ENABLED=false +AUTO_REBOOT_EVEN_IF_PLAYERS_ONLINE=false AUTO_REBOOT_WARN_MINUTES=5 AUTO_REBOOT_CRON_EXPRESSION=0 0 * * * diff --git a/Dockerfile b/Dockerfile index c077f6b88..7646e4ab2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -66,6 +66,7 @@ ENV PORT= \ AUTO_UPDATE_WARN_MINUTES=30 \ AUTO_REBOOT_ENABLED=false \ AUTO_REBOOT_WARN_MINUTES=5 \ + AUTO_REBOOT_EVEN_IF_PLAYERS_ONLINE=false \ AUTO_REBOOT_CRON_EXPRESSION="0 0 * * *" \ DISCORD_WEBHOOK_URL= \ DISCORD_CONNECT_TIMEOUT=30 \ diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 index d4a568f13..df2d8e2ed 100644 --- a/Dockerfile.arm64 +++ b/Dockerfile.arm64 @@ -86,6 +86,7 @@ ENV PORT= \ AUTO_UPDATE_WARN_MINUTES=30 \ AUTO_REBOOT_ENABLED=false \ AUTO_REBOOT_WARN_MINUTES=5 \ + AUTO_REBOOT_EVEN_IF_PLAYERS_ONLINE=false \ AUTO_REBOOT_CRON_EXPRESSION="0 0 * * *" \ DISCORD_WEBHOOK_URL= \ DISCORD_CONNECT_TIMEOUT=30 \ diff --git a/README.md b/README.md index 63ca9f12d..12dfa64f6 100644 --- a/README.md +++ b/README.md @@ -202,6 +202,7 @@ It is highly recommended you set the following environment values before startin | AUTO_REBOOT_CRON_EXPRESSION | Setting affects frequency of automatic updates. | 0 0 \* \* \* | Needs a Cron-Expression - See [Configuring Automatic Backups with Cron](#configuring-automatic-reboots-with-cron) | | AUTO_REBOOT_ENABLED | Enables automatic reboots | false | true/false | | AUTO_REBOOT_WARN_MINUTES | How long to wait to reboot the server, after the player were informed. | 5 | !0 | +| AUTO_REBOOT_EVEN_IF_PLAYERS_ONLINE | Restart the Server even if there are players online. | false | true/false | | DISCORD_WEBHOOK_URL | Discord webhook url found after creating a webhook on a discord server | | `https://discord.com/api/webhooks/` | | DISCORD_CONNECT_TIMEOUT | Discord command initial connection timeout | 30 | !0 | | DISCORD_MAX_TIMEOUT | Discord total hook timeout | 30 | !0 | diff --git a/scripts/auto_reboot.sh b/scripts/auto_reboot.sh index 9fa4e0fde..376af7d0a 100644 --- a/scripts/auto_reboot.sh +++ b/scripts/auto_reboot.sh @@ -1,6 +1,15 @@ #!/bin/bash if [ "${RCON_ENABLED,,}" = true ]; then + if [ "${AUTO_REBOOT_EVEN_IF_PLAYERS_ONLINE,,}" != true ]; then + players_count=$(rcon-cli -c /home/steam/server/rcon.yaml showplayers) + + if [ "$(echo -n "$players_count" | wc -l)" -gt 0 ]; then + echo "There are ${players_count} players online. Skipping auto reboot." + exit 1 + fi + fi + if [ -z "${AUTO_REBOOT_WARN_MINUTES}" ]; then echo "Unable to auto reboot, AUTO_REBOOT_WARN_MINUTES is empty." elif [[ "${AUTO_REBOOT_WARN_MINUTES}" =~ ^[0-9]+$ ]]; then From 6c67e35185a6716ef78b49c74bb0bf595d7f317f Mon Sep 17 00:00:00 2001 From: Blocka Wan Date: Sun, 11 Feb 2024 02:46:19 +0800 Subject: [PATCH 07/10] add unit test --- .github/workflows/linting.yml | 182 ++++++++++++++++++++++++++++++++++ 1 file changed, 182 insertions(+) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index b84f2f477..357375622 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -2,6 +2,8 @@ name: Linting on: # yamllint disable-line rule:truthy pull_request: + push: + branches: [main] run-name: Pull request - ${{ github.event.pull_request.number }} jobs: @@ -58,3 +60,183 @@ jobs: uses: docker/build-push-action@v5 with: push: false + + unit-test-amd64: + name: Docker - Test (amd64) + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and export to Docker + uses: docker/build-push-action@v5 + with: + load: true + tags: ${{ github.run_id }} + platforms: linux/amd64 + + - name: Run server + run: | + docker run -d \ + --name palworld-server \ + -p 8211:8211/udp \ + -p 27015:27015/udp \ + -p 25575:25575/tcp \ + -v ./palworld:/palworld/ \ + -e PUID=1000 \ + -e PGID=1000 \ + -e PORT=8211 \ + -e PLAYERS=16 \ + -e MULTITHREADING=true \ + -e RCON_ENABLED=true \ + -e RCON_PORT=25575 \ + -e TZ=UTC \ + -e ADMIN_PASSWORD="adminPasswordHere" \ + -e SERVER_PASSWORD="worldofpals" \ + -e COMMUNITY=false \ + -e SERVER_NAME="World of Pals" \ + -e SERVER_DESCRIPTION="palworld-server-docker by Thijs van Loef" \ + --restart unless-stopped \ + --stop-timeout 30 \ + ${{ github.run_id }} + + - name: Wait for server to start + run: | + TIMEOUT_SECONDS=120 + START_TIME=$(date +%s) + + while ! docker logs palworld-server 2>&1 | grep -q "Setting breakpad minidump AppID"; do + CURRENT_TIME=$(date +%s) + ELAPSED_TIME=$((CURRENT_TIME - START_TIME)) + + if [ $ELAPSED_TIME -gt $TIMEOUT_SECONDS ]; then + echo "Timeout reached. Server failed to start within $TIMEOUT_SECONDS seconds." + exit 1 # or handle the failure accordingly + fi + + echo "Waiting for server to start..." + sleep 5 + done + + - name: Test if server is up and running + run: | + if ! docker exec palworld-server rcon-cli Info | grep -q "Welcome to Pal Server"; then + echo "Server may not have started successfully." + exit 1 + fi + + - name: Test if port 8211, 27015 and 25575 are listening + run: | + sleep 10 + nc -z -u -v 127.0.0.1 8211 || exit 1 + nc -z -u -v 127.0.0.1 27015 || exit 1 + nc -z -v 127.0.0.1 25575 || exit 1 + + - name: Test the backup command functions + run: | + docker exec palworld-server backup + if [ ! -f ./palworld/backups/palworld-save-*.tar.gz ]; then + echo "Backup file not found. Backup command may have failed." + exit 1 + fi + + unit-test-arm64: + name: Docker - Test (arm64) + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and export to Docker + uses: docker/build-push-action@v5 + with: + file: ./Dockerfile.arm64 + load: true + tags: ${{ github.run_id }} + platforms: linux/arm64 + + - name: Run server + run: | + docker run -d \ + --name palworld-server \ + -p 8211:8211/udp \ + -p 27015:27015/udp \ + -p 25575:25575/tcp \ + -v ./palworld:/palworld/ \ + -e PUID=1000 \ + -e PGID=1000 \ + -e PORT=8211 \ + -e PLAYERS=16 \ + -e MULTITHREADING=true \ + -e RCON_ENABLED=true \ + -e RCON_PORT=25575 \ + -e TZ=UTC \ + -e ADMIN_PASSWORD="adminPasswordHere" \ + -e SERVER_PASSWORD="worldofpals" \ + -e COMMUNITY=false \ + -e SERVER_NAME="World of Pals" \ + -e SERVER_DESCRIPTION="palworld-server-docker by Thijs van Loef" \ + --restart unless-stopped \ + --stop-timeout 30 \ + ${{ github.run_id }} + + - name: Wait for server to start + run: | + TIMEOUT_SECONDS=240 + START_TIME=$(date +%s) + + while ! docker logs palworld-server 2>&1 | grep -q "Setting breakpad minidump AppID"; do + CURRENT_TIME=$(date +%s) + ELAPSED_TIME=$((CURRENT_TIME - START_TIME)) + + if [ $ELAPSED_TIME -gt $TIMEOUT_SECONDS ]; then + echo "Timeout reached. Server failed to start within $TIMEOUT_SECONDS seconds." + exit 1 # or handle the failure accordingly + fi + + echo "Waiting for server to start..." + sleep 5 + done + + - name: Test if server is up and running + run: | + if ! docker exec palworld-server rcon-cli Info | grep -q "Welcome to Pal Server"; then + echo "Server may not have started successfully." + exit 1 + fi + + - name: Test if port 8211, 27015 and 25575 are listening + run: | + sleep 10 + nc -z -u -v 127.0.0.1 8211 || exit 1 + nc -z -u -v 127.0.0.1 27015 || exit 1 + nc -z -v 127.0.0.1 25575 || exit 1 + + - name: Test the backup command functions + run: | + docker exec palworld-server backup + if [ ! -f ./palworld/backups/palworld-save-*.tar.gz ]; then + echo "Backup file not found. Backup command may have failed." + exit 1 + fi From def5ccbf5841eb5d86458b6cc32e64e672cd9496 Mon Sep 17 00:00:00 2001 From: Blocka Wan Date: Sun, 11 Feb 2024 06:23:35 +0800 Subject: [PATCH 08/10] add platform for arm64 unit test --- .github/workflows/linting.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 357375622..3d8111cac 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -180,6 +180,7 @@ jobs: run: | docker run -d \ --name palworld-server \ + --platform linux/arm64 \ -p 8211:8211/udp \ -p 27015:27015/udp \ -p 25575:25575/tcp \ From a9ed9cc2311447f15b9f66350cfedf9f9c319ca8 Mon Sep 17 00:00:00 2001 From: Blocka Wan Date: Sun, 11 Feb 2024 06:27:16 +0800 Subject: [PATCH 09/10] add a delay time to wait for rcon-cli to start --- .github/workflows/linting.yml | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 3d8111cac..223cab34e 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -71,12 +71,6 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build and export to Docker uses: docker/build-push-action@v5 with: @@ -129,6 +123,7 @@ jobs: - name: Test if server is up and running run: | + sleep 5 if ! docker exec palworld-server rcon-cli Info | grep -q "Welcome to Pal Server"; then echo "Server may not have started successfully." exit 1 @@ -136,7 +131,6 @@ jobs: - name: Test if port 8211, 27015 and 25575 are listening run: | - sleep 10 nc -z -u -v 127.0.0.1 8211 || exit 1 nc -z -u -v 127.0.0.1 27015 || exit 1 nc -z -v 127.0.0.1 25575 || exit 1 @@ -162,12 +156,6 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build and export to Docker uses: docker/build-push-action@v5 with: @@ -204,7 +192,7 @@ jobs: - name: Wait for server to start run: | - TIMEOUT_SECONDS=240 + TIMEOUT_SECONDS=360 START_TIME=$(date +%s) while ! docker logs palworld-server 2>&1 | grep -q "Setting breakpad minidump AppID"; do @@ -222,6 +210,7 @@ jobs: - name: Test if server is up and running run: | + sleep 5 if ! docker exec palworld-server rcon-cli Info | grep -q "Welcome to Pal Server"; then echo "Server may not have started successfully." exit 1 @@ -229,7 +218,6 @@ jobs: - name: Test if port 8211, 27015 and 25575 are listening run: | - sleep 10 nc -z -u -v 127.0.0.1 8211 || exit 1 nc -z -u -v 127.0.0.1 27015 || exit 1 nc -z -v 127.0.0.1 25575 || exit 1 From eac220adebdd5813fa3240ab3b9982622938535f Mon Sep 17 00:00:00 2001 From: Blocka Wan Date: Sun, 11 Feb 2024 07:01:37 +0800 Subject: [PATCH 10/10] turn unit test to reusable workflow --- .github/workflows/linting.yml | 171 --------------------------- .github/workflows/unit-test.yml | 199 ++++++++++++++++++++++++++++++++ 2 files changed, 199 insertions(+), 171 deletions(-) create mode 100644 .github/workflows/unit-test.yml diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 223cab34e..b84f2f477 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -2,8 +2,6 @@ name: Linting on: # yamllint disable-line rule:truthy pull_request: - push: - branches: [main] run-name: Pull request - ${{ github.event.pull_request.number }} jobs: @@ -60,172 +58,3 @@ jobs: uses: docker/build-push-action@v5 with: push: false - - unit-test-amd64: - name: Docker - Test (amd64) - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Build and export to Docker - uses: docker/build-push-action@v5 - with: - load: true - tags: ${{ github.run_id }} - platforms: linux/amd64 - - - name: Run server - run: | - docker run -d \ - --name palworld-server \ - -p 8211:8211/udp \ - -p 27015:27015/udp \ - -p 25575:25575/tcp \ - -v ./palworld:/palworld/ \ - -e PUID=1000 \ - -e PGID=1000 \ - -e PORT=8211 \ - -e PLAYERS=16 \ - -e MULTITHREADING=true \ - -e RCON_ENABLED=true \ - -e RCON_PORT=25575 \ - -e TZ=UTC \ - -e ADMIN_PASSWORD="adminPasswordHere" \ - -e SERVER_PASSWORD="worldofpals" \ - -e COMMUNITY=false \ - -e SERVER_NAME="World of Pals" \ - -e SERVER_DESCRIPTION="palworld-server-docker by Thijs van Loef" \ - --restart unless-stopped \ - --stop-timeout 30 \ - ${{ github.run_id }} - - - name: Wait for server to start - run: | - TIMEOUT_SECONDS=120 - START_TIME=$(date +%s) - - while ! docker logs palworld-server 2>&1 | grep -q "Setting breakpad minidump AppID"; do - CURRENT_TIME=$(date +%s) - ELAPSED_TIME=$((CURRENT_TIME - START_TIME)) - - if [ $ELAPSED_TIME -gt $TIMEOUT_SECONDS ]; then - echo "Timeout reached. Server failed to start within $TIMEOUT_SECONDS seconds." - exit 1 # or handle the failure accordingly - fi - - echo "Waiting for server to start..." - sleep 5 - done - - - name: Test if server is up and running - run: | - sleep 5 - if ! docker exec palworld-server rcon-cli Info | grep -q "Welcome to Pal Server"; then - echo "Server may not have started successfully." - exit 1 - fi - - - name: Test if port 8211, 27015 and 25575 are listening - run: | - nc -z -u -v 127.0.0.1 8211 || exit 1 - nc -z -u -v 127.0.0.1 27015 || exit 1 - nc -z -v 127.0.0.1 25575 || exit 1 - - - name: Test the backup command functions - run: | - docker exec palworld-server backup - if [ ! -f ./palworld/backups/palworld-save-*.tar.gz ]; then - echo "Backup file not found. Backup command may have failed." - exit 1 - fi - - unit-test-arm64: - name: Docker - Test (arm64) - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Build and export to Docker - uses: docker/build-push-action@v5 - with: - file: ./Dockerfile.arm64 - load: true - tags: ${{ github.run_id }} - platforms: linux/arm64 - - - name: Run server - run: | - docker run -d \ - --name palworld-server \ - --platform linux/arm64 \ - -p 8211:8211/udp \ - -p 27015:27015/udp \ - -p 25575:25575/tcp \ - -v ./palworld:/palworld/ \ - -e PUID=1000 \ - -e PGID=1000 \ - -e PORT=8211 \ - -e PLAYERS=16 \ - -e MULTITHREADING=true \ - -e RCON_ENABLED=true \ - -e RCON_PORT=25575 \ - -e TZ=UTC \ - -e ADMIN_PASSWORD="adminPasswordHere" \ - -e SERVER_PASSWORD="worldofpals" \ - -e COMMUNITY=false \ - -e SERVER_NAME="World of Pals" \ - -e SERVER_DESCRIPTION="palworld-server-docker by Thijs van Loef" \ - --restart unless-stopped \ - --stop-timeout 30 \ - ${{ github.run_id }} - - - name: Wait for server to start - run: | - TIMEOUT_SECONDS=360 - START_TIME=$(date +%s) - - while ! docker logs palworld-server 2>&1 | grep -q "Setting breakpad minidump AppID"; do - CURRENT_TIME=$(date +%s) - ELAPSED_TIME=$((CURRENT_TIME - START_TIME)) - - if [ $ELAPSED_TIME -gt $TIMEOUT_SECONDS ]; then - echo "Timeout reached. Server failed to start within $TIMEOUT_SECONDS seconds." - exit 1 # or handle the failure accordingly - fi - - echo "Waiting for server to start..." - sleep 5 - done - - - name: Test if server is up and running - run: | - sleep 5 - if ! docker exec palworld-server rcon-cli Info | grep -q "Welcome to Pal Server"; then - echo "Server may not have started successfully." - exit 1 - fi - - - name: Test if port 8211, 27015 and 25575 are listening - run: | - nc -z -u -v 127.0.0.1 8211 || exit 1 - nc -z -u -v 127.0.0.1 27015 || exit 1 - nc -z -v 127.0.0.1 25575 || exit 1 - - - name: Test the backup command functions - run: | - docker exec palworld-server backup - if [ ! -f ./palworld/backups/palworld-save-*.tar.gz ]; then - echo "Backup file not found. Backup command may have failed." - exit 1 - fi diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml new file mode 100644 index 000000000..3016f52a8 --- /dev/null +++ b/.github/workflows/unit-test.yml @@ -0,0 +1,199 @@ +--- +name: Unit-test +on: # yamllint disable-line rule:truthy + pull_request: + workflow_call: + +jobs: + unit-test-amd64: + name: Docker - Test (amd64) + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and export to Docker + uses: docker/build-push-action@v5 + with: + load: true + tags: ${{ github.run_id }} + platforms: linux/amd64 + + - name: Run server + run: | + docker run -d \ + --name palworld-server \ + -p 8211:8211/udp \ + -p 27015:27015/udp \ + -p 25575:25575/tcp \ + -v ./palworld:/palworld/ \ + -e PUID=1000 \ + -e PGID=1000 \ + -e PORT=8211 \ + -e PLAYERS=16 \ + -e MULTITHREADING=true \ + -e RCON_ENABLED=true \ + -e RCON_PORT=25575 \ + -e TZ=UTC \ + -e ADMIN_PASSWORD="adminPasswordHere" \ + -e SERVER_PASSWORD="worldofpals" \ + -e COMMUNITY=false \ + -e SERVER_NAME="World of Pals" \ + -e SERVER_DESCRIPTION="palworld-server-docker by Thijs van Loef" \ + --restart unless-stopped \ + --stop-timeout 30 \ + ${{ github.run_id }} + + - name: Wait for server to start + run: | + TIMEOUT_SECONDS=120 + START_TIME=$(date +%s) + + while ! docker logs palworld-server 2>&1 | grep -q "Setting breakpad minidump AppID"; do + CURRENT_TIME=$(date +%s) + ELAPSED_TIME=$((CURRENT_TIME - START_TIME)) + + if [ $ELAPSED_TIME -gt $TIMEOUT_SECONDS ]; then + echo "Timeout reached. Server failed to start within $TIMEOUT_SECONDS seconds." + exit 1 # or handle the failure accordingly + fi + + echo "Waiting for server to start..." + sleep 5 + done + + - name: Test if server is up and running + run: | + sleep 5 + if ! docker exec palworld-server rcon-cli Info | grep -q "Welcome to Pal Server"; then + echo "Server may not have started successfully." + exit 1 + fi + + - name: Test if port 8211, 27015 and 25575 are listening + run: | + nc -z -u -v 127.0.0.1 8211 || exit 1 + nc -z -u -v 127.0.0.1 27015 || exit 1 + nc -z -v 127.0.0.1 25575 || exit 1 + + - name: Test the backup command functions + run: | + docker exec palworld-server backup + if [ ! -f ./palworld/backups/palworld-save-*.tar.gz ]; then + echo "Backup file not found. Backup command may have failed." + exit 1 + fi + + - name: Test if PalWorldSettings.ini is valid + run: | + if ! grep -q "\[\/Script\/Pal.PalGameWorldSettings\]" ./palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini; then + echo "Error: PalWorldSettings.ini is missing the required section [/Script/Pal.PalGameWorldSettings]." + exit 1 + fi + + if ! grep -q "^OptionSettings=\(.*\)" ./palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini; then + echo "Error: PalWorldSettings.ini is missing or has an invalid OptionSettings section." + exit 1 + fi + + unit-test-arm64: + name: Docker - Test (arm64) + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and export to Docker + uses: docker/build-push-action@v5 + with: + file: ./Dockerfile.arm64 + load: true + tags: ${{ github.run_id }} + platforms: linux/arm64 + + - name: Run server + run: | + docker run -d \ + --name palworld-server \ + --platform linux/arm64 \ + -p 8211:8211/udp \ + -p 27015:27015/udp \ + -p 25575:25575/tcp \ + -v ./palworld:/palworld/ \ + -e PUID=1000 \ + -e PGID=1000 \ + -e PORT=8211 \ + -e PLAYERS=16 \ + -e MULTITHREADING=true \ + -e RCON_ENABLED=true \ + -e RCON_PORT=25575 \ + -e TZ=UTC \ + -e ADMIN_PASSWORD="adminPasswordHere" \ + -e SERVER_PASSWORD="worldofpals" \ + -e COMMUNITY=false \ + -e SERVER_NAME="World of Pals" \ + -e SERVER_DESCRIPTION="palworld-server-docker by Thijs van Loef" \ + --restart unless-stopped \ + --stop-timeout 30 \ + ${{ github.run_id }} + + - name: Wait for server to start + run: | + TIMEOUT_SECONDS=400 + START_TIME=$(date +%s) + + while ! docker logs palworld-server 2>&1 | grep -q "Setting breakpad minidump AppID"; do + CURRENT_TIME=$(date +%s) + ELAPSED_TIME=$((CURRENT_TIME - START_TIME)) + + if [ $ELAPSED_TIME -gt $TIMEOUT_SECONDS ]; then + echo "Timeout reached. Server failed to start within $TIMEOUT_SECONDS seconds." + exit 1 # or handle the failure accordingly + fi + + echo "Waiting for server to start..." + sleep 5 + done + + - name: Test if server is up and running + run: | + sleep 100 + if ! docker exec palworld-server rcon-cli Info | grep -q "Welcome to Pal Server"; then + echo "Server may not have started successfully." + exit 1 + fi + + - name: Test if port 8211, 27015 and 25575 are listening + run: | + nc -z -u -v 127.0.0.1 8211 || exit 1 + nc -z -u -v 127.0.0.1 27015 || exit 1 + nc -z -v 127.0.0.1 25575 || exit 1 + + - name: Test the backup command functions + run: | + docker exec palworld-server backup + if [ ! -f ./palworld/backups/palworld-save-*.tar.gz ]; then + echo "Backup file not found. Backup command may have failed." + exit 1 + fi + + - name: Test if PalWorldSettings.ini is valid + run: | + if ! grep -q "\[\/Script\/Pal.PalGameWorldSettings\]" ./palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini; then + echo "Error: PalWorldSettings.ini is missing the required section [/Script/Pal.PalGameWorldSettings]." + exit 1 + fi + + if ! grep -q "^OptionSettings=\(.*\)" ./palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini; then + echo "Error: PalWorldSettings.ini is missing or has an invalid OptionSettings section." + exit 1 + fi