Skip to content

Commit

Permalink
feat: 로컬 개발 환경에서 도커이미지를 빌드하고 쿠버네티스에 올릴 수 있도록 수정
Browse files Browse the repository at this point in the history
npm 명령으로 변경사항을 빌드하고 쿠버네티스에 적용할 수 있도록 스크립트 작성
  • Loading branch information
Hoons97 committed Jan 14, 2025
1 parent e7a5728 commit ee8dd57
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 2 deletions.
15 changes: 14 additions & 1 deletion kubernetes/apiServer-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ spec:
spec:
containers:
- name: apiserver
image: hoon317/qlab-apiserver:latest
image: local-qlab-apiserver:latest
imagePullPolicy: Never
ports:
- containerPort: 3000
env:
Expand All @@ -34,6 +35,18 @@ spec:
- name: DB_DATABASE
value: 'qlabdb'

- name: QUERY_DB_TYPE
value: 'mysql'
- name: QUERY_DB_PORT
value: '3306'
- name: QUERY_DB_USER
value: 'root'
- name: QUERY_DB_PASSWORD
valueFrom:
secretKeyRef:
name: qlab-secret
key: querydb-password

- name: REDIS_HOST
value: 'redis-service.default'
- name: REDIS_PORT
Expand Down
1 change: 1 addition & 0 deletions kubernetes/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ metadata:
type: Opaque
data:
db-password: cm9vdHBhc3N3b3Jk #rootpassword
querydb-password: cm9vdHBhc3N3b3Jk #rootpassword
session-secret: c2Vzc2lvbi1zZWNyZXQ= #session-secret
3 changes: 2 additions & 1 deletion kubernetes/webServer-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ spec:
spec:
containers:
- name: webserver
image: hoon317/qlab-webserver:latest
image: local-qlab-webserver:latest
imagePullPolicy: Never
ports:
- containerPort: 80
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"name": "web36-qlab",
"version": "1.0.0",
"scripts": {
"minikube:win": "powershell ./scripts/minikube.ps1",
"minikube:unix": "bash ./scripts/minikube.sh",
"start:minikube": "npm run minikube:win || npm run minikube:unix",
"start:container": "npm run start:backend && npm run setup:frontend && npm run start:frontend",
"start:backend": "docker-compose -f ./BE/docker-compose.backend.local.yml up --build -d",
"setup:frontend": "cd FE && npm install",
Expand Down
14 changes: 14 additions & 0 deletions scripts/minikube.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
$status = & minikube status --format="{{.Host}}"
if ($status -eq "Running") {
Write-Host "Minikube is already running."
} else {
& minikube start
}

& minikube docker-env | Invoke-Expression
docker build -t local-qlab-apiserver -f ./BE/Dockerfile .
docker build -t local-qlab-webserver -f ./FE/Dockerfile .

kubectl delete -f ./kubernetes/apiServer-deployment.yaml
kubectl delete -f ./kubernetes/webServer-deployment.yaml
kubectl apply -f ./kubernetes/
16 changes: 16 additions & 0 deletions scripts/minikube.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

status=$(minikube status --format='{{.Host}}')
if [ "$status" == "Running" ]; then
echo "Minikube is already running."
else
minikube start
fi

eval $(minikube docker-env)
docker build -t local-qlab-apiserver -f ./BE/Dockerfile .
docker build -t local-qlab-webserver -f ./FE/Dockerfile .

kubectl delete -f ./kubernetes/apiServer-deployment.yaml
kubectl delete -f ./kubernetes/webServer-deployment.yaml
kubectl apply -f ./kubernetes/

0 comments on commit ee8dd57

Please sign in to comment.