java 版に対して Bedrock Edition(統合版)は TCP に加えて UDP 接続する必要があった。
ググってみる限り UDP だけで port 19132 接続できれば良さそうな記述が多いが、自分の環境だと service までは TCP も port 19132 への通信が確立できないと「サーバーへの接続に失敗しました」状態になった。
ということで、Loadbalancer(MetalLB)を使って、同一 IP アドレスの異なる port に接続できるように設定した。
目次
デプロイ
永続ボリューム
java 版と同様に永続ボリュームとする。namespace は java 版と別にしている。
apiVersion: v1
kind: PersistentVolume
metadata:
name: nfs-pv-bedrock
spec:
capacity:
storage: 5Gi
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain
claimRef:
name: nfs-pvc-bedrock
namespace: minecraft-bedrock
nfs:
server: 10.1.1.3
path: /media/disk2/bedrock-version
mountOptions:
- nfsvers=4.2
マニフェスト
TCP 用と UDP 用の、2つの service を用意する。接続用の IP アドレスは 10.1.11.12。
こんな感じ。
---
apiVersion: v1
kind: ConfigMap
metadata:
name: minecraft-bedrock
namespace: minecraft-bedrock
labels:
role: service-config
app: minecraft-bedrock
data:
# Find more options at https://github.com/itzg/docker-minecraft-bedrock-server#server-properties
# Remove # from in front of line if changing from default values.
EULA: "TRUE" # Must accept EULA to use this minecraft server
#GAMEMODE: "survival" # Options: survival, creative, adventure
DIFFICULTY: "easy" # Options: peaceful, easy, normal, hard
DEFAULT_PLAYER_PERMISSION_LEVEL: "operator" # Options: visitor, member, operator
#LEVEL_NAME: "my_minecraft_world"
#LEVEL_SEED: "33480944"
SERVER_NAME: "Minecraft Bedrock Server"
SERVER_PORT: "19132"
#LEVEL_TYPE: "DEFAULT" # Options: FLAT, LEGACY, DEFAULT
ALLOW_CHEATS: "true" # Options: true, false
MAX_PLAYERS: "10"
#PLAYER_IDLE_TIMEOUT: "30"
#TEXTUREPACK_REQUIRED: "false" # Options: true, false
#
## Changing these will have a security impact
#ONLINE_MODE: "true" # Options: true, false (removes Xbox Live account requirements)
#WHITE_LIST: "false" # If enabled, need to provide a whitelist.json by your own means.
#
## Changing these will have a performance impact
#VIEW_DISTANCE: "10"
#TICK_DISTANCE: "4"
#MAX_THREADS: "8"
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: nfs-pvc-bedrock
namespace: minecraft-bedrock
spec:
accessModes:
- ReadWriteMany
storageClassName: ""
resources:
requests:
storage: 5Gi
volumeName: nfs-pv-bedrock
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: minecraft-bedrock
namespace: minecraft-bedrock
spec:
replicas: 1
selector:
matchLabels:
app: minecraft-bedrock
template:
metadata:
labels:
app: minecraft-bedrock
spec:
volumes:
- name: minecraft-volumes
persistentVolumeClaim:
claimName: nfs-pvc-bedrock
containers:
- name: minecraft-bedrock
image: itzg/minecraft-bedrock-server
envFrom:
- configMapRef:
name: minecraft-bedrock
volumeMounts:
- name: minecraft-volumes
mountPath: "/data"
ports:
- containerPort: 19132
protocol: UDP
readinessProbe: &probe
exec:
command:
- mc-monitor
- status-bedrock
- --host
# force health check against IPv4 port
- 127.0.0.1
initialDelaySeconds: 30
livenessProbe: *probe
tty: true
stdin: true
---
apiVersion: v1
kind: Service
metadata:
name: minecraft-bedrock-udp
namespace: minecraft-bedrock
annotations:
metallb.universe.tf/allow-shared-ip: "key-to-share-10.1.11.12"
spec:
type: LoadBalancer
loadBalancerIP: 10.1.11.12
ports:
- name: minecraft-port-udp
port: 19132
protocol: UDP
targetPort: 19132
selector:
app: minecraft-bedrock
---
apiVersion: v1
kind: Service
metadata:
name: minecraft-bedrock-tcp
namespace: minecraft-bedrock
annotations:
metallb.universe.tf/allow-shared-ip: "key-to-share-10.1.11.12"
spec:
type: LoadBalancer
loadBalancerIP: 10.1.11.12
ports:
- name: minecraft-port-tcp
port: 19132
protocol: TCP
targetPort: 19132
selector:
app: minecraft-bedrock
参考としたサイト
MetalLB で IP アドレスを異なる port で共有する方法はこちら。
Usage :: MetalLB, bare metal load-balancer for Kubernetes
After MetalLB is installed and configured, to expose a service externally, simply create it with spec.type set to LoadBalancer, and MetalLB will do the rest. Me...
image は https://hub.docker.com/r/itzg/minecraft-bedrock-server を使用している。
コメント