From 56386e75b1d905223967606802446ac236daeb44 Mon Sep 17 00:00:00 2001 From: Xstar97TheNoob <9399967+xstar97@users.noreply.github.com> Date: Sun, 4 Feb 2024 01:42:22 -0500 Subject: [PATCH] fix(palworld) fix rcon sidecar and update docs and update probes (#17776) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Description** - Fixes rcon sidecar - mount a default file to persist the creds and host for the rcon command tool - updates docs - update probes ⚒️ Fixes # **⚙️ Type of change** - [ ] ⚙️ Feature/App addition - [X] 🪛 Bugfix - [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] 🔃 Refactor of current code **🧪 How Has This Been Tested?** **📃 Notes:** **✔️ Checklist:** - [X] ⚖️ My code follows the style guidelines of this project - [X] 👀 I have performed a self-review of my own code - [ ] #️⃣ I have commented my code, particularly in hard-to-understand areas - [X] 📄 I have made corresponding changes to the documentation - [ ] ⚠️ My changes generate no new warnings - [ ] 🧪 I have added tests to this description that prove my fix is effective or that my feature works - [X] ⬆️ I increased versions for any altered app according to semantic versioning **➕ App addition** If this PR is an app addition please make sure you have done the following. - [ ] 🖼️ I have added an icon in the Chart's root directory called `icon.png` --- _Please don't blindly check all the boxes. Read them and only check those that apply. Those checkboxes are there for the reviewer to see what is this all about and the status of this PR with a quick glance._ --------- Signed-off-by: Xstar97TheNoob <9399967+xstar97@users.noreply.github.com> Co-authored-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com> --- charts/incubator/palworld/Chart.yaml | 2 +- .../palworld/docs/installation_notes.md | 8 +- charts/incubator/palworld/docs/rcon_notes.md | 14 +++- .../incubator/palworld/docs/update_notes.md | 9 ++ charts/incubator/palworld/questions.yaml | 55 ++++++++++-- .../palworld/templates/_configmap.tpl | 17 ++++ .../incubator/palworld/templates/common.yaml | 12 ++- charts/incubator/palworld/values.yaml | 84 ++++++++++++------- 8 files changed, 162 insertions(+), 39 deletions(-) create mode 100644 charts/incubator/palworld/docs/update_notes.md create mode 100644 charts/incubator/palworld/templates/_configmap.tpl diff --git a/charts/incubator/palworld/Chart.yaml b/charts/incubator/palworld/Chart.yaml index 374b41531b6..80ef8be9a63 100644 --- a/charts/incubator/palworld/Chart.yaml +++ b/charts/incubator/palworld/Chart.yaml @@ -35,4 +35,4 @@ sources: - https://ghcr.io/ich777/steamcmd - https://hub.docker.com/r/outdead/rcon type: application -version: 0.1.3 +version: 0.1.4 diff --git a/charts/incubator/palworld/docs/installation_notes.md b/charts/incubator/palworld/docs/installation_notes.md index e8f9fc9f6e9..d95a95ccffe 100644 --- a/charts/incubator/palworld/docs/installation_notes.md +++ b/charts/incubator/palworld/docs/installation_notes.md @@ -2,12 +2,18 @@ title: PalWorld Installation Notes --- -::: note +:::note All app configuration defined in the GUI will take precedence over ANY manual configuration changed via the ini file. ::: +:::info + +You may need to restart the chart every 24 to 48hrs to keep the server from running out of memory and crashing. + +::: + ## Default Values | KEY | VALUE | diff --git a/charts/incubator/palworld/docs/rcon_notes.md b/charts/incubator/palworld/docs/rcon_notes.md index 5dd6e1697f7..2a183493292 100644 --- a/charts/incubator/palworld/docs/rcon_notes.md +++ b/charts/incubator/palworld/docs/rcon_notes.md @@ -4,7 +4,19 @@ title: PalWorld RCON Notes Shell into the app from the web gui or use heavyscript and select the RCON container; the following commands can be used. -::: note +A single command: + +```shell +./rcon info +``` + +A interactive shell: + +```shell +./rcon +``` + +:::note To use the same commands while in game; type in chat: diff --git a/charts/incubator/palworld/docs/update_notes.md b/charts/incubator/palworld/docs/update_notes.md new file mode 100644 index 00000000000..61d5413bfcb --- /dev/null +++ b/charts/incubator/palworld/docs/update_notes.md @@ -0,0 +1,9 @@ +--- +title: PalWorld Update Notes +--- + +:::note + +To update the server; restart the chart, it will download the latest available version when present. Highly recommend to checkout [rocn docs](./rcon_notes.md) to save the game prior to restarting it. + +::: diff --git a/charts/incubator/palworld/questions.yaml b/charts/incubator/palworld/questions.yaml index c09bb52015f..7707c56ea87 100644 --- a/charts/incubator/palworld/questions.yaml +++ b/charts/incubator/palworld/questions.yaml @@ -391,6 +391,42 @@ questions: schema: type: boolean default: false + - variable: public_ip + label: Public IP + schema: + type: string + default: "" + show_if: [[update_public_ip, "!=", "true"]] + - variable: params + label: Game Params + schema: + type: list + default: + - EpicApp=PalServer + required: true + items: + - variable: param + label: Param + schema: + type: string + required: true + default: "" + - variable: params_extra + label: Game Params Extra + schema: + type: list + default: + - -useperfthreads + - -NoAsyncLoadingThread + - -UseMultithreadForDS + required: true + items: + - variable: extra_param + label: Extra Param + schema: + type: string + required: true + default: "" - variable: backup label: Backup Configuration schema: @@ -419,27 +455,32 @@ questions: min: 1 # Include{containerConfig} -# Include{podOptions} # Include{serviceRoot} -# Include{serviceMain} + - variable: main + label: Main Service + description: The Primary service on which the healthcheck runs, often the webUI + schema: + additional_attrs: true + type: dict + attrs: # Include{serviceSelectorLoadBalancer} # Include{serviceSelectorExtras} - variable: main - label: "Main Service Port Configuration" + label: Main Service Port Configuration schema: additional_attrs: true type: dict attrs: - variable: port - label: "Port" - description: "This port exposes the container port on the service" + label: Port + description: This port exposes the container port on the service schema: type: int default: 8211 required: true - variable: rcon - label: RCON Service - description: The RCON service. + label: RCON service + description: RCON Service Port Configuration schema: additional_attrs: true type: dict diff --git a/charts/incubator/palworld/templates/_configmap.tpl b/charts/incubator/palworld/templates/_configmap.tpl new file mode 100644 index 00000000000..915455e7133 --- /dev/null +++ b/charts/incubator/palworld/templates/_configmap.tpl @@ -0,0 +1,17 @@ +{{/* Define the configmap */}} +{{- define "palworld.configmaps" -}} +{{- $fullname := (include "tc.v1.common.lib.chart.names.fullname" $) -}} + +{{- $adminPassword := .Values.palworld.game.admin_password -}} +{{- $rconPort := .Values.service.rcon.ports.rcon.port }} + +palworld-rcon: + enabled: true + data: + rcon.yaml: | + default: + address: "{{ printf "%v-rcon:%v" $fullname $rconPort }}" + password: {{ $adminPassword }} + log: "rcon-palworld.log" + timeout: "10s" +{{- end -}} diff --git a/charts/incubator/palworld/templates/common.yaml b/charts/incubator/palworld/templates/common.yaml index b51394e00a4..aa8a6f48691 100644 --- a/charts/incubator/palworld/templates/common.yaml +++ b/charts/incubator/palworld/templates/common.yaml @@ -1 +1,11 @@ -{{ include "tc.v1.common.loader.all" . }} +{{/* Make sure all variables are set properly */}} +{{- include "tc.v1.common.loader.init" . -}} + +{{/* Render configmaps for all pods */}} +{{- $configmaps := include "palworld.configmaps" . | fromYaml -}} +{{- if $configmaps -}} + {{- $_ := mustMergeOverwrite .Values.configmap $configmaps -}} +{{- end -}} + +{{/* Render the templates */}} +{{- include "tc.v1.common.loader.apply" . -}} diff --git a/charts/incubator/palworld/values.yaml b/charts/incubator/palworld/values.yaml index c627d94774a..b827d7ae154 100644 --- a/charts/incubator/palworld/values.yaml +++ b/charts/incubator/palworld/values.yaml @@ -93,6 +93,7 @@ palworld: region: "" work_speed_rate: "1.000000" update_public_ip: false + public_ip: "" params: - EpicApp=PalServer params_extra: @@ -120,6 +121,7 @@ workload: config={{ .Values.persistence.serverfiles.targetSelector.main.main.mountPath }}/Pal/Saved/Config/LinuxServer cfgFile=${config}/PalWorldSettings.ini dfCfgFile={{ .Values.persistence.serverfiles.targetSelector.main.main.mountPath }}/DefaultPalWorldSettings.ini + update_public_ip="{{ .Values.palworld.game.update_public_ip }}" mkdir -p ${config} if [ ! -f "${cfgFile}" ]; then @@ -134,24 +136,43 @@ workload: fi set_ini_value() { - local key="${1}" - local value="${2}" - local quote_flag="${3:-}" + local key="${1}" + local value="${2}" + local quote_flag="${3:-}" - # Check if the key exists - if ! grep -q "${key}=" "${cfgFile}"; then - echo "Key '${key}' does not exist in '${cfgFile}'. Skipping..." - return - fi + # Check if the key exists in the OptionSettings section + if ! grep -q 'OptionSettings=(' "$cfgFile"; then + echo "OptionSettings section not found in '${cfgFile}'. Skipping..." + return + fi - if [ "$quote_flag" = "-q" ]; then - # Add quotes around the value - value="\"$value\"" - fi + # Check if the key exists within the OptionSettings section + if ! grep -q "${key}=" "$cfgFile"; then + echo "Key '${key}' does not exist in the OptionSettings section of '${cfgFile}'. Skipping..." + return + fi - echo "Setting ${key}..." - sed -i "s|\(${key}=\)[^,]*|\1${value}|g" "${cfgFile}" - echo "Set to $(grep -Po "(?<=${key}=)[^,]*" "${cfgFile}")" + # Add quotes around the value if quote_flag is set + if [ "$quote_flag" = "-q" ]; then + value="\"$value\"" + fi + + # Update the value within the OptionSettings section + sed -i "/OptionSettings=(/ { + :loop + /)$/! { + N + b loop + } + s|\(${key}=\)[^,]*|\1${value}| + }" "${cfgFile}" + + # Check if the closing parenthesis is missing, and if so, add it + if ! grep -q ')$' "${cfgFile}"; then + sed -i "\|OptionSettings=(| s|$|)|" "${cfgFile}" + fi + + echo "Set ${key} to ${value}" } echo "the following options are updating...." @@ -160,15 +181,15 @@ workload: set_ini_value "RCONPort" "{{ .Values.service.rcon.ports.rcon.port }}" -q set_ini_value "PublicPort" "{{ .Values.service.main.ports.main.port }}" -q - set_ini_value "ServerPassword" "{{ .Values.palworld.game.password }}" -q - set_ini_value "AdminPassword" "{{ .Values.palworld.game.admin_password }}" -q + set_ini_value "ServerPassword" '{{ .Values.palworld.game.password }}' -q + set_ini_value "AdminPassword" '{{ .Values.palworld.game.admin_password }}' -q - set_ini_value "ServerName" "{{ .Values.palworld.game.name }}" -q - set_ini_value "ServerDescription" "{{ .Values.palworld.game.description }}" -q + set_ini_value "ServerName" '{{ .Values.palworld.game.name }}' -q + set_ini_value "ServerDescription" '{{ .Values.palworld.game.description }}' -q set_ini_value "Difficulty" "{{ .Values.palworld.game.difficulty }}" -q set_ini_value "DeathPenalty" "{{ .Values.palworld.game.death_penalty }}" -q set_ini_value "Region" "{{ .Values.palworld.game.region }}" -q - + set_ini_value "AutoResetGuildTimeNoOnlinePlayers" "{{ .Values.palworld.game.auto_reset_guild_time_no_online_players }}" set_ini_value "BaseCampMaxNum" "{{ .Values.palworld.game.base_camp_max }}" set_ini_value "BaseCampWorkerMaxNum" "{{ .Values.palworld.game.base_camp_worker_max }}" @@ -221,6 +242,10 @@ workload: set_ini_value "WorkSpeedRate" "{{ .Values.palworld.game.work_speed_rate }}" set_ini_value "ExpRate" "{{ .Values.palworld.game.exp_rate }}" + # Check if update_public_ip is not true + if [ "${update_public_ip}" != "true" ]; then + set_ini_value "PublicIP" "{{ .Values.palworld.game.public_ip }}" -q + fi echo "Done!" containers: main: @@ -245,7 +270,7 @@ workload: VALIDATE: "{{ .Values.palworld.steam.validate }}" # game SRV_ADMIN_PWD: "{{ .Values.palworld.game.admin_password }}" - UPDATE_PUBLIC_IP: "{{ .Values.palworld.game.update_public_ip }}" + UPDATE_PUBLIC_IP: "{{ .Values.palworld.game.update_public_ip }}" GAME_PARAMS: '{{ join " " .Values.palworld.game.params }}' GAME_PARAMS_EXTRA: '{{ join " " .Values.palworld.game.params_extra }}' # backup @@ -272,12 +297,6 @@ workload: enabled: false startup: enabled: false - args: - - ./rcon - - -a - - '{{ printf "%v-rcon:%v" (include "tc.v1.common.lib.chart.names.fullname" $) .Values.service.rcon.ports.rcon.port }}' - - -p - - "{{ .Values.palworld.game.admin_password }}" persistence: steamcmd: @@ -291,7 +310,16 @@ persistence: mountPath: /serverdata/serverfiles update-config-ini: mountPath: /serverdata/serverfiles - + palworld-rcon: + enabled: true + type: configmap + objectName: palworld-rcon + targetSelector: + rcon: + rcon: + mountPath: /rcon.yaml + subPath: rcon.yaml + readOnly: true portal: open: enabled: false