Files
homelab/k8s/games/minecraft/deployments.yaml
ab e342aab9df
All checks were successful
Check with kubeconform / lint (push) Successful in 11s
Update k8s/games/minecraft/deployments.yaml
2025-07-09 09:49:30 +00:00

168 lines
5.4 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-config
namespace: minecraft
data:
nginx.conf: |
# Запуск рабочих процессов от имени пользователя nginx
user nginx;
# Рекомендуется ставить worker_processes auto; но 1 тоже будет работать
worker_processes 1;
events {
worker_connections 1024;
}
http {
# --- ИСПРАВЛЕНИЯ И ОПТИМИЗАЦИЯ ---
# Включаем sendfile для быстрой отдачи файлов напрямую из файловой системы
sendfile on;
# Оптимизирует отправку пакетов, используется вместе с sendfile
tcp_nopush on;
# --- КОНЕЦ ИСПРАВЛЕНИЙ ---
# Определяем MIME-типы файлов, чтобы браузер знал, как их обрабатывать
types {
application/zip zip;
text/html html htm;
text/css css;
application/javascript js;
image/png png;
image/jpeg jpg jpeg;
}
# Тип по умолчанию для всех остальных файлов
default_type application/octet-stream;
server {
listen 80;
# Этот блок остается без изменений для вашего основного сайта
location / {
proxy_pass http://localhost:8123;
sub_filter 'Minecraft Dynamic Map' "Hexor's MC server";
sub_filter "</body>" '<p style="background-color: #CEC6CB; color: black; padding: 10px 10px; text-align: center; font-size: large; text-decoration: none; display: inline-block; border-radius: 4px; position: absolute; top: 10px; left: 150px;">Get <a href="https://github.com/PrismLauncher/PrismLauncher/releases/tag/8.4" >Prism Launcher</a> and <a href="/clients/1.12.2.zip" >client.zip</a> for this server. Server address <b>minecraft.hexor.cy:30565</b></p></body>';
sub_filter_once off;
}
# --- УПРОЩЕННЫЙ БЛОК ДЛЯ СКАЧИВАНИЯ ФАЙЛОВ ---
# Этот блок теперь корректно и эффективно обрабатывает все файлы в /clients/
location /clients/ {
# Указываем реальный путь к файлам на сервере
alias /mc/clients/;
# Показывает список файлов, если запрошена сама директория
autoindex on;
# Добавляем заголовок, чтобы браузер всегда предлагал скачать файл,
# а не пытался его открыть. Это применится ко всем файлам в /clients/
add_header Content-Disposition "attachment";
}
}
}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: minecraft
namespace: minecraft
labels:
app: minecraft
spec:
selector:
matchLabels:
app: minecraft
replicas: 1
strategy:
type: Recreate
template:
metadata:
labels:
app: minecraft
spec:
nodeSelector:
kubernetes.io/hostname: master.tail2fe2d.ts.net
volumes:
- name: storage
hostPath:
path: /k8s/mc-server/
type: DirectoryOrCreate
- name: nginx-config
configMap:
name: nginx-config
terminationGracePeriodSeconds: 10
containers:
- name: nginx
image: nginx:latest
ports:
- containerPort: 80
volumeMounts:
- name: nginx-config
mountPath: /etc/nginx/nginx.conf
subPath: nginx.conf
- name: storage
mountPath: /mc
- name: minecraft
image: 'openjdk:8-jdk-alpine'
command: ["java"]
args:
- -Xms4G
- -Xmx4G
- -XX:+UseG1GC
- -XX:+ParallelRefProcEnabled
- -XX:MaxGCPauseMillis=200
- -XX:+UnlockExperimentalVMOptions
- -XX:+DisableExplicitGC
- -XX:+AlwaysPreTouch
- -XX:G1NewSizePercent=30
- -XX:G1MaxNewSizePercent=40
- -XX:G1HeapRegionSize=8M
- -XX:G1ReservePercent=20
- -XX:G1HeapWastePercent=5
- -XX:G1MixedGCCountTarget=4
- -XX:InitiatingHeapOccupancyPercent=15
- -XX:G1MixedGCLiveThresholdPercent=90
- -XX:G1RSetUpdatingPauseTimePercent=5
- -XX:SurvivorRatio=32
- -XX:+PerfDisableSharedMem
- -XX:MaxTenuringThreshold=1
- -jar
- forge-1.12.2-14.23.5.2854.jar
- nogui
workingDir: /mc/
resources:
limits:
memory: 8Gi
#cpu: 1
requests:
memory: 5Gi
#cpu: 100m
ports:
- name: game
containerPort: 25565
protocol: TCP
- name: dynmap
containerPort: 8123
protocol: TCP
volumeMounts:
- name: storage
mountPath: /mc
---
apiVersion: v1
kind: Service
metadata:
name: minecraft-exporter
namespace: minecraft
spec:
selector:
app: minecraft
ports:
- protocol: TCP
port: 19565
targetPort: 19565