itzg / minecraft-server-charts

MIT License
279 stars 144 forks source link

Allow velocity forwarding secret to be passed as value (`minecraft-proxy`) #236

Closed skylerspaeth closed 3 weeks ago

skylerspaeth commented 3 weeks ago

Description

This repo indicates support for running a Velocity proxy, but without my proposed changes, I cannot spin one up when player-info-forwarding-mode is set to modern (which I have heard is the only safe way to run Velocity).

This is due to the file at the default forwarding-secret-file path being missing. Since there is no apparent way to provide one without manual customizations, I figured I'd PR the changes I made back to master.

I'm coming into this project completely new, so forgive me if things are done differently than y'all usually do. Happy to make changes if needed. I used the config volume mount (just above my new one) as an example:

- name: config
  mountPath: {{ .Values.minecraftProxy.configFilePath }}
  subPath: config.yml

Hence why mysubPath and path under the volumes section are hardcoded too (to forwarding.secret). That said, I assume the implication of doing so is that no matter what the user provides as velocityForwardingSecretFilePath, the filename is going to remain the same, even though its location may change. I'm willing to adjust if needed.

Additionally, I added the example provided in this PR over 3 years ago to the values.yaml file, which will hopefully save others time trying to figure out how to configure Velocity with this chart: https://github.com/itzg/minecraft-server-charts/pull/65#discussion_r608180401

Thank you @ChipWolf for that info! 🙏

Testing

I ensured both the changes worked together: example Velocity config along with forwarding changes. I couldn't test them individually because, at least in my case and with my knowledge, both are needed to prevent the pod from crashing.

To test them together, I used the following values.yaml, which contains the exact examples added to the upstream values file:

minecraftProxy:
  type: VELOCITY
  velocityVersion: 3.4.0-SNAPSHOT
  serviceType: NodePort
  nodePort: 30565
  velocityForwardingSecret: "CHANGEME!"
  velocityForwardingSecretFilePath: /server/forwarding.secret
  configFilePath: /server/velocity.toml
  config: |-
    config-version = "2.7"
    bind = "0.0.0.0:25577"
    motd = "Hello from Helmified Velocity!"
    show-max-players = 500
    player-info-forwarding-mode = "modern"

The proxy shows up as expected in-game:

image

Even though I didn't mess with anything related to it, I also briefly tested the chart in the default BungeeCord mode just in case, and the MOTD appropriately changed back to the BungeeCord one in my server list.

I did not test these changes on any other sever types but I can't imagine there's any impact.

Related Links

This is a list of helpful PRs and links that I referenced when making this PR (mostly here for my own future reference):