Skip to content

Commit 05fa04e

Browse files
authored
Add Kubernetes Tailscale Operator example with MTU fix (#554)
1 parent bd10c36 commit 05fa04e

File tree

1 file changed

+117
-0
lines changed

1 file changed

+117
-0
lines changed
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# This example manifest deploys a Minecraft Bedrock server on Kubernetes
2+
# using Tailscale Operator to provide secure access to the server.
3+
#
4+
# Prerequisites: A Kubernetes cluster with Tailscale Operator installed and configured.
5+
# Please see https://tailscale.com/kb/1236/kubernetes-operator
6+
#
7+
# Also, This example contains an initContainer to adjust the MTU of the pod's network interface.
8+
# Please see https://github.com/itzg/docker-minecraft-bedrock-server/discussions/553
9+
---
10+
apiVersion: v1
11+
kind: ConfigMap
12+
metadata:
13+
name: minecraft-bedrock
14+
labels:
15+
role: service-config
16+
app: bds
17+
data:
18+
EULA: "TRUE"
19+
---
20+
kind: PersistentVolumeClaim
21+
apiVersion: v1
22+
metadata:
23+
name: bds
24+
spec:
25+
accessModes:
26+
- ReadWriteOnce
27+
resources:
28+
requests:
29+
storage: 1Gi
30+
---
31+
apiVersion: apps/v1
32+
kind: StatefulSet
33+
metadata:
34+
labels:
35+
app: bds
36+
name: bds
37+
spec:
38+
replicas: 1
39+
serviceName: bds
40+
selector:
41+
matchLabels:
42+
app: bds
43+
template:
44+
metadata:
45+
labels:
46+
app: bds
47+
spec:
48+
initContainers:
49+
- name: setup-mtu
50+
image: busybox:latest
51+
command:
52+
- /bin/sh
53+
- -c
54+
- |
55+
ip route
56+
ip route change default via $POD_IP dev $TARGET_DEVICE mtu $TARGET_MTU
57+
ip route
58+
env:
59+
- name: POD_IP
60+
valueFrom:
61+
fieldRef:
62+
fieldPath: status.podIP
63+
- name: TARGET_MTU
64+
value: "1280" # tailscale's default MTU. see https://tailscale.com/kb/1023/troubleshooting#tcp-connection-issues-between-two-devices
65+
- name: TARGET_DEVICE
66+
value: eth0 # adjust if not eth0
67+
securityContext:
68+
capabilities:
69+
add:
70+
- NET_ADMIN # it is necessary to change the MTU
71+
72+
containers:
73+
- name: main
74+
image: itzg/minecraft-bedrock-server
75+
imagePullPolicy: Always
76+
envFrom:
77+
- configMapRef:
78+
name: minecraft-bedrock
79+
volumeMounts:
80+
- mountPath: /data
81+
name: data
82+
ports:
83+
- containerPort: 19132
84+
protocol: UDP
85+
readinessProbe: &probe
86+
exec:
87+
command:
88+
- mc-monitor
89+
- status-bedrock
90+
- --host
91+
- 127.0.0.1
92+
initialDelaySeconds: 30
93+
livenessProbe: *probe
94+
tty: true
95+
stdin: true
96+
volumeClaimTemplates:
97+
- metadata:
98+
name: data
99+
spec:
100+
accessModes:
101+
- ReadWriteOnce
102+
resources:
103+
requests:
104+
storage: 1Gi
105+
---
106+
apiVersion: v1
107+
kind: Service
108+
metadata:
109+
name: bds
110+
annotations:
111+
tailscale.com/expose: "true" # expose this service via Tailscale
112+
spec:
113+
selector:
114+
app: bds
115+
ports:
116+
- port: 19132
117+
protocol: UDP

0 commit comments

Comments
 (0)