DEV Community

loading...
Cover image for Tutorial - Minecraft server running in Kubernetes on releasehub.com (free)

Tutorial - Minecraft server running in Kubernetes on releasehub.com (free)

tmcclung
Co-founder/CEO Release. Ycombinator W20, S09. Oregon State alum. Proud baseball Dad.
Originally published at releasehub.com Updated on ・9 min read

Setup your own free Minecraft Server running on releasehub.com

One of the coolest things about working at Release has been figuring out all of the fun stuff that we can do with the platform. While our main use case is helping people build environments for their applications, anything that runs in Docker will run easily on Release.

Early on, I found a handful of repos that helped us build out our platform. One that has been the most fun all along is the docker-minecraft-server from itzg. I used it in the early days because it had a little complexity and a fully working docker-compose ecosystem to play around with. It’s got the great side effect of when it runs, I let my kids test it out!

So while you’re sipping on egg nog and enjoying a 2020 Holiday season on COVID lock-down, here’s a walkthrough of how to get your very own free Minecraft server up and running on Release. 

I highly recommend following along on the video tutorial. I've included step by step instructions for anyone that learns better through reading or if you're confused about a step.

If you want to see a live version of this setup, we fired up our own Minecraft server that we built using these steps. So if you're bored over the Holidays, pop in and say hello! Here's our Server name if you want to say hi.

Play Minecraft With Us on the Release Team Minecraft Server

team-release-minecraft.releaseapp.io

Full video walkthrough of this tutorial

Detailed instructions to get your Minecraft Server up and running

Background

At the time of this writing, we have a “Starter” plan that’s free so you can give this a shot and have some Holiday fun on Release. Since we’re hosting all of the environments on Release on the starter plan we have a limitation of 2Gb/container. That’s sufficient for a Minecraft server for your kids and their friends.

To get started, take a look at https://github.com/awesome-release/docker-minecraft-server, which we cloned from itzg. Fork or clone this repo into your GitHub account so you’ve got your own version of it to play around with.

Once you’ve got your own repo to work with, I recommend taking a quick read through the README, there are a lot of configuration options and the documentation is extremely well done. 

We're also going to use the Rcon Web Administrative portal. Take a look at the documentation, specifically the environment variables that can be configured. itzg made a version of this for Docker called docker-rcon-web-admin that we are using when when we load the rcon and rcon-ws services in this tutorial.

For this walkthrough, we’re going to bring up a vanilla Minecraft server with an Rcon administrative portal running in a standalone container. This will let you and your kids have full control over the Minecraft server and ban friends who can’t fight off Zombie Pig Men. Here's an overview of what the system architecture looks like.

High level overview of Minecraft with Rcon

The master branch of this repo is already setup to work with this docker-compose file in Release. Take a look at the .release.yaml file in the root of the repo’s directory.

compose: examples/docker-compose-with-rcon.yml
Enter fullscreen mode Exit fullscreen mode

This sets the compose directive to `examples/docker-compose-with-rcon.yml’ which tells Release that’s the docker-compose file you want to use. If you want to play around with a Forge server or other examples, just point the .release.yaml file at the corresponding docker-compose.

1. Create a new application in Release

Ok, let’s setup the server.

Create new app button

  • Select your docker-minecraft-server repo. If you don’t see it in the list, click Configure the Release app on Github link to assign permissions to your repo.

Select your repo

  • Add a name for your application. Note this name is used in your server hostname.
  • Click Generate App Template. 

Click Generate App Template

2. Edit the generated application template

Release automatically detects and creates an application template from the docker-compose file but there are a few edits we need to make based on how this repo works and to make sure we can fit the server into the Starter plan. If you want to dive in, read the documentation about Release Application Templates.

For a little background, take a look at this diagram.

docker-minecraft-server networking architecture

We need to make our application reflect this networking setup.

In Release we have two different kinds of loadbalancers based on Amazon's ELB's and ALB's.

We also need to make sure we're using the correct type of port for the use case. There are two types of ports container_port and node_port. In short, a node_port is exposed to the Internet and a conatiner_port is not. Because the rcon service is only internally facing, we want to set its port to a container_port. For more info on setting the correct type of port, read about ports in Release.

So let's make the changes necessary to setup the Application Template correctly.

Update memory to 2Gb

Increase to 2gi

  • The Minecraft server is setup to use 1Gb of max memory so we need to set the default memory limit in Release to 2Gb to leave enough room with some overhead. Edit the app template to allow the services to use up to 2Gb of memory.

Update hostnames and ports

Change ports settings on the minecraft service

  • Change the port type for 25575 to container_port and remove the target_port line.
  • Add a loadbalancer: true for port 25565.
  • Add a hostname field at the same level as ports in the file and set to hostname: my-server-${env_id}-${domain}. You can set my-server to anything you'd like. ${env_id} and ${domain} are variables that Release will automatically fill in to customize your domain.

remove minecraft alb

  • Remove the ALB hostname for the minecraft service. (We only need the minecraft service exposed on port 25565 via an ELB not an ALB which is for http/https).
  • Click "Save and Continue".

3. Setup Environment Variables

We need to set a few passwords via environment variables and an environment variable mapping for the rcon websocket hostname. For more information about these environment variables, see the documentation/README files here:

In this diagram we show the passwords that need to be set via environment variables.

Passwords via environment variables

Setup passwords via environment variables

rcon password envs

On the minecraft service we need to set a password for its local rcon service on port 25575 so other containers can connect to it. RCON_PASSWORD is the environment variable that needs to be set for this and on the rcon and rcon-ws service we need to set RWA_RCON_PASSWORD to the same value so those services can control the minecraft server.

rcon web password

  • Click on "Edit" for "Default Environment Variables".
  • Set RCON_PASSWORD in the minecraft service and add secret: true. To encrypt this value in the database.
  • Set RWA_RCON_PASSWORD to the same value as you set in step 2 on both the rcon and rcon-ws services.
  • Set RWA_PASSWORD which will be the default password used for the RCON Web Administration tool in both the rcon and rcon-ws services. Make sure to add secret: true to encrypt this value.

Setup mapping of environment variable RWA_WEBSOCKET_URL_SSL

rwa webscoket hostname mapping

The last environment variable we need to add is a mapping that tells Release to map RWA_WEBSOCKET_URL_SSL to a dynamically created environment variable for hostnames created in Release RCON_WS_INGRESS_HOST. RWA_WEBSOCKET_URL_SSL tells the Rcon Web Admin tool which container host url is running the websocket for this service which is on our rcon-ws service on port 4327.

RCON_WS_INGRESS_HOST is automatically created everytime a new environment is created by Release and always conatins the correct hostname for rcon-ws. This value can change when new environments are created, thus we can't just hard set RWA_WEBSOCKET_URL_SSL. This is where an environment variable mapping comes into play. The diagram above represents the change we need to add in our Default Environment Variables.

set env mapping

  • Add a mapping: directive and map RWA_WEBSOCKET_URL_SSL to the top of the file.


mapping:
RWA_WEBSOCKET_URL_SSL: wss://${RCON_WS_INGRESS_HOST}

When these chages and your env passwords have been made, your file should look like this:

`

mapping:
RWA_WEBSOCKET_URL_SSL: wss://${RCON_WS_INGRESS_HOST}
defaults:

  • key: RWA_RCON_HOST
    value: minecraft
    services:
    minecraft:

    • key: EULA value: 'TRUE'
    • key: MAX_MEMORY value: 1G
    • key: ENABLE_RCON value: true
    • key: RCON_PASSWORD value: "rcon_password" secret: true
    • key: VIEW_DISTANCE value: 15
    • key: MAX_BUILD_HEIGHT value: 256 rcon:
    • key: RWA_RCON_HOST value: minecraft
    • key: RWA_RCON_PASSWORD value: "rcon_password" secret: TRUE
    • key: RWA_PASSWORD value: "rwa_password" secret: true rcon-ws:
    • key: RWA_RCON_HOST value: minecraft
    • key: RWA_RCON_PASSWORD value: "rcon_password" secret: TRUE
    • key: RWA_PASSWORD value: "rwa_password" secret: true `
  • Click 'Save & Deploy'

deploy and view environment

  • Your environment is now deploying, you can click on the deploy and watch its progress. When it's done, navigate to the environment screen and inspect your created hostnames.

4. Setup the Minecraft Client to Connect to your new server and login to the RCON web admin tool.

Setup minecraft server

  • Using the minecraft hostname that was created by Release, create a new server within the Minecraft Client.

rcon web admin tool

  • Click on the rcon hostname that was created by Release to access the RCON Web Admin user interface.
  • Login using the same password you set for the RWA_PASSWORD environment variable.
  • Add the minecraft server.
  • Add the console widget.
  • Run admin commands on your server!

What if it doesn't work???

If for any reason you made a mistake and something doesn't work. You can navigate to your App Settings and edit your Application Template and your Default Environment Variables. Double check you've made the proper settings. Once you've made these edits, navigate to your environments screen, delete your environment and create a new one. The beauty of Release is environments can be torn down and up whenever you want. Here are the links to the docs on how to edit your App Template and Default Environment Variables.

Delete and Create a new Environment

delete and create new environment

Conclusion

You now have your very own Minecraft Server running on the Release Starter Plan. This server was created in an Ephemeral Environment in Release and will destroy itself in 7 days. If you'd like your server to remain indefinitely, you'll need to delete the environment and re-create it as a permanent environment.

delete and create new environment

Make sure you choose permanent when creating the environment.

With the RCON Web Admin tool you can control and make the server your own special place. If you have any questions, please contact the Release team at hello@releasehub.com. Jump in and say hello on our Release Team Minecraft Server here:

team-release-minecraft.releaseapp.io

Happy Holidays from the Release Team!!!

Discussion (1)

Collapse
tmcclung profile image
tmcclung Author

Here to answer questions if anyone needs help getting their server up and running!