Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker Desktopのクラスタで動くk8sマニフェストを作成 #229

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
e7f6d12
ローカルで使うk8sの雛形作成
Tatsumi0000 Apr 20, 2024
2527483
ディレクトリ名を変更
Tatsumi0000 Apr 20, 2024
56a6699
ローカルのfrontendファイルをマウントします
Tatsumi0000 Apr 20, 2024
6b61a90
鍵はcommitしたくないので除外設定について
Tatsumi0000 Apr 20, 2024
228a578
ローカルのディレクトリたちをマウントする
Tatsumi0000 Apr 20, 2024
5c6c271
volumesのインデントがずれていた
Tatsumi0000 Apr 20, 2024
1e23ddf
dbコンテナに環境変数をセットするので位置を修正
Tatsumi0000 Apr 20, 2024
289a2a9
backendとfrontendが見えないのでディレクトリの階層を1個浅くする
Tatsumi0000 Apr 20, 2024
368c4c4
backendとfrontendが見えないのでディレクトリの階層を1個浅くする
Tatsumi0000 Apr 20, 2024
5a0ff35
Revert "backendとfrontendが見えないのでディレクトリの階層を1個浅くする"
Tatsumi0000 Apr 20, 2024
672ba2f
Revert "backendとfrontendが見えないのでディレクトリの階層を1個浅くする"
Tatsumi0000 Apr 20, 2024
5bb25c3
普通にローカルのマウントをしないようにした
Tatsumi0000 Apr 20, 2024
6265492
ライブラリをイメージに含める
Tatsumi0000 Apr 20, 2024
ce54b12
COPYしないとライブラリをインストールするためのファイルが見れない
Tatsumi0000 Apr 20, 2024
24a52be
Add
Tatsumi0000 Apr 21, 2024
70ca227
メモリが足りずにviteが立ち上がってなかったので増やす
Tatsumi0000 Apr 24, 2024
94f04b3
configMapGenerator経由で環境変数をセットする
Tatsumi0000 Apr 24, 2024
08cbb4f
同一deployment内にいたほうが通信が楽なのでまとめる
Tatsumi0000 Apr 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion web/backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ RUN rbenv install 3.3.0 && \
RUN gem update && \
bundle config set path vendor/bundle


WORKDIR /usr/src/app
COPY . /usr/src/app
RUN bundle install
3 changes: 3 additions & 0 deletions web/frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ RUN apt update && \
RUN npm install -g npm

WORKDIR /usr/src/app

COPY . /usr/src/app
RUN npm install
1 change: 1 addition & 0 deletions web/infra/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub-cert.pem
28 changes: 28 additions & 0 deletions web/infra/base/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: starry-kids
name: web
spec:
replicas: 1
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: frontend
image: frontend-image
ports:
- containerPort: 5173
resources:
limits:
memory: "128Mi"
cpu: "250m"
command:
- "npm"
- "run"
- "dev"
11 changes: 11 additions & 0 deletions web/infra/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: "starry-kids"

resources:
- deployment.yaml

images:
- name: frontend-image
newName: ghcr.io/tatsumi0000/starry-kids/frontend
newTag: latest
1 change: 1 addition & 0 deletions web/infra/overlays/local/config/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MYSQL_ROOT_PASSWORD=password
58 changes: 58 additions & 0 deletions web/infra/overlays/local/deployment.patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: starry-kids
name: web
spec:
replicas: 1
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: backend
image: ghcr.io/tatsumi0000/starry-kids/backend:latest
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
configMapKeyRef:
name: db-config
key: MYSQL_ROOT_PASSWORD
ports:
- containerPort: 3000
resources:
limits:
cpu: "250m"
memory: "769Mi"
command:
- "bundle exec db:prepare"
- "bin/rails"
- "s"
- "-b"
- "0.0.0.0"
- name: db
image: mysql:8.1.0
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
configMapKeyRef:
name: db-config
key: MYSQL_ROOT_PASSWORD
ports:
- containerPort: 3306
resources:
limits:
cpu: "250m"
memory: "769Mi"
volumeMounts:
- name: db
mountPath: /var/lib/mysql
volumes:
- name: db
hostPath:
path: /db_data
type: DirectoryOrCreate
14 changes: 14 additions & 0 deletions web/infra/overlays/local/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: starry-kids

resources:
- "../../base"

patches:
- path: deployment.patch.yaml

configMapGenerator:
- name: db-config
envs:
- config/.env
Loading