From ee6cd0a3f409374b33ce3b86586f95ccce8d765f Mon Sep 17 00:00:00 2001 From: accassid Date: Thu, 22 Aug 2024 14:55:01 -0600 Subject: [PATCH 1/2] Adding kubernetes pod, fixing image name --- .github/workflows/ci.yml | 2 +- backend/.kubernetes/kubernetes.yaml | 37 +++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7f634464..145d8492 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -319,7 +319,7 @@ jobs: ECR_REPOSITORY: ${{ secrets.AWS_DISCORD_ECR_REPO_NAME }} IMAGE_TAG: latest run: | - docker tag spellbook-backend:latest $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + docker tag spellbook-discord-bot:latest $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG - name: Rollout pods 🚀 diff --git a/backend/.kubernetes/kubernetes.yaml b/backend/.kubernetes/kubernetes.yaml index 5566e3ba..ecc8a29e 100644 --- a/backend/.kubernetes/kubernetes.yaml +++ b/backend/.kubernetes/kubernetes.yaml @@ -264,3 +264,40 @@ roleRef: name: spellbook-ns-full-access apiGroup: rbac.authorization.k8s.io +--- + +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: spellbook + name: spellbook-discord-bot + labels: + app: spellbook-discord-bot +spec: + selector: + matchLabels: + app: spellbook-discord-bot + template: + metadata: + labels: + app: spellbook-discord-bot + spec: + serviceAccountName: app-service-account + containers: + - name: spellbook-discord-bot-app + image: 083767677168.dkr.ecr.us-east-2.amazonaws.com/spellbook-prod-discord-ecr + ports: + - containerPort: 80 + livenessProbe: + exec: + command: + - ls + initialDelaySeconds: 40 + periodSeconds: 20 + timeoutSeconds: 5 + env: + - name: KUBE_DISCORD_TOKEN + valueFrom: + secretKeyRef: + name: discord-bot-secrets + key: discord-token \ No newline at end of file From d472e63fb96eca72b4349262c443a067ab716d4d Mon Sep 17 00:00:00 2001 From: accassid Date: Thu, 22 Aug 2024 15:05:32 -0600 Subject: [PATCH 2/2] adding admin ids and backend curl --- backend/.kubernetes/kubernetes.yaml | 16 ++++++++++++++-- bot/discord/spellbook_discord.py | 6 +++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/backend/.kubernetes/kubernetes.yaml b/backend/.kubernetes/kubernetes.yaml index ecc8a29e..c94b39f2 100644 --- a/backend/.kubernetes/kubernetes.yaml +++ b/backend/.kubernetes/kubernetes.yaml @@ -291,7 +291,9 @@ spec: livenessProbe: exec: command: - - ls + - curl + - -f + - https://backend.commanderspellbook.com initialDelaySeconds: 40 periodSeconds: 20 timeoutSeconds: 5 @@ -300,4 +302,14 @@ spec: valueFrom: secretKeyRef: name: discord-bot-secrets - key: discord-token \ No newline at end of file + key: discord-token + - name: KUBE_ADMIN_USER__0 + valueFrom: + secretKeyRef: + name: discord-bot-secrets + key: deloo-discord-id + - name: KUBE_ADMIN_USER__1 + valueFrom: + secretKeyRef: + name: discord-bot-secrets + key: andy-discord-id \ No newline at end of file diff --git a/bot/discord/spellbook_discord.py b/bot/discord/spellbook_discord.py index e7897008..4b8e4a67 100644 --- a/bot/discord/spellbook_discord.py +++ b/bot/discord/spellbook_discord.py @@ -35,8 +35,8 @@ add_reactions=True, use_external_emojis=True, ) -administration_guilds = [int(guild) for guild in (os.getenv(f'ADMIN_GUILD__{i}') for i in range(10)) if guild is not None] -administration_users = [int(user) for user in (os.getenv(f'ADMIN_USER__{i}') for i in range(10)) if user is not None] +administration_guilds = [int(guild) for guild in (os.getenv(f'KUBE_ADMIN_GUILD__{i}', os.getenv(f'ADMIN_GUILD__{i}')) for i in range(10)) if guild is not None] +administration_users = [int(user) for user in (os.getenv(f'KUBE_ADMIN_USER__{i}', os.getenv(f'ADMIN_USER__{i}')) for i in range(10)) if user is not None] MAX_SEARCH_RESULTS = 7 @@ -346,4 +346,4 @@ async def find_my_combos(interaction: discord.Interaction, decklist: str | None await interaction.response.send_modal(FindMyCombosModal()) -bot.run(os.getenv('DISCORD_TOKEN', '')) +bot.run(os.getenv('KUBE_DISCORD_TOKEN', os.getenv('DISCORD_TOKEN', '')))