Running Valheim Server On MicroK8s




MicroK8s is a self contained Kubernetes cluster. It can be used on most Linux distros and even Windows and Mac. We’re going to use Kubernetes, provided by MircoK8s, to maintain all of the moving parts of our Valheim server.


Valheim, available on Linux and Windows, is currently one of the most popular games on Steam despite only being in early access! It’s a co-op survival game based in the Viking afterlife; perfect to play with friends across the globe.


A bare metal or cloud instance. This should have 8GB of RAM, a few cores and some storage space for Valheim to save its state files. It also, obviously, requires an internet connection and a public IP address.

The host should have snapd installed.

We also need a place to store persistent data. In this example, I’ll be using /media/k8s/valheim, but this can be set anywhere that MicroK8s has permission to read and write.


For this demonstration, we’ll focus on a server running Linux. MicroK8s is available on Windows and Mac but would require a couple of extra steps in order to have a public IP, which is out of the scope of this blog.


Install MicroK8s.

sudo snap install microk8s --classic

Enable the required add-ons to give functionality we need.

sudo microk8s enable dns ingress storage

We can wait for for everything to settle or just continue to the next step.

sudo microk8s status --wait-ready


Now that we have a Kubernetes cluster to run our Valheim server, we can configure and deploy it.

Thank you to cbrgm who as already created a container image of the Valheim server. We’ll be using this.

I’ve created a Kubernetes manifest that’s been tailored for MicroK8s. We need to clone it.

git clone
cd microk8s-valheim

We must then create a secrets file to define the server’s name, world and password. I’ve bundled an example we can base off.

cp ./examples/secrets.yaml .

The three values under data should be changed. These are set in base64 (if you try to use plaintext, the secrets will be rejected). To convert plaintext into base64, we can just use echo and base64.

echo "VALUE" | base64

After you’ve done this for your three values, use your editor of choice to paste them into secrets.yaml.

If you want to change the directory that the server will write to, change it in deployment.yaml. If you’re happy with the example, we need to create it and set the right permissions.

sudo mkdir -p /media/k8s/valheim
sudo chown ${USER}:microk8s /media/k8s/valheim
sudo chmod 775 /media/k8s/valheim

Let’s deploy into the valheim namespace.

sudo microk8s kubectl apply -f ./deployment.yaml -f ./secrets.yaml

The server will take a little while to install and start running. We can watch it with the following.

watch -cd -n1 sudo microk8s kubectl get all -n valheim

Once up, the server will be running on 32456, 32457 and 32458. If you decide to change this, it must correspond to the port the server is running on.

To connect to this server via Steam, you need to go to View -> Servers click the Favourites tab and then click Add A Server. The address will be your public IP plus the port 32457. Example:

Once you’ve entered the address, click Find Games At This Address... and the server should appear.

Tear Down

If you want to remove everything, including MicroK8s.

sudo snap remove microk8s --purge

You can remove just the Valheim server by cding into the repository we cloned earlier and running this.

sudo microk8s kubectl delete -f ./deployment.yaml -f ./secrets.yaml

Either way, the server’s state files will remain in sudo chmod 775 /media/k8s/valheim. This can be deleted too or kept in case you want to revive the server one day.

comments powered by Disqus