Skip to content

Commit

Permalink
シークレットの管理方法を改善
Browse files Browse the repository at this point in the history
  • Loading branch information
na2na-p committed Nov 27, 2023
1 parent d464835 commit 1ea5dc7
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 24 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ coverage
built/
.env
.idea
configmap.yml
values.yaml
secret.yml
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Discord Bot

# 必要なもの
## 必要なもの

.tool-versionsを参照してください。
asdfを使っている場合はそのまま入ります。
Expand All @@ -11,7 +11,21 @@ asdfを使っている場合はそのまま入ります。

Pythonは、`@discordjs/opus`の入れるのに必要です。

# 登場するドメイン
## 登場するドメイン

- Actor
- Userの子概念で、interactしたUserを指す。

## Helmを利用してデプロイする

### リソースの作成

1. `infra/k8s/manifests/secret.example.yml`を参考に、同ディレクトリに`secret.yml`を作成する
1. SecretはBase64エンコードすること
2. `kubectl apply -f infra/k8s/manifests/secret.yml`でSecretの適用をする
3. `helm install {任意の名前/バージョン名など} ./infra/k8s/helm`

### リソースの削除

1. `helm uninstall {任意の名前/バージョン名など}`
2. `kubectl delete -f infra/k8s/manifests/secret.yml`
10 changes: 3 additions & 7 deletions infra/k8s/helm/templates/jetdisc/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,8 @@ spec:
- name: {{ .Chart.Name }}
image: '{{ .Values.image.repository }}:{{ .Values.image.tag }}'
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: DISCORD_APP_TOKEN
value: {{ .Values.secret.DISCORD_APP_TOKEN }}
- name: BOT_NAME
value: {{ .Values.secret.BOT_NAME }}
- name: SET_COMMANDS_TARGET_SERVERS
value: {{ .Values.secret.SET_COMMANDS_TARGET_SERVERS }}
envFrom:
- secretRef:
name: {{ .Values.secret.name }}
resources: {{- toYaml .Values.resources | nindent 12 }}
restartPolicy: Always
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ image:

secret:
name: jetdisc-secret
DISCORD_APP_TOKEN: ""
BOT_NAME: "2na2"
SET_COMMANDS_TARGET_SERVERS: ""

resources:
limits:
Expand Down
4 changes: 2 additions & 2 deletions infra/k8s/manifests/app-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ spec:
- name: jetdisc
image: na2na/jetdisc:preview
envFrom:
- configMapRef:
name: jetdisc-config
- secretRef:
name: jetdisc-secret
resources:
limits:
cpu: 500m
Expand Down
8 changes: 0 additions & 8 deletions infra/k8s/manifests/configmap.example.yml

This file was deleted.

9 changes: 9 additions & 0 deletions infra/k8s/manifests/secret.example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: Secret
metadata:
name: jetdisc-secret
type: Opaque
data:
DISCORD_APP_TOKEN: base64エンコードされたトークン
BOT_NAME: base64エンコードされたボット名
SET_COMMANDS_TARGET_SERVERS: base64エンコードされたサーバーID

0 comments on commit 1ea5dc7

Please sign in to comment.