From 5b07c4308893556796058f2807e8ac1d259841b7 Mon Sep 17 00:00:00 2001 From: outductor Date: Fri, 22 Dec 2023 02:14:14 +0900 Subject: [PATCH] add lobby server --- .../templates/debug-lobby/lobby-server.yaml | 251 ++++++++++++++++++ .../templates/debug-lobby/ops-config.yaml | 38 +++ .../debug-lobby/service-monitor.yaml | 17 ++ .../templates/debug-lobby/service.yaml | 21 ++ .../templates/debug-s1/seichiassist.yaml | 7 +- .../bungeecord/bungeecord-config.yaml | 2 +- 6 files changed, 333 insertions(+), 3 deletions(-) create mode 100644 seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/debug-lobby/lobby-server.yaml create mode 100644 seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/debug-lobby/ops-config.yaml create mode 100644 seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/debug-lobby/service-monitor.yaml create mode 100644 seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/debug-lobby/service.yaml diff --git a/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/debug-lobby/lobby-server.yaml b/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/debug-lobby/lobby-server.yaml new file mode 100644 index 000000000..94d424527 --- /dev/null +++ b/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/debug-lobby/lobby-server.yaml @@ -0,0 +1,251 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + annotations: + reloader.stakater.com/auto: "true" + labels: + app: mcserver + mcserver: debug-lobby + name: mcserver--debug-lobby +spec: + replicas: 1 + serviceName: "mcserver--debug-lobby" + selector: + matchLabels: + app: mcserver--debug-lobby + mcserver: debug-lobby + template: + metadata: + labels: + app: mcserver--debug-lobby + mcserver: debug-lobby + spec: + initContainers: + - name: jmx-exporter-downloader + image: busybox:1.36.1 + env: + - name: JMX_EXPORTER_URL + value: "https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.16.1/jmx_prometheus_javaagent-0.16.1.jar" + volumeMounts: + - name: jmx-exporter-download-volume + mountPath: /root/jmx-exporter-download + command: + - "sh" + - "-c" + - 'wget -O /root/jmx-exporter-download/jmx-exporter-javaagent.jar "${JMX_EXPORTER_URL}"' + - name: mod-downloader + image: ghcr.io/giganticminecraft/mod-downloader:sha-c0f7980 + env: + - name: MINIO_ENDPOINT + value: seichi-private-plugin-blackhole-minio.minio:9000 + - name: MINIO_ACCESS_KEY + valueFrom: + secretKeyRef: + name: minio-secrets + key: MINIO_ACCESS_KEY + - name: MINIO_ACCESS_SECRET + valueFrom: + secretKeyRef: + name: minio-secrets + key: MINIO_ACCESS_SECRET + - name: BUCKET_NAME + value: seichi-plugins + - name: BUCKET_PREFIX_NAME + value: deb-1-18-2 + - name: DOWNLOAD_TARGET_DIR_PATH + value: /plugins + volumeMounts: + - name: mod-downloader-volume + mountPath: /plugins + - name: world-downloader + image: busybox:1.36.1 + env: + - name: WORLD_URL # S1からインポートしてきたワールドデータ + value: "http://seichi-private-plugin-blackhole-minio.minio:9000/seichi-plugins/world-data/lobby/world.tar.gz" + volumeMounts: + - name: world-download-volume + mountPath: /data + command: + - "sh" + - "-c" + - 'wget -qO- "${WORLD_URL}" | tar -xz -C /data' + + containers: + - resources: + requests: + cpu: 2 + memory: 4Gi + limits: + cpu: 2 + memory: 4Gi + env: + - name: MEMORY + value: 2048m + - name: TYPE + value: PAPER + - name: VERSION + value: "1.18.2" + - name: EULA + value: "TRUE" + + - name: REMOVE_OLD_MODS + value: "TRUE" + + - name: MODS + # DiscordSRV: + # https://github.com/DiscordSRV/DiscordSRV/releases/download/v1.25.1/DiscordSRV-Build-1.25.1.jar + # LunaChat: + # https://github.com/ucchyocean/LunaChat/releases/download/v3.0.16/LunaChat.jar + value: >- + https://github.com/DiscordSRV/DiscordSRV/releases/download/v1.25.1/DiscordSRV-Build-1.25.1.jar, + https://github.com/ucchyocean/LunaChat/releases/download/v3.0.16/LunaChat.jar, + https://download.luckperms.net/1526/bukkit/loader/LuckPerms-Bukkit-5.4.113.jar, + https://github.com/DmitryRendov/BungeePortals/releases/download/1.2.3/BungeePortals-1.2.3.jar, + + - name: JVM_OPTS + value: >- + -javaagent:/jmx-exporter/jmx-exporter-javaagent.jar=18321:/jmx-exporter/jmx-exporter-config.yaml + + - name: COPY_CONFIG_DEST + # /config をサーバーディレクトリにコピーするようにする + # https://github.com/itzg/docker-minecraft-server/tree/9458005b5bd78b8139e13e66c29a449a12dd6218#optional-plugins-mods-and-config-attach-points + value: /data + + # 設定ファイル内の ${CFG_*} の形をした部分を置き換える + # https://github.com/itzg/docker-minecraft-server/tree/9458005b5bd78b8139e13e66c29a449a12dd6218#replacing-variables-inside-configs + - name: REPLACE_ENV_VARIABLE_PREFIX + value: CFG_ + + - name: CFG_DISCORDSRV_TOKEN + valueFrom: + secretKeyRef: + name: mcserver--common--config-secrets + key: DISCORDSRV_TOKEN + + - name: CFG_DISCORDSRV_GLOBAL_CHANNEL_ID + value: "1054159992447570032" + + - name: CFG_DISCORDSRV_CONSOLE_CHANNEL_ID + value: "1054159676964622426" + + - name: RCON_CMDS_STARTUP + value: |- + gamerule keepInventory true + lp group default permission set worldedit.wand true + lp group default permission set worldguard.region.claim true + lp group default permission set worldguard.region.select.own.* true + lp group default permission set worldguard.region.list.own true + lp group default permission set worldguard.region.info.own.* true + lp group default permission set worldguard.region.flag.regions.own.* true + + image: ghcr.io/giganticminecraft/seichi_minecraft_server_debug_base_1_18_2:sha-1267b49 + name: minecraft + ports: + - containerPort: 25565 + name: minecraft + - containerPort: 18321 + name: jmx-metrics + + startupProbe: + tcpSocket: + port: 25565 + # 最大120秒待つ + failureThreshold: 6 + periodSeconds: 20 + + readinessProbe: + exec: + command: + - mc-monitor + - status + - --host + - localhost + - --port + - "25565" + initialDelaySeconds: 30 + periodSeconds: 5 + failureThreshold: 18 + + volumeMounts: + # itzg/minecraft-server は /config に設定ファイルをマウントしておけばコピーをしてくれる。 + # 環境変数の置き換えはPrefix等の設定が必要なので、必要になったら設定するように。 + # https://github.com/itzg/docker-minecraft-server/tree/9458005b5bd78b8139e13e66c29a449a12dd6218#replacing-variables-inside-configs + + # 普通にマウントすると、auto-update (常に最新のvolume内容がコンテナ内から見える) の挙動を + # 提供するために symlink による一時ディレクトリがマウントされることになるが、 + # itzg/minecraft-server が利用するファイル同期の仕組み (itzg/mc-image-helper) は + # symlink を展開してしまうため、設定ファイルのパスが壊れてしまう。 + # + # subPathを利用してマウントすればsymlinkが作られることを回避できるためそのようにしている。 + # 参考: https://stackoverflow.com/a/63114800 + # 参考: https://stackoverflow.com/a/50687707 + + # サーバーの設定ファイル + - name: common-mcserver-configs + mountPath: /config/bukkit.yml + subPath: bukkit.yml + - name: common-mcserver-configs + mountPath: /config/paper.yml + subPath: paper.yml + - name: common-mcserver-configs + mountPath: /config/server.properties + subPath: server.properties + - name: common-mcserver-configs + mountPath: /config/spigot.yml + subPath: spigot.yml + - name: minecraft-ops-config + mountPath: /config/ops.json + subPath: ops.json + + # DiscordSRV プラグインの設定ファイル + - name: common-mcserver-plugin-configs + mountPath: /plugins/DiscordSRV/config.yml + subPath: DiscordSRV-config.yml + - name: common-mcserver-plugin-configs + mountPath: /plugins/DiscordSRV/messages.yml + subPath: DiscordSRV-messages.yml + + # LunaChat プラグインの設定ファイル + - name: common-mcserver-plugin-configs + mountPath: /plugins/LunaChat/config.yml + subPath: LunaChat-config.yml + + # JMX exporter 周りのファイルが入ったボリューム達のマウント設定 + - name: jmx-exporter-download-volume + mountPath: /jmx-exporter/jmx-exporter-javaagent.jar + subPath: jmx-exporter-javaagent.jar + - name: common-jmx-exporter-config + mountPath: /jmx-exporter/jmx-exporter-config.yaml + subPath: jmx-exporter-config.yaml + + - name: mod-downloader-volume + mountPath: /plugins + + - name: world-download-volume + mountPath: /data + + volumes: + - name: common-mcserver-configs + configMap: + name: common-mcserver-configs + - name: common-mcserver-plugin-configs + configMap: + name: common-mcserver-plugin-configs + - name: minecraft-ops-config + configMap: + name: minecraft-ops-config + + # JMX exporterをinitContainerでダウンロードしてBugneeCordに受け渡すためのvolume + - name: jmx-exporter-download-volume + emptyDir: {} + - name: common-jmx-exporter-config + configMap: + name: common-jmx-exporter-config + + # mod-downloaderからプラグインをinitContainerでダウンロードしてBugneeCordに受け渡すためのvolume + - name: mod-downloader-volume + emptyDir: {} + + # S1から取ってきたワールドデータをぶちこむボリューム + - name: world-download-volume + emptyDir: {} diff --git a/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/debug-lobby/ops-config.yaml b/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/debug-lobby/ops-config.yaml new file mode 100644 index 000000000..862beefb9 --- /dev/null +++ b/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/debug-lobby/ops-config.yaml @@ -0,0 +1,38 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: minecraft-ops-config +data: + ops.json: | + [ + { + "uuid": "0ea34656-b1c7-45c0-8b89-1ec55a70fe17", + "name": "Lucky3028", + "level": 4, + "bypassesPlayerLimit": false + }, + { + "uuid": "0e117246-6d1c-46f1-b4f3-4310b9fbfedb", + "name": "galapon", + "level": 4, + "bypassesPlayerLimit": false + }, + { + "uuid": "89f9b874-8303-4605-b45b-c271ab6d6a89", + "name": "Kory3", + "level": 4, + "bypassesPlayerLimit": false + }, + { + "uuid": "b66cc3f6-a045-42ad-b4b8-320f20caf140", + "name": "unchama", + "level": 4, + "bypassesPlayerLimit": false + }, + { + "uuid": "e1ee55bb-c993-4896-88e9-9893a11df27a", + "name": "rito_5289", + "level": 4, + "bypassesPlayerLimit": false + } + ] diff --git a/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/debug-lobby/service-monitor.yaml b/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/debug-lobby/service-monitor.yaml new file mode 100644 index 000000000..2e21d5576 --- /dev/null +++ b/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/debug-lobby/service-monitor.yaml @@ -0,0 +1,17 @@ +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + labels: + app: mcserver + release: prometheus + mcserver: debug-lobby + name: mcserver-metrics--debug-lobby +spec: + endpoints: + - interval: 30s + port: jmx-metrics + selector: + matchLabels: + app: mcserver + role: metrics + mcserver: debug-lobby diff --git a/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/debug-lobby/service.yaml b/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/debug-lobby/service.yaml new file mode 100644 index 000000000..f3f8ae145 --- /dev/null +++ b/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/debug-lobby/service.yaml @@ -0,0 +1,21 @@ +apiVersion: v1 +kind: Service +metadata: + name: mcserver--debug-lobby + labels: + app: mcserver + role: metrics + mcserver: debug-lobby +spec: + type: ClusterIP + ports: + - name: minecraft + port: 25565 + protocol: TCP + targetPort: minecraft + - name: jmx-metrics + port: 18321 + protocol: TCP + targetPort: jmx-metrics + selector: + mcserver: debug-lobby diff --git a/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/debug-s1/seichiassist.yaml b/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/debug-s1/seichiassist.yaml index 6432a007a..7a6f958ae 100644 --- a/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/debug-s1/seichiassist.yaml +++ b/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/debug-s1/seichiassist.yaml @@ -61,7 +61,7 @@ spec: image: busybox:1.36.1 env: - name: WORLD_URL # S1からインポートしてきたワールドデータ - value: "http://seichi-private-plugin-blackhole-minio.minio:9000/seichi-plugins/world.tar.gz" + value: "http://seichi-private-plugin-blackhole-minio.minio:9000/seichi-plugins/word-data/s1/world.tar.gz" volumeMounts: - name: world-download-volume mountPath: /data @@ -75,9 +75,12 @@ spec: requests: cpu: 4 memory: 8Gi + limits: + cpu: 4 + memory: 8Gi env: - name: MEMORY - value: 2048m + value: 6144m - name: TYPE value: PAPER - name: VERSION diff --git a/seichi-onp-k8s/manifests/seichi-kubernetes/apps/seichi-debug-gateway/bungeecord/bungeecord-config.yaml b/seichi-onp-k8s/manifests/seichi-kubernetes/apps/seichi-debug-gateway/bungeecord/bungeecord-config.yaml index b7a2ac875..65937cdc9 100644 --- a/seichi-onp-k8s/manifests/seichi-kubernetes/apps/seichi-debug-gateway/bungeecord/bungeecord-config.yaml +++ b/seichi-onp-k8s/manifests/seichi-kubernetes/apps/seichi-debug-gateway/bungeecord/bungeecord-config.yaml @@ -8,7 +8,7 @@ spec: servers: {{- range . }} debug-pr-{{ . }}: - address: mcserver--debug-s1.seichi-debug-minecraft-on-seichiassist-pr-{{ . }}:25565 + address: mcserver--debug-lobby.seichi-debug-minecraft-on-seichiassist-pr-{{ . }}:25565 restricted: false motd: '' {{- end }}