This commit is contained in:
2025-11-18 03:48:19 +00:00
parent 5e78c7c529
commit 5ea805c450
10 changed files with 23378 additions and 1 deletions

View File

@ -1,2 +1,2 @@
# assignment02
- 과제 2 진행을 위한 코드 입니다.

14
argocd/application.yaml Normal file
View File

@ -0,0 +1,14 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: voyger-assign
namespace: argocd
spec:
destination:
namespace: voyger-assign
server: https://kubernetes.default.svc
project: voyger-assignments
source:
path: overlays/assignments
repoURL: https://gitea.icurfer.com/dev/voyger-assignments.git
targetRevision: HEAD

View File

@ -0,0 +1,23 @@
# Offloading setting.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: argocd-ingress
namespace: argocd
annotations:
#nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
nginx.ingress.kubernetes.io/backend-protocol: "https"
nginx.ingress.kubernetes.io/ssl-passthrough: "true"
spec:
ingressClassName: nginx
rules:
- host: argocd.icurfer.com # 사전 생성된 인증서의 도메인적용.
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: argocd-server
port:
number: 443

File diff suppressed because it is too large Load Diff

22
be_getUsers/Dockerfile Normal file
View File

@ -0,0 +1,22 @@
# pull official base image
FROM python:3.10-slim-bullseye
# set work directory
WORKDIR /usr/src/app
# set environment variable
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# copy project files
COPY . /usr/src/app/
# install python dependencies
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
# expose the port
EXPOSE 5000
# command to run
CMD ["gunicorn", "--workers=3", "--bind=0.0.0.0:5000", "list_app:app"]

17
be_getUsers/list_app.py Normal file
View File

@ -0,0 +1,17 @@
# list_app.py
from flask import Flask, jsonify
import os
app = Flask(__name__)
DB_DIR = './data'
DB_FILE = f'{DB_DIR}/db.json'
@app.route('/users')
def users():
with open(DB_FILE, 'r') as f:
data = f.read()
return data, 200
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5002)

View File

@ -0,0 +1,8 @@
blinker==1.9.0
click==8.3.0
Flask==3.1.2
itsdangerous==2.2.0
Jinja2==3.1.6
MarkupSafe==3.0.3
Werkzeug==3.1.3
gunicorn==20.1.0

22
be_signup/Dockerfile Normal file
View File

@ -0,0 +1,22 @@
# pull official base image
FROM python:3.10-slim-bullseye
# set work directory
WORKDIR /usr/src/app
# set environment variable
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# copy project files
COPY . /usr/src/app/
# install python dependencies
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
# expose the port
EXPOSE 5000
# command to run
CMD ["gunicorn", "--workers=3", "--bind=0.0.0.0:5000", "signup_app:app"]

View File

@ -0,0 +1,8 @@
blinker==1.9.0
click==8.3.0
Flask==3.1.2
itsdangerous==2.2.0
Jinja2==3.1.6
MarkupSafe==3.0.3
Werkzeug==3.1.3
gunicorn==20.1.0

52
be_signup/signup_app.py Normal file
View File

@ -0,0 +1,52 @@
# signup_app.py
from flask import Flask, request, jsonify
import os
import json
app = Flask(__name__)
DB_DIR = './data'
DB_FILE = f'{DB_DIR}/db.json'
# ensure directory exists
os.makedirs(DB_DIR, exist_ok=True)
# DB 초기화 함수
def init_db():
if not os.path.exists(DB_FILE):
with open(DB_FILE, 'w') as f:
json.dump([], f)
else:
try:
with open(DB_FILE, 'r') as f:
data = json.load(f)
if not isinstance(data, list):
raise ValueError
except:
with open(DB_FILE, 'w') as f:
json.dump([], f)
@app.route('/signup', methods=['POST'])
def signup():
data = request.get_json()
if not data or 'name' not in data:
return jsonify({'error': 'Missing name or email'}), 400
with open(DB_FILE, 'r') as f:
users = json.load(f)
users.append({'name': data['name'], 'email': data.get('email', '')})
with open(DB_FILE, 'w') as f:
# json.dump(users, f)
json.dump(users, f, ensure_ascii=False, indent=2)
return jsonify({'status': 'ok'})
# DB 초기화
init_db()
if __name__ == '__main__':
# init_db() # 서버 시작할 때 DB 초기화
# app.run(host='127.0.0.1', port=5000)
app.run(host='0.0.0.0', port=5000)