add minecraft

This commit is contained in:
James Turland 2023-11-23 15:50:51 +00:00
parent 98fc682a86
commit 898b52b49d
4 changed files with 110 additions and 0 deletions

View file

@ -0,0 +1,59 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: minecraft
app.kubernetes.io/instance: minecraft
name: minecraft
namespace: minecraft
spec:
replicas: 1
selector:
matchLabels:
app: minecraft
template:
metadata:
labels:
app: minecraft
spec:
nodeSelector:
worker: "true"
containers:
- env:
- name: EULA
value: "TRUE"
image: itzg/minecraft-server
name: minecraft-server
ports:
- containerPort: 25565
resources: {}
stdin: true
tty: true
volumeMounts:
- mountPath: /data
name: minecraft
restartPolicy: Always
volumes:
- name: minecraft
persistentVolumeClaim:
claimName: minecraft
---
apiVersion: v1
kind: Service
metadata:
labels:
app: minecraft
name: minecraft
namespace: minecraft
spec:
ports:
- name: minecraft-tcp
port: 25565
protocol: TCP
targetPort: 25565
selector:
app: minecraft
externalTrafficPolicy: Local
loadBalancerIP: 192.168.200.19
type: LoadBalancer

View file

@ -0,0 +1,24 @@
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: allow-internet-only
namespace: minecraft
spec:
podSelector: {}
policyTypes:
- Egress
egress:
- to:
- ipBlock:
cidr: "0.0.0.0/0"
except:
- "10.0.0.0/8"
- "172.16.0.0/12"
- "192.168.0.0/16"
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: "kube-system"
- podSelector:
matchLabels:
k8s-app: "kube-dns"

View file

@ -0,0 +1,22 @@
version: '3.3'
services:
minecraft-server:
container_name: minecraft-server
image: itzg/minecraft-server
ports:
- 25565:25565
environment:
- TYPE=FORGE
- EULA=TRUE
volumes:
- /home/ubuntu/docker/minecraft:/data
stdin_open: true
tty: true
restart: unless-stopped
networks:
macvlan4: # change name to whatever you like
ipv4_address: 192.168.4.20 # change to your IP in your vLAN subnet
networks:
macvlan4:
external: true

5
Minecraft/macvlan Normal file
View file

@ -0,0 +1,5 @@
docker network create -d macvlan \
--subnet=192.168.4.0/24 \
--gateway=192.168.4.1 \
-o parent=eth0.4 \
macvlan4