Sign inSign up

fabianvf/game-server-operator

By fabianvf

•Updated over 6 years ago

Image
0

50K+

fabianvf/game-server-operator repository overview

⁠game-server-operator

Build Status Gitter chat

This operator deploys game servers to OpenShift or Kubernetes

Currently supported games are:

  • minecraft

⁠Deploying the Operator

To deploy it, ensure your kubeconfig is properly set up (ie, that you can use kubectl or oc to connect to it), ensure you have cluster-admin permissions (you will need this to create CustomResourceDefinitions), install ansible⁠ and the openshift python client⁠, and run

ansible-playbook deploy.yml

If you'd rather deploy it by hand, you can instead run:

kubectl apply -f deploy/crds/games_v1alpha1_minecraft_crd.yaml
kubectl apply -f deploy/role.yaml
kubectl apply -f deploy/role_binding.yaml
kubectl apply -f deploy/service_account.yaml
kubectl apply -f deploy/operator.yaml

Once this is done, your operator will be running.

⁠Deploying a Minecraft server

The minecraft operator is built on top of the fantastic minecraft-server image⁠ provided by @itzg.

All you need to do is create an instance of the games.fabianism.us/v1alpha1 Minecraft resource. A basic example Minecraft definition exists in deploy/crds/minecraft.yaml. You can create it with

kubectl apply -f deploy/crds/minecraft.yaml

This will kick off the deployment of the Minecraft server. To monitor the status of the deployment, run

kubectl describe minecraft

and monitor the status field. After some amount of time, a field called URL should appear in the status, this is the URL that the operator has generated for your server. You should be able to access the minecraft server by connecting to that URL.

⁠Deployment Options

The example deployment will only give you a very basic, ephemeral, vanilla Minecraft. In order to get a real deployment, you will at least need to add storage options. The following options are supported in the Minecraft spec:

namedescriptiondefaultrequired
eulaAcceptedWhether the EULA has been accepted. Required to start the server.Falseyes
imageThe Minecraft image to deploydocker.io/itzg/minecraft-server:latestno
portThe port on the host that Minecraft should listen on.Random available portno
hostIf running openshift, the host that Minecraft will be accessible fromhttp://minecraft-{namespace}.{openshift subdomain}no
volumesThe volumes to create/mount into your container. See VolumeSpec⁠ for more detail.yes
serverThe server configuration options. See ServerSpec⁠ for more detail.no
worldThe world configuration options. See WorldSpec⁠ for more detail.no
modsThe mod configuration options. See ModSpec⁠ for more detail.no
jvmThe jvm configuration options. See JvmSpec⁠ for more detail.no
resourcesThe resource limits/minimums for your server. See https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#resource-requests-and-limits-of-pod-and-container⁠ for more detail.no
⁠VolumeSpec

The volumes field is a map of key:value pairs, where each key is a volume name and the value is a map of key:value pairs defining how the volume is to be created/mounted/accessed.

For configuration persistence, only one volume is required, the data volume. It must be mounted to /data with read-write permissions.

All volumes accept the following options:

namedescriptiondefaultrequired
typeThe type of volume. Choices are [PersistentVolumeClaim, EmptyDir]yes
mountPathThe full path to mount in the container.The name of the volume (ie, config -> /config).no
claimNameThe name of the PersistentVolumeClaim to use.The name of the volume.no
sizeThe size of the volume to be createdWhen type is PersistentVolumeClaim and create is true.
createWhether the PersistentVolumeClaim be created if it does not exist.nono
storageClassNameThe name of the storage class to set for a PersistentVolumeClaimThe default storageClass for the cluster.no
accessModesThe list of accessModes for a volume. Options are [ReadWriteOnce, ReadWriteMany, ReadOnlyMany][ReadWriteOnce]no
readOnlyWhether the volume should be mounted read onlyfalseno
⁠ServerSpec

The server field contains configuration options for server administration.

namedescriptiondefaultrequired
versionThe minecraft version to installlatestno
nameThe name of your Minecraft serverMy Minecraft Serverno
typeThe type of server to run. Choices are BUKKIT, SPIGOT, PAPER, FORGE, FTB, CURSEFORGE, VANILLA, SPONGEVANILLA, CUSTOMVANILLA
iconThe icon to display for your serverno
difficultyThe difficulty level. Choices are peaceful, easy, normal, hardeasyno
maxPlayersThe maximun number of players your server will support20no
whitelistA list of usernames to allow to connect to the servereveryoneno
opsA list of usernames to grant op permissions tonooneno
announcePlayerAchievementsWhether to announce achievements globally to the serverTrueno
enableCommandBlockEnables command blocksFalseno
forceGamemodeForce players to join in the default game mode.Falseno
hardcoreIf set to true, players will be set to spectator mode if they die.Falseno
snooperEnabledIf set to false, the server will not send data to snoop.minecraft.net serverTrueno
maxBuildHeightThe maximum height in which building is allowed. Terrain may still naturally generate above a low height limit.no
maxTickTimeThe maximum number of milliseconds a single tick may take before the server watchdog stops the server with the message, A single server tick took 60.00 seconds (should be max 0.05); Considering it to be crashed, server will forcibly shutdown. Once this criteria is met, it calls System.exit(1). Setting this to -1 will disable watchdog entirely60000no
viewDistanceSets the amount of world data the server sends the client, measured in chunks in each direction of the player (radius, not diameter). It determines the server-side viewing distance.10no
modeThe gamemode of the server. One of creative, survival, adventure, spectatorsurvivalno
motdThe message of the day for the server.no
pvpIf set to False, PVP will not be allowed on the serverTrueno
enableRconWhether to enable RCONFalseno
rconPasswordThe password for RCONno
onlineModeWhether to check that users are logged in.Trueno
allowNetherAllows players to travel to the Nether.Trueno
allowFlightAllows players to fly.Falseno
⁠WorldSpec

The world field contains options for generating or loading your world.

namedescriptiondefaultrequired
maxWorldSizeThis sets the maximum possible size in blocks, expressed as a radius, that the world border can obtain.10000no
generateStructuresDefines whether structures (such as villages) will be generated.Trueno
spawnAnimalsDetermines if animals will be able to spawn.Trueno
spawnMonstersDetermines if monsters will be spawned.Trueno
spawnNpcsDetermines if villagers will be spawned.Trueno
seedThe level seed to generate the world withno
levelTypeOne of default, flat, largebiomes, amplified, customized, buffetdefaultno
generatorSettingsWhen using a levelType of FLAT, CUSTOMIZED, and BUFFET, you can further configure the world generator by passing custom generator settings.no
levelDetermines the World Save Name to loadworldno
worldURL or path to worldno
⁠ModSpec

The mods field contains options for loading and configuring your modpacks. Bukkit, Spigot, Paper, Forge, Feed The Beast, CurseForge, Vanilla, SpongeVanilla and Custom modpacks are all supported. The configuration options that will be loaded are based on the spec.server.type field.

namedescriptiondefaultrequired
modpackno
removeOldModsFalseno
ftbServerModsee https://github.com/itzg/dockerfiles/tree/master/minecraft-server#running-a-server-with-a-feed-the-beast-ftb--curseforge-modpack⁠no
cfServerModsee https://github.com/itzg/dockerfiles/tree/master/minecraft-server#running-a-server-with-a-feed-the-beast-ftb--curseforge-modpack⁠no
forgeversionsee https://github.com/itzg/dockerfiles/tree/master/minecraft-server#running-a-forge-server⁠latest stableno
forgeInstallersee https://github.com/itzg/dockerfiles/tree/master/minecraft-server#running-a-forge-server⁠installer corresponding to forgeversionno
forgeInstallerURLsee https://github.com/itzg/dockerfiles/tree/master/minecraft-server#running-a-forge-server⁠no
bukkitDownloadURLsee https://github.com/itzg/dockerfiles/tree/master/minecraft-server#running-a-bukkitspigot-server⁠no
spigotDownloadURLsee https://github.com/itzg/dockerfiles/tree/master/minecraft-server#running-a-bukkitspigot-server⁠no
buildFromSourcesee https://github.com/itzg/dockerfiles/tree/master/minecraft-server#running-a-bukkitspigot-server⁠Falseno
paperDownloadURLsee https://github.com/itzg/dockerfiles/tree/master/minecraft-server#running-a-paperspigot-server⁠no
manifestsee https://github.com/itzg/dockerfiles/tree/master/minecraft-server#using-a-client-made-curseforge-modpack⁠no
spongeBranchsee https://github.com/itzg/dockerfiles/tree/master/minecraft-server#running-a-spongevanilla-server⁠no
customServersee https://github.com/itzg/dockerfiles/tree/master/minecraft-server#running-with-a-custom-server-jar⁠no
⁠JvmSpec

The jvm field contains options for configuring the JVM. These include memory/heap settings as well as arbitrary arguments you may want to pass to the JVM.

namedescriptiondefaultrequired
memorycan be used to adjust both initial (Xms) and max (Xmx) memory settings of the JVM.1Gno
initMemoryindependently sets the initial heap size.no
maxMemoryIndependently sets the max heap size.no
jvmOptsGeneral JVM options that will be passed to the Minecraft Server invocationno
jvmXxOptsOptions like -X that need to proceed general JVM optionsno
jvmDdOptsFor some cases, if e.g. after removing mods, it could be necessary to startup minecraft with an additional -D parameter like -Dfml.queryResult=confirm. If you add fml.queryResult:confirm, it will be converted to -Dfml.queryResult=confirmno
⁠Examples

TODO

Tag summary

Content type

Image

Digest

Size

143.6 MB

Last updated

about 7 years ago

docker pull fabianvf/game-server-operator