13 Commits

Author SHA1 Message Date
ducoterra
dae5a097e9 Fix RAM issue with deploy
A deploy was running the same max ram for both the pod and the java
app. This led to issues where the java app would use its max ram and the
pod would think it was out of memory. It would kill the pod and the
minecraft server with it, often not saving the last few minutes of
progress.

Now the deploy runs 1GiB extra ram than the java app.
2021-09-11 14:08:38 -04:00
ducoterra
44053abdf8 truenas compatibility update 2021-08-29 15:24:11 -04:00
ducoterra
807b1866a8 set memory requirements to avoid sudden container death 2021-02-20 12:16:05 -05:00
ducoterra
99666bab94 add setenv 2021-02-05 21:47:13 -05:00
ducoterra
1b6b8bb281 update RAM for new cluster 2021-02-05 21:42:48 -05:00
ducoterra
95c7fa79f3 merge templates 2020-11-27 15:30:43 -05:00
ducoterra
7e0ff9e416 upgrade to 1.6.4 2020-11-21 15:29:21 -05:00
ducoterra
12fa8ecdbe remove extra opts and remove threading 2020-07-19 17:14:58 -04:00
ducoterra
7d34b3a36c add charts for each server 2020-07-17 13:48:19 -04:00
ducoterra
95b0bd6852 switch to configmap model 2020-07-11 17:50:43 -04:00
ducoterra
ff2c9affb5 servers to nvme 2020-07-10 12:15:55 -04:00
ducoterra
1dfb1f6202 nvme for minecraft 2020-06-28 18:05:52 -04:00
ducoterra
3faf5c9d95 don't auto deploy 2020-06-26 23:49:19 -04:00
27 changed files with 314 additions and 95 deletions

View File

@@ -19,20 +19,3 @@ build:
script:
- echo $DEPLOY
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
deploy_to_prod:
variables:
DEPLOY: prod
stage: deploy
only:
variables:
- $CI_COMMIT_TAG
image:
name: debian:10
entrypoint: [""]
script:
- apt -qq update >> /dev/null && apt -qq install -y curl >> /dev/null
- curl -L -o /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
- chmod +x /usr/local/bin/kubectl
- curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
- helm template $CI_PROJECT_NAME --set tag=$CI_COMMIT_TAG --set image=$CI_REGISTRY_IMAGE ./helm | kubectl apply -f -

View File

@@ -1,13 +1,12 @@
FROM openjdk:8-slim
WORKDIR /mc_server
COPY ./server .
COPY server.jar /server.jar
RUN groupadd -r minecraft && useradd --no-log-init -r -g minecraft minecraft
RUN groupadd -r minecraft -g 2000
RUN useradd --no-log-init minecraft -u 2000 -g 2000 -m
WORKDIR /mc_data
RUN chown -R minecraft:minecraft .
USER minecraft
# Copy files only if they don't yet exist (server.jar, server.properties, etc) and start the server
CMD cp -r /mc_server/. . && \
java -server -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSIncrementalPacing -XX:ParallelGCThreads="$THREADS" -XX:+AggressiveOpts -Xmx"$MAX_RAM"G -Xms"$MIN_RAM"G -jar server.jar nogui
CMD java -Xmx"$MAX_RAM"G -Xms"$MIN_RAM"G -jar /server.jar nogui

View File

@@ -71,4 +71,10 @@ kubectl cp <backup> <pod_name>:/mc_data
## Cool seeds
with an amplified world, -8018833100564192815
### 7485786574821478084
Spawns you next to a nether portal with golden axe and pickaxe. River and Village close by.
### -8018833100564192815
Use with an amplified world, massive island

View File

@@ -1,3 +0,0 @@
docker-compose build mc
docker-compose push mc
kubectl apply -f k8s/

View File

@@ -3,15 +3,4 @@ version: '3'
services:
minecraft:
build: .
ports:
- 25565:25565
volumes:
- ./data:/mc_data
tty: true
stdin_open: true
restart: always
environment:
- MAX_RAM=2
- MIN_RAM=1
- THREADS=2
user: minecraft
image: hub.ducoterra.net/ducoterra/minecraft:1.16.4

View File

@@ -1,6 +1,6 @@
apiVersion: v2
name: charts
description: A Helm chart for Kubernetes
name: minecraft
description: A Minecraft server for kubernetes
# A chart can be either an 'application' or a 'library' chart.
#
@@ -15,9 +15,9 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0
version: 1.0.2
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
appVersion: 1.16.0
appVersion: 1.16.4

3
helm/README.md Normal file
View File

@@ -0,0 +1,3 @@
# Minecraft Server
Creates a vanilla Minecraft server.

3
helm/app-readme.md Normal file
View File

@@ -0,0 +1,3 @@
# Minecraft Server
Creates a vanilla Minecraft server.

1
helm/ix_values.yaml Normal file
View File

@@ -0,0 +1 @@
image: ducoterra/minecraft:1.16.4

30
helm/questions.yaml Normal file
View File

@@ -0,0 +1,30 @@
groups:
- name: "Server Config"
description: "Minecraft Server Configuration"
- name: "Storage"
description: "Minecraft Server Storage"
questions:
- variable: port
description: "Listen Port"
group: "Server Config"
label: "Port"
schema:
type: int
default: 25565
required: true
- variable: max_ram
description: "Total RAM allocated to the server"
group: "Server Config"
label: "RAM Limit (GiB)"
schema:
type: int
default: 4
required: true
- variable: max_cpu
description: "# CPU Cores Allocated to the server"
group: "Server Config"
label: "CPU Limit (# Cores)"
schema:
type: int
default: 4
required: true

View File

@@ -0,0 +1,8 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}
data:
eula.txt: |
eula=true
server.properties: {{ toYaml .Values.server_props | indent 2 }}

View File

@@ -6,6 +6,8 @@ spec:
selector:
matchLabels:
app: {{ .Release.Name }}
strategy:
type: Recreate
template:
metadata:
labels:
@@ -13,29 +15,38 @@ spec:
spec:
containers:
- name: {{ .Release.Name }}
image: {{ .Values.image }}:{{ .Values.tag }}
image: {{ .Values.image }}
ports:
- containerPort: 25565
volumeMounts:
- mountPath: /mc_data
name: data
- name: properties
mountPath: /mc_data/server.properties
subPath: server.properties
- name: properties
mountPath: /mc_data/eula.txt
subPath: eula.txt
tty: true
stdin: true
env:
- name: MAX_RAM
value: "4"
value: {{ .Values.max_ram | quote }}
- name: MIN_RAM
value: "1"
- name: THREADS
value: "4"
resources:
requests:
memory: "2Gi"
cpu: 250m
memory: {{ div .Values.max_ram 2 }}Gi
cpu: 1m
limits:
memory: "4Gi"
cpu: "4"
memory: {{ add 1 .Values.max_ram }}Gi
cpu: {{ .Values.max_cpu | quote }}
volumes:
- name: data
persistentVolumeClaim:
claimName: {{ .Release.Name }}
- name: properties
configMap:
name: {{ .Release.Name }}
securityContext:
fsGroup: 2000

View File

@@ -2,10 +2,11 @@ apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ .Release.Name }}
annotations:
"helm.sh/resource-policy": keep
spec:
storageClassName: nfs-encrypted
accessModes:
- ReadWriteMany
- ReadWriteOnce
resources:
requests:
storage: 32Gi

View File

@@ -1,2 +1,42 @@
image: hub.ducoterra.net/ducoterra/minecraft
port: 25565
image: ducoterra/minecraft:1.16.4
port: 20101
max_cpu: 4
max_ram: 4
server_props: |
max-tick-time=60000
generator-settings=
force-gamemode=false
allow-nether=true
gamemode=0
broadcast-console-to-ops=true
enable-query=false
player-idle-timeout=0
difficulty=3
spawn-monsters=true
op-permission-level=4
pvp=true
snooper-enabled=true
level-type=default
hardcore=false
enable-command-block=false
max-players=20
network-compression-threshold=256
resource-pack-sha1=
max-world-size=29999984
server-port=25565
server-ip=
spawn-npcs=true
allow-flight=true
level-name=world
view-distance=32
resource-pack=
spawn-animals=true
white-list=true
generate-structures=true
online-mode=true
max-build-height=256
level-seed=
prevent-proxy-connections=false
use-native-transport=true
motd=This is gonna be interesting
enable-rcon=false

Binary file not shown.

Before

Width:  |  Height:  |  Size: 481 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 476 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 348 KiB

Binary file not shown.

View File

@@ -1 +0,0 @@
eula=true

View File

@@ -1,39 +0,0 @@
#Minecraft server properties
#Thu Jan 02 01:15:23 UTC 2020
max-tick-time=60000
generator-settings=
force-gamemode=false
allow-nether=true
gamemode=0
broadcast-console-to-ops=true
enable-query=false
player-idle-timeout=0
difficulty=3
spawn-monsters=true
op-permission-level=4
pvp=true
snooper-enabled=true
level-type=amplified
hardcore=false
enable-command-block=false
max-players=20
network-compression-threshold=256
resource-pack-sha1=
max-world-size=29999984
server-port=25565
server-ip=
spawn-npcs=true
allow-flight=true
level-name=world
view-distance=32
resource-pack=
spawn-animals=true
white-list=true
generate-structures=true
online-mode=true
max-build-height=512
level-seed=
prevent-proxy-connections=false
use-native-transport=true
motd=This is gonna be interesting
enable-rcon=false

19
servers.md Normal file
View File

@@ -0,0 +1,19 @@
# Servers
## Minecraft
```bash
helm upgrade --install minecraft ./helm --set tag=1.15.2_7 --set port=25565
```
## Pubcraft
```bash
helm upgrade --install pubcraft ./helm --set tag=1.15.2_7 --set port=20100
```
## TestCraft
```bash
helm upgrade --install testcraft ./helm --set tag=1.16.1_2 --set port=25566
```

1
setenv.sh Executable file
View File

@@ -0,0 +1 @@
kubectl config set current-context k3os-alpha.dnet-ducoterra-minecraft

42
values-camcraft.yaml Normal file
View File

@@ -0,0 +1,42 @@
image: hub.ducoterra.net/ducoterra/minecraft:1.16.4
port: 20101
max_cpu: 8
max_ram: 8
server_props: |
max-tick-time=60000
generator-settings=
force-gamemode=false
allow-nether=true
gamemode=0
broadcast-console-to-ops=true
enable-query=false
player-idle-timeout=0
difficulty=3
spawn-monsters=true
op-permission-level=4
pvp=true
snooper-enabled=true
level-type=default
hardcore=false
enable-command-block=false
max-players=20
network-compression-threshold=256
resource-pack-sha1=
max-world-size=29999984
server-port=25565
server-ip=
spawn-npcs=true
allow-flight=true
level-name=world
view-distance=32
resource-pack=
spawn-animals=true
white-list=true
generate-structures=true
online-mode=true
max-build-height=256
level-seed=
prevent-proxy-connections=false
use-native-transport=true
motd=This is gonna be interesting
enable-rcon=false

42
values-minecraft.yaml Normal file
View File

@@ -0,0 +1,42 @@
image: hub.ducoterra.net/ducoterra/minecraft:1.16.4
port: 25565
max_cpu: 8
max_ram: 6
server_props: |
max-tick-time=60000
generator-settings=
force-gamemode=false
allow-nether=true
gamemode=0
broadcast-console-to-ops=true
enable-query=false
player-idle-timeout=0
difficulty=3
spawn-monsters=true
op-permission-level=4
pvp=true
snooper-enabled=true
level-type=default
hardcore=false
enable-command-block=false
max-players=20
network-compression-threshold=256
resource-pack-sha1=
max-world-size=29999984
server-port=25565
server-ip=
spawn-npcs=true
allow-flight=true
level-name=world
view-distance=32
resource-pack=
spawn-animals=true
white-list=true
generate-structures=true
online-mode=true
max-build-height=256
level-seed=
prevent-proxy-connections=false
use-native-transport=true
motd=This is gonna be interesting
enable-rcon=false

42
values-pubcraft.yaml Normal file
View File

@@ -0,0 +1,42 @@
image: hub.ducoterra.net/ducoterra/minecraft:1.16.4
port: 20100
max_cpu: 8
max_ram: 6
server_props: |
max-tick-time=60000
generator-settings=
force-gamemode=false
allow-nether=true
gamemode=0
broadcast-console-to-ops=true
enable-query=false
player-idle-timeout=0
difficulty=3
spawn-monsters=true
op-permission-level=4
pvp=true
snooper-enabled=true
level-type=default
hardcore=false
enable-command-block=false
max-players=20
network-compression-threshold=256
resource-pack-sha1=
max-world-size=29999984
server-port=25565
server-ip=
spawn-npcs=true
allow-flight=true
level-name=world
view-distance=32
resource-pack=
spawn-animals=true
white-list=true
generate-structures=true
online-mode=true
max-build-height=256
level-seed=
prevent-proxy-connections=false
use-native-transport=true
motd=This is gonna be interesting
enable-rcon=false

42
values-testcraft.yaml Normal file
View File

@@ -0,0 +1,42 @@
image: hub.ducoterra.net/ducoterra/minecraft:1.16.4
port: 25566
max_cpu: 8
max_ram: 6
server_props: |
max-tick-time=60000
generator-settings=
force-gamemode=false
allow-nether=true
gamemode=0
broadcast-console-to-ops=true
enable-query=false
player-idle-timeout=0
difficulty=3
spawn-monsters=true
op-permission-level=4
pvp=true
snooper-enabled=true
level-type=amplified
hardcore=false
enable-command-block=false
max-players=20
network-compression-threshold=256
resource-pack-sha1=
max-world-size=29999984
server-port=25565
server-ip=
spawn-npcs=true
allow-flight=true
level-name=world
view-distance=64
resource-pack=
spawn-animals=true
white-list=true
generate-structures=true
online-mode=true
max-build-height=512
level-seed=
prevent-proxy-connections=false
use-native-transport=true
motd=This is gonna be interesting
enable-rcon=false