factorio

by funkypenguin

Helm chartv1.2.2App stableVerified publisher

Factorio dedicated steam game server

About this chart

factorio

Factorio dedicated steam game server

This chart is not maintained by the upstream project and any issues with the chart should be raised here

Source Code

Requirements

Kubernetes: >=1.16.0-0

Dependencies

RepositoryNameVersion
https://library-charts.k8s-at-home.comcommon4.5.2

TL;DR

helm repo add k8s-at-home https://k8s-at-home.com/charts/
helm repo update
helm install factorio k8s-at-home/factorio

Installing the Chart

To install the chart with the release name factorio

helm install factorio k8s-at-home/factorio

Uninstalling the Chart

To uninstall the factorio deployment

helm uninstall factorio

The command removes all the Kubernetes components associated with the chart including persistent volumes and deletes the release.

Configuration

Read through the values.yaml file. It has several commented out suggested values. Other values may be used from the values.yaml from the common library.

Specify each parameter using the --set key=value[,key=value] argument to helm install.

helm install factorio \
  --set env.TZ="America/New York" \
    k8s-at-home/factorio

Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart.

helm install factorio k8s-at-home/factorio -f values.yaml

Custom configuration

Cart credits

This chart is partially inspired by https://github.com/SQLJames/factorio-server-charts and the yaml for the server settings defaults is sourced from here. Many thanks to @SQLJames for his work on that chart and the inspiration.

Keeping server up to date

By default, this helm chart will follow Factoriotools/Factorio:stable. Game servers need to be kept up to date regularly, but you might not want it updating during gameplay with traffic being forwarded from your router through open ports The author recommends a approach of setting a tag: in your values.yaml to pin a specific version, and using a solution like Renovate-bot to control updates. This can be best achieved to pinning to a specific sha release, which allows you to set the tag to follow.

Note that by default renovate follows latest which can sometimes be undesirable for this image. The author notes that stable follows the version declared stable on [Factorio.com[(https://Factorio.com)] and on Steam, and latest can at times diverge into testing/beta releases (which require a Steam opt-in for downloading with traffic being forwarded from your router through open ports

Pinning to one node

Whilst not best practice in k8s, it may be desirable to pin a game server to a node, so it is getting a paticular CPU (i.e. targeting best core performance).

# Prefer higher single core speed node
affinity:
    nodeAffinity:
    preferredDuringSchedulingIgnoredDuringExecution:
        - weight: 1
        preference:
            matchExpressions:
            - key: kubernetes.io/hostname
                operator: In
                values:
                - <yourhostname>

Map generation

This chart has yaml to allow you to pick map gen settings for first load. One way that may be eaiser to get a map howver, is to generate the map in your local game with the UI, ensure you are happy with it. You can run this helm once with default settings (to generate the folder structure in a PVC), spin it back down and mount the pvc in a test pod. You can then copy your generated map.zip to the container and spin it back up - the server will load the 'latest' save and run your map.

Networking

Networking may be a challenge as Factorio uses UDP. One approach can be to use a load balancer in front of the service, with traffic being forwarded from your router through open ports pointed at the load balancer. A load balancer could be set in this chart, for example with this addition (using metallb for load-balancing):

service:
  main:
    ports:
      http:
        server:
            enabled: true
            type: LoadBalancer # Setting Ip external to cluster for easy port forward
            externalTrafficPolicy: Cluster
            loadBalancerIP: "192.168.2.100" # Set a IP here to ensure the game server is given a static internal IP
            annotations:
                metallb.universe.tf/allow-shared-ip: factorio
            ports:
                factorio-game:
                port: 34201
                protocol: UDP
                targetPort: 34197
        rcon:
            enabled: false
            type: LoadBalancer # Setting Ip external to cluster for easy port forward
            externalTrafficPolicy: Cluster
            loadBalancerIP: "192.168.2.100" # Set a IP here to ensure the game server is given a static internal IP
            annotations:
                metallb.universe.tf/allow-shared-ip: factorio
            ports:
                factorio-rcon:
                enabled: true
                port: 27015
                protocol: TCP
                targetPort: 27015

Values

Important: When deploying an application Helm chart you can add more values from our common library chart here

KeyTypeDefaultDescription
configobjectSee values.yamlConfigure server settings. Can be disabled if you wish to configure in the container in the json config files. -- See values.yaml for descriptions for many config options, ore refer to https://wiki.factorio.com/Multiplayer.
config.ban_liststringnil- "jane_doe"
config.factorioServer.generate_new_saveboolfalseGenerate a New Save
config.factorioServer.load_latest_savebooltruelets the game know if you want to load the latest save
config.factorioServer.save_namestring"_autosave1"name to be used for save
config.factorioServer.tokenstringnilfactorio.com token
config.factorioServer.update_mods_on_startboolfalseUpdate mods on start
config.factorioServer.usernamestringnilfactorio.com password
config.map_gen_settings.cliff_settings.cliff_elevation_0int10Elevation of first row of cliffs
config.map_gen_settings.cliff_settings.cliff_elevation_intervalint40Elevation difference between successive rows of cliffs. -- This is inversely proportional to frequency in the map generation GUI. Specifically, when set from the GUI the value is 40 / frequency.
config.map_gen_settings.cliff_settings.namestring"cliff"Name of the cliff prototype
config.map_gen_settings.cliff_settings.richnessint1Called cliff continuity in the map generator GUI. 0 will result in no cliffs, 10 will make all cliff rows completely solid
config.map_gen_settings.heightint0Width and height of map, in tiles; 0 means infinite
config.map_gen_settings.property_expression_namesobject{"control-setting:aux:bias":"0","control-setting:aux:frequency:multiplier":"1","control-setting:moisture:bias":"0","control-setting:moisture:frequency:multiplier":"1"}Overrides for property value generators (map type) -- Leave elevation blank to get normal terrain. -- Use ''elevation'': ''0_16-elevation'' to reproduce terrain from 0.16. -- Use ''elevation'': ''0_17-island'' to get an island. -- Moisture and terrain type are also controlled via this. -- "control-setting:moisture:frequency:multiplier is the inverse of the moisture scale in the map generator GUI." -- "control-setting:moisture:bias is the moisture bias in the map generator GUI." -- "control-setting:aux:frequency:multiplier is the inverse of the terrain type scale in the map generator GUI." -- "control-setting:aux:bias is the teraain type bias in the map generator GUI."
config.map_gen_settings.seedstringnilUse null for a random seed, number for a specific seed.
config.map_gen_settings.starting_areaint1Multiplier for biter free zone radius
config.map_gen_settings.terrain_segmentationint1The inverse of water scale in the map generator GUI.
config.map_gen_settings.waterint1The equivalent to water coverage in the map generator GUI. Higher coverage means -- more water in larger oceans. -- Water level = 10 * log2(this value)
config.map_gen_settings.widthint0Width and height of map, in tiles; 0 means infinite
config.map_settings.pollution.diffusion_ratiofloat0.02these are values for 60 ticks (1 simulated second) -- amount that is diffused to neighboring chunk
config.rconobject{"external":true,"password":"replaceme","port":30100,"type":"LoadBalancer"}Password and port for the rcon service
config.server_settings.afk_autokick_intervalint0How many minutes until someone is kicked when doing nothing, 0 for never.
config.server_settings.allow_commandsstring"admins-only"possible values are, true, false and admins-only
config.server_settings.auto_pausebooltrueWhether should the server be paused when no players are present.
config.server_settings.autosave_intervalint10Autosave interval in minutes
config.server_settings.autosave_only_on_serverbooltrueWhether autosaves should be saved only on server or also on all connected clients. Default is true.
config.server_settings.autosave_slotsint5server autosave slots, it is cycled through when the server autosaves.
config.server_settings.descriptionstring"Factorio running on Kubernetes"Your Instance Description
config.server_settings.game_passwordstring""password required to log into the factorio server
config.server_settings.ignore_player_limit_for_returning_playersboolfalsePlayers that played on this map already can join even when the max player limit was reached.
config.server_settings.max_playersint0Maximum number of players allowed, admins can join even a full server. 0 means unlimited.
config.server_settings.max_upload_in_kilobytes_per_secondint0optional, default value is 0. 0 means unlimited.
config.server_settings.max_upload_slotsint5optional, default value is 5. 0 means unlimited.
config.server_settings.minimum_latency_in_ticksint0optional one tick is 16ms in default speed, default value is 0. 0 means no minimum.
config.server_settings.minimum_segment_sizeint25Long network messages are split into segments that are sent -- over multiple ticks. Their size depends on the number of peers currently connected. -- Increasing the segment size will increase upload bandwidth requirement for the server -- and download bandwidth requirement for clients. This setting only affects server -- outbound messages. Changing these settings can have a negative impact on connection -- stability for some clients.
config.server_settings.namestring"Factorio"Your Instance Name
config.server_settings.non_blocking_savingboolfalseHighly experimental feature, enable only at your own -- risk of losing your saves. On UNIX systems, server will fork itself to create an -- autosave. Autosaving on connected Windows clients will be disabled regardless of -- autosave_only_on_server option.
config.server_settings.only_admins_can_pause_the_gamebooltruespecifies if anyone can pause or only admins
config.server_settings.require_user_verificationboolfalseWhen set to true, the server will only allow clients that have a valid Factorio.com account
config.server_settings.tokenstring""Authentication token. May be used instead of password above.
config.server_settings.usernamestring""Your factorio.com login credentials. Required for games with visibility public
config.server_settings.visibilityobject{"lan":true,"public":false}Game visibility
config.server_settings.visibility.lanbooltrueGame will be broadcast on LAN
config.server_settings.visibility.publicboolfalseGame will be published on the official Factorio matching server
config.white_liststringnil- "jane_doe"
envobjectSee belowenvironment variables. See more environment variables in the factorio documentation.
env.GENERATE_NEW_SAVEstring"{{ .Values.config.factorioServer.generate_new_save }}"Generate a new save if one does not exist before starting the server
env.LOAD_LATEST_SAVEstring"{{ .Values.config.factorioServer.load_latest_save }}"Load latest when true. Otherwise load SAVE_NAME
env.PORTstring"{{ .Values.service.main.ports.server.port }}"UDP port the server listens on
env.RCON_PORTstring"{{ .Values.service.main.ports.rcon.port }}"TCP port the rcon server listens on
env.SAVE_NAMEstring"{{ .Values.config.factorioServer.save_name }}"Name to use for the save file
env.TOKENstring"{{ .Values.config.factorioServer.token }}"factorio.com token
env.TZstring"UTC"Set the container timezone
env.UPDATE_MODS_ON_STARTstring`"{{ .Values.config.factorioServer.upda

Deploy factorio with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has factorio on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartfactorio is pinned at v1.2.2 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply