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.

The content below is editable! Feel free to modify any of the values before applying.

We'll begin by configuring a PersistentVolumeClaimA PersistentVolumeClaim is a request for storage - it asks the Kubernetes Cluster for a particular type of storage which it can use as a Volume.Read More... 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.

Apply
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: factorio-pv-claim
labels:
app: factorio
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Mi
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Once you've applied the volume claim config, the second resource is the DeploymentIn Kubernetes, a Deployment is an object which describes how an application is deployed. A Deployment defines the images to launch, how to configure them, and how they should be deployedRead More.... 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.

Apply
---
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
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

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 PersistentVolumeClaimA PersistentVolumeClaim is a request for storage - it asks the Kubernetes Cluster for a particular type of storage which it can use as a Volume.Read More... 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 hobby tier, starting at $7! See our pricing page for more.

Stay in the loop!

We're working hard to make Kubernetes easy to learn and use! Give us a shout on twitter or gitter, checkout some of our GitHub repos and be sure to join our mailing list!