How to run a free factorio server

Dan Pastusek
Mar 10, 2019

TL;DR: Click both "apply" buttons below and have a running factorio server

Factorio 0.17 is here, and you need a server for you and your friends to play on. You also want to run it for free, on the latest, most resilient infrastructure. If so, this tutorial is for you. At the end, you'll have a working factorio server, running on Kubernetes.

We'll begin by configuring a PersistentVolumeClaim which is a request for storage. For this demo, we'll configure a small claim for 20mb, or enough storage to run a factorio game for a few days worth of play.

editApply YAML
Free KubeSail Cluster
or
Your Cluster
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: factorio-pv-claim
  labels:
    app: factorio
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 20Mi

Once you've applied the volume claim config, the second resource is the Deployment. This is the configuration that tells Kubernetes which Docker image to run (in our case the excellent factorio server by dtanderson). As recommended from the image's documentation page, we'll mount the volume via mountPath: /factorio so the saves persist between game server restarts. We also configure it with a maximum of 128Mb of memory, and 1 CPU enough to fit within the free tier on KubeSail.

editApply YAML
Free KubeSail Cluster
or
Your Cluster
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: factorio
spec:
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: factorio
  replicas: 1
  template:
    metadata:
      labels:
        app: factorio
    spec:
      volumes:
        - name: factorio-persistent-storage
          persistentVolumeClaim:
            claimName: factorio-pv-claim
      containers:
        - name: factorio
          image: dtandersen/factorio:latest
          imagePullPolicy: Always
          ports:
            - name: game-port
              containerPort: 34197
          resources:
            requests:
              cpu: 10m
              memory: 128Mi
            limits:
              cpu: 1
              memory: 256Mi
          volumeMounts:
            - mountPath: /factorio
              name: factorio-persistent-storage

Once applied, you will need to expose your deployment to the internet. Open up your deployments dashboard and click the Expose to Internet (TCP) button. Once you do, you'll get the full address (hostname and port) which you can connect to from your factorio client!

Port Options

Disk usage

In our PersistentVolumeClaim YAML, you'll notice we set our storage request to 20Mb - KubeSail's free tier hosting is limited to 25Mb, which will serve you well for a while - but a well-loved factorio map can exceed that size! We offer 32Gb of expandable storage on our starter tier, starting at $7! See our pricing page for more.

Stay in the loop!

Give us a shout on twitter or gitter, check out some of our GitHub repos and be sure to join our mailing list!