diff --git a/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/debug-s1/kustomization.yaml b/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/debug-s1/kustomization.yaml new file mode 100644 index 000000000..a01659150 --- /dev/null +++ b/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/debug-s1/kustomization.yaml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: seichi-debug-minecraft + +resources: + - "./service-monitor.yaml" + - "./service.yaml" + - "./stateful-set.yaml" diff --git a/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/debug-s1/service-monitor.yaml b/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/debug-s1/service-monitor.yaml new file mode 100644 index 000000000..1917f20ff --- /dev/null +++ b/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/debug-s1/service-monitor.yaml @@ -0,0 +1,17 @@ +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + labels: + app: mcserver + release: prometheus + mcserver: debug-s1 + name: mcserver-metrics--debug-s1 +spec: + endpoints: + - interval: 30s + port: jmx-metrics + selector: + matchLabels: + app: mcserver + role: metrics + mcserver: debug-s1 diff --git a/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/debug-s1/service.yaml b/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/debug-s1/service.yaml new file mode 100644 index 000000000..291fa93e3 --- /dev/null +++ b/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/debug-s1/service.yaml @@ -0,0 +1,21 @@ +apiVersion: v1 +kind: Service +metadata: + name: mcserver--debug-s1 + labels: + app: mcserver + role: metrics + mcserver: debug-s1 +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-s1 diff --git a/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/debug-s1/stateful-set.yaml b/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/debug-s1/stateful-set.yaml new file mode 100644 index 000000000..a59a0ded4 --- /dev/null +++ b/seichi-onp-k8s/manifests/seichi-kubernetes/app-templates/seichi-debug-minecraft-on-seichiassist-pr/templates/debug-s1/stateful-set.yaml @@ -0,0 +1,177 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + annotations: + reloader.stakater.com/auto: "true" + labels: + app: mcserver + mcserver: debug-s1 + name: mcserver--debug-s1 +spec: + replicas: 1 + serviceName: "mcserver--debug-s1" + selector: + matchLabels: + app: mcserver--debug-s1 + mcserver: debug-s1 + template: + metadata: + labels: + app: mcserver--debug-s1 + mcserver: debug-s1 + 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}"' + + containers: + - resources: + requests: + memory: 2100Mi + env: + - name: MEMORY + value: 2048m + - name: TYPE + value: PAPER + - name: VERSION + value: "1.12.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 + # ViaBackwards: + # https://github.com/ViaVersion/ViaBackwards/releases/download/4.4.2/ViaBackwards-4.4.2.jar + # ViaVersion: + # https://github.com/ViaVersion/ViaVersion/releases/download/4.4.2/ViaVersion-4.4.2.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://github.com/ViaVersion/ViaBackwards/releases/download/4.4.2/ViaBackwards-4.4.2.jar, + https://github.com/ViaVersion/ViaVersion/releases/download/4.4.2/ViaVersion-4.4.2.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" + + image: itzg/minecraft-server:2023.9.1-java8-jdk + name: minecraft + ports: + - containerPort: 25565 + name: minecraft + - containerPort: 18321 + name: jmx-metrics + + startupProbe: + tcpSocket: + port: 25565 + # 最大120秒待つ + failureThreshold: 6 + periodSeconds: 20 + + 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 + + # 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 + + # MorningGlorySeeds プラグインの設定ファイル + - name: common-mcserver-plugin-configs + mountPath: /plugins/MorningGlorySeeds/config.yml + subPath: MorningGlorySeeds-config.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 + + volumes: + - name: common-mcserver-configs + configMap: + name: common-mcserver-configs + - name: common-mcserver-plugin-configs + configMap: + name: common-mcserver-plugin-configs + + # JMX exporterをinitContainerでダウンロードしてBugneeCordに受け渡すためのvolume + - name: jmx-exporter-download-volume + emptyDir: {} + - name: common-jmx-exporter-config + configMap: + name: common-jmx-exporter-config