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