From 6b42438b4295d1c9d560cf758a7aa91b9e835c9f Mon Sep 17 00:00:00 2001 From: Filipe Souza Date: Wed, 24 Jan 2024 15:57:53 -0300 Subject: [PATCH 1/9] - Added a helm chart with some basic doc; --- .gitignore | 5 +- chart/Chart.yaml | 20 +++++ chart/README.md | 32 ++++++++ chart/VALUES_SUMMARY.md | 63 ++++++++++++++++ chart/templates/configmaps.yaml | 36 +++++++++ chart/templates/deployments.yaml | 58 ++++++++++++++ chart/templates/pvcs.yaml | 29 +++++++ chart/templates/secrets.yaml | 25 +++++++ chart/templates/services.yaml | 28 +++++++ chart/values.yaml | 125 +++++++++++++++++++++++++++++++ 10 files changed, 420 insertions(+), 1 deletion(-) create mode 100644 chart/Chart.yaml create mode 100644 chart/README.md create mode 100644 chart/VALUES_SUMMARY.md create mode 100644 chart/templates/configmaps.yaml create mode 100644 chart/templates/deployments.yaml create mode 100644 chart/templates/pvcs.yaml create mode 100644 chart/templates/secrets.yaml create mode 100644 chart/templates/services.yaml create mode 100644 chart/values.yaml diff --git a/.gitignore b/.gitignore index d1a7b7fb..5cddfe9d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ -palworld \ No newline at end of file +palworld +.idea +values*.yaml +!chart/values.yaml \ No newline at end of file diff --git a/chart/Chart.yaml b/chart/Chart.yaml new file mode 100644 index 00000000..1f657979 --- /dev/null +++ b/chart/Chart.yaml @@ -0,0 +1,20 @@ +apiVersion: v2 +name: palworld +version: 0.0.0 +description: This chart can provide an rAthena emulator 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 +icon: https://cdn.akamai.steamstatic.com/steam/apps/1623730/header.jpg +appVersion: "latest" +deprecated: false \ No newline at end of file diff --git a/chart/README.md b/chart/README.md new file mode 100644 index 00000000..5cb389cb --- /dev/null +++ b/chart/README.md @@ -0,0 +1,32 @@ +# 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/chart/VALUES_SUMMARY.md b/chart/VALUES_SUMMARY.md new file mode 100644 index 00000000..f76fb436 --- /dev/null +++ b/chart/VALUES_SUMMARY.md @@ -0,0 +1,63 @@ +# palworld + +![Version: 0.0.0](https://img.shields.io/badge/Version-0.0.0-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 can provide an rAthena emulator installation on a Kubernetes cluster. + +**Homepage:** + +## Maintainers + +| Name | Email | Url | +| ---- | ------ | --- | +| Filipe Souza | | | + +## 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.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.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.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.name | string | `"thijsvanloef/palworld-server-docker"` | Name 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.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.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.ports[3] | dict | `{"name":"healthz","port":80,"protocol":"TCP","targetPort":80}` | The "healthz" port definition . Used only to create a health check for load balancers on cloud services. | +| server.service.type | string | `"LoadBalancer"` | The type of service to be created. | +| server.storage | dict | `{"preventDelete":false,"size":"10Gi","storageClassName":""}` | Define some parameters for the storage volume | +| server.storage.preventDelete | bool | `false` | Keeps helm from deleting the PVC. By default, helm does not delete pvcs. | +| server.storage.size | string | `"10Gi"` | The size of the pvc storage. | +| server.storage.storageClassName | string | `""` | The storage class name. | + +---------------------------------------------- +Autogenerated from chart metadata using [helm-docs v1.12.0](https://github.com/norwoodj/helm-docs/releases/v1.12.0) diff --git a/chart/templates/configmaps.yaml b/chart/templates/configmaps.yaml new file mode 100644 index 00000000..3ae6bbf5 --- /dev/null +++ b/chart/templates/configmaps.yaml @@ -0,0 +1,36 @@ +{{- $cPwd := randAlphaNum 12 | nospace -}} +{{- $sName := randAlphaNum 6 | nospace -}} +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 }} + SERVER_NAME: {{- if .Values.server.config.server_name }} "{{ .Values.server.config.server_name }}" {{ else }} {{ printf "%s_%s" "palworld" $sName }} {{ end }} \ No newline at end of file diff --git a/chart/templates/deployments.yaml b/chart/templates/deployments.yaml new file mode 100644 index 00000000..823261b9 --- /dev/null +++ b/chart/templates/deployments.yaml @@ -0,0 +1,58 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: {{ .Values.namespace }} + name: "{{ .Release.Name }}-server" +spec: + selector: + matchLabels: + app.kubernetes.io/component: "{{ .Release.Name }}-server" + 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: + - name: healthz + image: "chussenot/tiny-server:latest" + imagePullPolicy: {{ .Values.server.image.imagePullPolicy }} + ports: + - name: healthz + containerPort: 80 + protocol: TCP + - name: server + image: "{{ .Values.server.image.name }}:{{ .Values.server.image.tag }}" + imagePullPolicy: {{ .Values.server.image.imagePullPolicy }} + 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: + claimName: "{{ .Release.Name }}-datadir-pvc" diff --git a/chart/templates/pvcs.yaml b/chart/templates/pvcs.yaml new file mode 100644 index 00000000..b4d9a5f3 --- /dev/null +++ b/chart/templates/pvcs.yaml @@ -0,0 +1,29 @@ +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 }} \ No newline at end of file diff --git a/chart/templates/secrets.yaml b/chart/templates/secrets.yaml new file mode 100644 index 00000000..f1a3d857 --- /dev/null +++ b/chart/templates/secrets.yaml @@ -0,0 +1,25 @@ +{{- 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/chart/templates/services.yaml b/chart/templates/services.yaml new file mode 100644 index 00000000..a7ff4e29 --- /dev/null +++ b/chart/templates/services.yaml @@ -0,0 +1,28 @@ +--- +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.config.annotations }} + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + selector: + app.kubernetes.io/component: "{{ .Release.Name }}-server" + ports: + {{- with .Values.server.service.ports }} + {{- toYaml . | nindent 4 }} + {{- end }} + type: {{ .Values.server.service.type }} \ No newline at end of file diff --git a/chart/values.yaml b/chart/values.yaml new file mode 100644 index 00000000..3172d7a9 --- /dev/null +++ b/chart/values.yaml @@ -0,0 +1,125 @@ +# -- 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) Define some parameters for the storage volume + storage: + # -- Keeps helm from deleting the PVC. By default, helm does not delete pvcs. + preventDelete: false + # -- The size of the pvc storage. + size: 10Gi + # -- The storage class name. + storageClassName: "" + # -- (dict) Define the parameters for the server image container + # @notationType -- bigValue + image: + # -- Name of the image, without the tag. + name: 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 + + # -- (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. + type: LoadBalancer + # -- (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) The "healthz" port definition . + # Used only to create a health check for load balancers on cloud services. + - name: healthz + port: 80 + protocol: TCP + targetPort: 80 + # -- (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: "" + + From 2fdb55f4dd12d22f4f45830c61a9fa1065f30f97 Mon Sep 17 00:00:00 2001 From: Filipe Souza Date: Wed, 24 Jan 2024 17:56:54 -0300 Subject: [PATCH 2/9] - Updated the main readme; --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 612f6a4c..157f1ce7 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,10 @@ All files you will need to deploy this container to kubernetes are located in th 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](./chart/README.md) to deploy. + ### Environment variables You can use the following values to change the settings of the server on boot. From 3f00d4ad0d3e3f23fa2c81879630253a551aede3 Mon Sep 17 00:00:00 2001 From: Filipe Souza Date: Thu, 25 Jan 2024 00:43:55 -0300 Subject: [PATCH 3/9] - Now supports a external PVC to be attached to the container; - Added parameters to include a external PVC; --- chart/VALUES_SUMMARY.md | 4 +++- chart/templates/deployments.yaml | 4 ++++ chart/templates/pvcs.yaml | 4 +++- chart/values.yaml | 4 ++++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/chart/VALUES_SUMMARY.md b/chart/VALUES_SUMMARY.md index f76fb436..ef8ad5bc 100644 --- a/chart/VALUES_SUMMARY.md +++ b/chart/VALUES_SUMMARY.md @@ -54,7 +54,9 @@ This chart can provide an rAthena emulator installation on a Kubernetes cluster. | 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.ports[3] | dict | `{"name":"healthz","port":80,"protocol":"TCP","targetPort":80}` | The "healthz" port definition . Used only to create a health check for load balancers on cloud services. | | server.service.type | string | `"LoadBalancer"` | The type of service to be created. | -| server.storage | dict | `{"preventDelete":false,"size":"10Gi","storageClassName":""}` | Define some parameters for the storage volume | +| server.storage | dict | `{"external":false,"externalName":"","preventDelete":false,"size":"10Gi","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 | `"10Gi"` | The size of the pvc storage. | | server.storage.storageClassName | string | `""` | The storage class name. | diff --git a/chart/templates/deployments.yaml b/chart/templates/deployments.yaml index 823261b9..105909bb 100644 --- a/chart/templates/deployments.yaml +++ b/chart/templates/deployments.yaml @@ -55,4 +55,8 @@ spec: 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/chart/templates/pvcs.yaml b/chart/templates/pvcs.yaml index b4d9a5f3..c16e754f 100644 --- a/chart/templates/pvcs.yaml +++ b/chart/templates/pvcs.yaml @@ -1,3 +1,4 @@ +{{- if not .Values.server.storage.external }} apiVersion: v1 kind: PersistentVolumeClaim metadata: @@ -26,4 +27,5 @@ spec: resources: requests: storage: {{ .Values.server.storage.size }} - storageClassName: {{ .Values.server.storage.storageClassName }} \ No newline at end of file + storageClassName: {{ .Values.server.storage.storageClassName }} +{{ end }} \ No newline at end of file diff --git a/chart/values.yaml b/chart/values.yaml index 3172d7a9..e72af116 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -9,6 +9,10 @@ server: labels: { } # -- (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. From a8e466d9dd5d17841a6e0cc80235b129bbeac8f1 Mon Sep 17 00:00:00 2001 From: Filipe Souza Date: Thu, 25 Jan 2024 01:30:21 -0300 Subject: [PATCH 4/9] - Added limits for the server container spec; --- chart/VALUES_SUMMARY.md | 1 + chart/templates/deployments.yaml | 4 ++++ chart/values.yaml | 8 ++++++++ 3 files changed, 13 insertions(+) diff --git a/chart/VALUES_SUMMARY.md b/chart/VALUES_SUMMARY.md index ef8ad5bc..7304d20f 100644 --- a/chart/VALUES_SUMMARY.md +++ b/chart/VALUES_SUMMARY.md @@ -44,6 +44,7 @@ This chart can provide an rAthena emulator installation on a Kubernetes cluster. | 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. | diff --git a/chart/templates/deployments.yaml b/chart/templates/deployments.yaml index 105909bb..73e97893 100644 --- a/chart/templates/deployments.yaml +++ b/chart/templates/deployments.yaml @@ -36,6 +36,10 @@ spec: - name: server image: "{{ .Values.server.image.name }}:{{ .Values.server.image.tag }}" imagePullPolicy: {{ .Values.server.image.imagePullPolicy }} + resources: + {{- with .Values.server.resources }} + {{- toYaml . | nindent 12 }} + {{- end }} ports: {{- with .Values.server.ports }} {{- toYaml . | nindent 12 }} diff --git a/chart/values.yaml b/chart/values.yaml index e72af116..5d78652b 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -7,6 +7,14 @@ server: 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. From c0e5b9fa66f6382d38084365ced867d65f4a0f00 Mon Sep 17 00:00:00 2001 From: Filipe Souza Date: Thu, 25 Jan 2024 01:51:27 -0300 Subject: [PATCH 5/9] - Added func to replace any non alphanumeric chars to underscore into server name; --- chart/templates/configmaps.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/chart/templates/configmaps.yaml b/chart/templates/configmaps.yaml index 3ae6bbf5..4dea3bfc 100644 --- a/chart/templates/configmaps.yaml +++ b/chart/templates/configmaps.yaml @@ -1,5 +1,5 @@ {{- $cPwd := randAlphaNum 12 | nospace -}} -{{- $sName := randAlphaNum 6 | nospace -}} +{{- $sName := "" -}} apiVersion: v1 kind: ConfigMap metadata: @@ -33,4 +33,8 @@ data: COMMUNITY: "true" SERVER_PASSWORD: {{- if .Values.server.config.community.password }} "{{ .Values.server.config.community.password }}" {{ else }} {{ $cPwd }} {{ end }} {{ end }} - SERVER_NAME: {{- if .Values.server.config.server_name }} "{{ .Values.server.config.server_name }}" {{ else }} {{ printf "%s_%s" "palworld" $sName }} {{ end }} \ No newline at end of file + {{ 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 }} \ No newline at end of file From c8ad151018a2ed2b80470437eca6df9e068d94c8 Mon Sep 17 00:00:00 2001 From: Filipe Souza Date: Thu, 25 Jan 2024 09:14:58 -0300 Subject: [PATCH 6/9] - Updated README to lint spec; --- chart/README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/chart/README.md b/chart/README.md index 5cb389cb..1b3a6b4a 100644 --- a/chart/README.md +++ b/chart/README.md @@ -1,6 +1,7 @@ # 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. +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. @@ -10,11 +11,13 @@ You will need the [Helm client](https://helm.sh/docs/intro/install/) and a Kuber ## 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. +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 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: From 52c2a295029b75789215b2acfe659c614173dd0b Mon Sep 17 00:00:00 2001 From: Thijs van Loef <58031337+thijsvanloef@users.noreply.github.com> Date: Thu, 25 Jan 2024 13:38:51 +0100 Subject: [PATCH 7/9] Update README.md --- chart/README.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/chart/README.md b/chart/README.md index 1b3a6b4a..81d7b7f6 100644 --- a/chart/README.md +++ b/chart/README.md @@ -1,6 +1,6 @@ # Palworld Helm Chart -Allows you to deploy the usage of [Palworld Server docker](https://github.com/Filipe-Souza/palworld-server-docker) as +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. @@ -11,13 +11,13 @@ You will need the [Helm client](https://helm.sh/docs/intro/install/) and a Kuber ## 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 +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 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: @@ -30,6 +30,3 @@ You can remove all the resources created (except the PVC) with the following com ```bash helm uninstall -n palworld palworld ``` - - - From c167f0cbb572fe86b6bde7da5469f418f4ff2af7 Mon Sep 17 00:00:00 2001 From: Thijs van Loef <58031337+thijsvanloef@users.noreply.github.com> Date: Thu, 25 Jan 2024 13:40:02 +0100 Subject: [PATCH 8/9] Update VALUES_SUMMARY.md --- chart/VALUES_SUMMARY.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/chart/VALUES_SUMMARY.md b/chart/VALUES_SUMMARY.md index 7304d20f..12928ab9 100644 --- a/chart/VALUES_SUMMARY.md +++ b/chart/VALUES_SUMMARY.md @@ -1,6 +1,8 @@ # palworld -![Version: 0.0.0](https://img.shields.io/badge/Version-0.0.0-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) +![Version: 0.0.0](https://img.shields.io/badge/Version-0.0.0-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 can provide an rAthena emulator installation on a Kubernetes cluster. From 19680165d03b1f143fa789b13978bd308254c4a3 Mon Sep 17 00:00:00 2001 From: Thijs van Loef <58031337+thijsvanloef@users.noreply.github.com> Date: Thu, 25 Jan 2024 13:40:49 +0100 Subject: [PATCH 9/9] Update VALUES_SUMMARY.md --- chart/VALUES_SUMMARY.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/chart/VALUES_SUMMARY.md b/chart/VALUES_SUMMARY.md index 12928ab9..d95dab2b 100644 --- a/chart/VALUES_SUMMARY.md +++ b/chart/VALUES_SUMMARY.md @@ -1,8 +1,8 @@ # palworld -![Version: 0.0.0](https://img.shields.io/badge/Version-0.0.0-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) +![Version: 0.0.0](https://img.shields.io/badge/Version-0.0.0-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 can provide an rAthena emulator installation on a Kubernetes cluster.