Running Gate in Kubernetes
Gate ships in packaged Docker images that you can deploy to Kubernetes.
Prerequisites
All-in-One Minecraft Network Example
This Kubernetes manifest contains a Gate deployment configuring two non-persistent Minecraft servers.
You can join Gate on NodePort 32556
and switch between the two Minecraft servers using the /server
command.
You can also try to delete one server pod and see how Gate automatically reconnects the player to the other server.
sh
kubectl apply -f https://raw.githubusercontent.com/minekube/gate/master/.examples/kubernetes/bundle.yaml
bundle.yaml
yaml
apiVersion: v1
data:
config.yml: |
# This is a simplified config where the rest of the
# settings are omitted and will be set by default.
# See config.yml for the full configuration options.
config:
bind: 0.0.0.0:25565
servers:
server-0: server-0.servers:25565
server-1: server-1.servers:25565
try:
- server-0
- server-1
kind: ConfigMap
metadata:
labels:
app.kubernetes.io/name: gate
name: gate-config-8bh2kdmfmd
---
apiVersion: v1
data:
spigot.yml: |
settings:
bungeecord: true
kind: ConfigMap
metadata:
labels:
app.kubernetes.io/component: server
app.kubernetes.io/name: gate
name: spigot-8mf62594mt
---
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/name: gate
name: gate
spec:
ports:
- name: minecraft
nodePort: 32556
port: 25565
protocol: TCP
targetPort: minecraft
selector:
app.kubernetes.io/component: proxy
app.kubernetes.io/name: gate
type: NodePort
---
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/component: server
app.kubernetes.io/name: gate
name: servers
spec:
clusterIP: None
ports:
- name: minecraft
port: 25565
targetPort: minecraft
selector:
app.kubernetes.io/component: server
app.kubernetes.io/name: gate
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/name: gate
name: gate
spec:
selector:
matchLabels:
app.kubernetes.io/name: gate
template:
metadata:
labels:
app.kubernetes.io/component: proxy
app.kubernetes.io/name: gate
spec:
containers:
- image: ghcr.io/minekube/gate:latest
name: gate
ports:
- containerPort: 25565
name: minecraft
volumeMounts:
- mountPath: /gate/config.yml
name: config
subPath: config.yml
volumes:
- configMap:
name: gate-config-8bh2kdmfmd
name: config
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
labels:
app.kubernetes.io/component: server
app.kubernetes.io/name: gate
name: server
spec:
replicas: 2
selector:
matchLabels:
app.kubernetes.io/component: server
app.kubernetes.io/name: gate
serviceName: servers
template:
metadata:
labels:
app.kubernetes.io/component: server
app.kubernetes.io/name: gate
spec:
containers:
- env:
- name: TYPE
value: PUFFERFISH
- name: EULA
value: "TRUE"
- name: ONLINE_MODE
value: "FALSE"
image: itzg/minecraft-server:latest
livenessProbe:
exec:
command:
- mc-health
initialDelaySeconds: 120
periodSeconds: 60
name: server1
ports:
- containerPort: 25565
name: minecraft
readinessProbe:
exec:
command:
- mc-health
failureThreshold: 12
initialDelaySeconds: 20
periodSeconds: 10
stdin: true
tty: true
volumeMounts:
- mountPath: /data/spigot.yml
name: spigot
readOnly: false
subPath: spigot.yml
volumes:
- configMap:
name: spigot-8mf62594mt
name: spigot
Using Kustomize Recommended
Use Kustomize for structuring your Kubernetes manifests in a more manageable way before deploying. In fact, we used Kustomize to generate the All-in-One example above.
sh
git clone https://github.com/minekube/gate.git
cd gate/.examples/kubernetes # Edit to your needs
kustomize build # Preview generated manifest
kubectl apply -k . # Generate and deploy to Kubernetes
kubectl delete -k . # Delete deployment
You can also overlay your own Kustomize on top of the example:
yaml
resources:
- https://raw.githubusercontent.com/minekube/gate/master/.examples/kubernetes
# Edit to your needs...
patchesStrategicMerge:
- patch.yaml