From a7231d80e3a16726c1762e29059ddba756590d90 Mon Sep 17 00:00:00 2001 From: m1sk9 Date: Thu, 29 Aug 2024 14:00:29 +0900 Subject: [PATCH 1/3] feat: Add babyrite pod --- .../seichi-minecraft/babyrite/babyrite.yaml | 40 +++++++++++++++++++ .../common-configs/babyrite-config.yaml | 12 ++++++ terraform/main.tf | 6 +++ terraform/onp_cluster_secrets.tf | 13 ++++++ 4 files changed, 71 insertions(+) create mode 100644 seichi-onp-k8s/manifests/seichi-kubernetes/apps/seichi-minecraft/babyrite/babyrite.yaml create mode 100644 seichi-onp-k8s/manifests/seichi-kubernetes/apps/seichi-minecraft/common-configs/babyrite-config.yaml diff --git a/seichi-onp-k8s/manifests/seichi-kubernetes/apps/seichi-minecraft/babyrite/babyrite.yaml b/seichi-onp-k8s/manifests/seichi-kubernetes/apps/seichi-minecraft/babyrite/babyrite.yaml new file mode 100644 index 000000000..ec98eed95 --- /dev/null +++ b/seichi-onp-k8s/manifests/seichi-kubernetes/apps/seichi-minecraft/babyrite/babyrite.yaml @@ -0,0 +1,40 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: babyrite + namespace: seichi-minecraft + labels: + app: babyrite +spec: + replicas: 1 + selector: + matchLabels: + app: babyrite + template: + metadata: + labels: + app: babyrite + spec: + - name: babyrite + image: ghcr.io/m1sk9/babyrite:v0.9.1 + resources: + requests: + cpu: 250m + memory: 16Mi + limits: + cpu: 500m + memory: 32Mi + volumeMounts: + - name: babyrite-config-volume + mountPath: /home/babyrite/config/config.yaml + env: + - name: DISCORD_API_TOKEN + valueFrom: + secretKeyRef: + name: babyrite-discord-token + key: BABYRITE_DISCORD_TOKEN + volumes: + - name: babyrite-config-volume + configMap: + name: babyrite-config + diff --git a/seichi-onp-k8s/manifests/seichi-kubernetes/apps/seichi-minecraft/common-configs/babyrite-config.yaml b/seichi-onp-k8s/manifests/seichi-kubernetes/apps/seichi-minecraft/common-configs/babyrite-config.yaml new file mode 100644 index 000000000..5d864974e --- /dev/null +++ b/seichi-onp-k8s/manifests/seichi-kubernetes/apps/seichi-minecraft/common-configs/babyrite-config.yaml @@ -0,0 +1,12 @@ +# babyrite Config +# This file is used to configure babyrite. +# You can change the settings here to customize babyrite's behavior. +# For more information, see the babyrite documentation at https://babyrite.m1sk9.dev/configuration.html + +apiVersion: v1 +kind: ConfigMap +metadata: + name: babyrite-config +data: + config.yaml: | + bypass_guilds: false diff --git a/terraform/main.tf b/terraform/main.tf index 98d8dd4b6..81d06ae04 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -304,6 +304,12 @@ variable "minecraft__idea_reaction_redmine_api_key" { sensitive = true } +variable "minecraft__babyrite_discord_token" { + description = "Token set to the production babyrite" + type = string + sensitive = true +} + #endregion #region env variables for Cloudflare Pages projects diff --git a/terraform/onp_cluster_secrets.tf b/terraform/onp_cluster_secrets.tf index 14a0d5906..dbd6770e6 100644 --- a/terraform/onp_cluster_secrets.tf +++ b/terraform/onp_cluster_secrets.tf @@ -292,3 +292,16 @@ resource "kubernetes_secret" "idea_reaction_redmine_api_key" { IDEA_REACTION_REDMINE_API_KEY = var.minecraft__idea_reaction_redmine_api_key } } + +resource "kubernetes_secret" "babyrite_discord_token" { + depends_on = [kubernetes_namespace.onp_seichi_minecraft] + + metadata { + name = "babyrite-discord-token" + namespace = "seichi-minecraft" + } + + data = { + BABYRITE_DISCORD_TOKEN = var.minecraft__babyrite_discord_token + } +} From 5add88bb2d56adf599ea1985598e63445b2a0fcf Mon Sep 17 00:00:00 2001 From: m1sk9 Date: Sun, 1 Sep 2024 17:43:02 +0900 Subject: [PATCH 2/3] fix: Fix secret prefix --- terraform/main.tf | 2 +- terraform/onp_cluster_secrets.tf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/terraform/main.tf b/terraform/main.tf index 81d06ae04..25ba7bac5 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -304,7 +304,7 @@ variable "minecraft__idea_reaction_redmine_api_key" { sensitive = true } -variable "minecraft__babyrite_discord_token" { +variable "discord_bot__babyrite_discord_token" { description = "Token set to the production babyrite" type = string sensitive = true diff --git a/terraform/onp_cluster_secrets.tf b/terraform/onp_cluster_secrets.tf index dbd6770e6..033f065e8 100644 --- a/terraform/onp_cluster_secrets.tf +++ b/terraform/onp_cluster_secrets.tf @@ -302,6 +302,6 @@ resource "kubernetes_secret" "babyrite_discord_token" { } data = { - BABYRITE_DISCORD_TOKEN = var.minecraft__babyrite_discord_token + BABYRITE_DISCORD_TOKEN = var.discord_bot__babyrite_discord_token } } From a43911761b8c967be1be2fd8fd3c2532f6afc7da Mon Sep 17 00:00:00 2001 From: m1sk9 Date: Mon, 2 Sep 2024 20:03:50 +0900 Subject: [PATCH 3/3] chore: apply babyrite v0.9.2 --- .../apps/seichi-minecraft/babyrite/babyrite.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/seichi-onp-k8s/manifests/seichi-kubernetes/apps/seichi-minecraft/babyrite/babyrite.yaml b/seichi-onp-k8s/manifests/seichi-kubernetes/apps/seichi-minecraft/babyrite/babyrite.yaml index ec98eed95..75e9473d8 100644 --- a/seichi-onp-k8s/manifests/seichi-kubernetes/apps/seichi-minecraft/babyrite/babyrite.yaml +++ b/seichi-onp-k8s/manifests/seichi-kubernetes/apps/seichi-minecraft/babyrite/babyrite.yaml @@ -16,7 +16,7 @@ spec: app: babyrite spec: - name: babyrite - image: ghcr.io/m1sk9/babyrite:v0.9.1 + image: ghcr.io/m1sk9/babyrite:v0.9.2 resources: requests: cpu: 250m @@ -28,6 +28,9 @@ spec: - name: babyrite-config-volume mountPath: /home/babyrite/config/config.yaml env: + # 相対パスを指定する + - name: CONFIG_FILE_PATH + value: "config/config.yaml" - name: DISCORD_API_TOKEN valueFrom: secretKeyRef: