From dd2111496c457601fdf4a470fec8077a7ba5f319 Mon Sep 17 00:00:00 2001 From: choisungwook Date: Wed, 8 Jun 2022 21:08:32 +0900 Subject: [PATCH 01/21] =?UTF-8?q?cicd=20=EB=B0=B0=ED=8F=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 162 --------------------------------- app/.env | 14 --- app/api/__init__.py | 0 app/api/project.py | 93 ------------------- app/config.py | 52 ----------- app/database.py | 8 -- app/db_session.py | 10 -- app/documents/shcema.md | 27 ------ app/domain/__init__.py | 0 app/domain/project/__init__.py | 0 app/domain/project/crud.py | 73 --------------- app/domain/project/schemas.py | 33 ------- app/domain/project/service.py | 158 -------------------------------- app/log.yaml | 19 ---- app/logger.py | 8 -- app/main.py | 15 --- app/module/__init__.py | 0 app/module/k8s.py | 32 ------- app/requirements.txt | 45 --------- base/deployment.yaml | 25 +++++ base/ingress.yaml | 17 ++++ base/kustomization.yaml | 5 + base/service.yaml | 10 ++ dev/kustomization.yaml | 24 +++++ dev/nameReference.yaml | 6 ++ 25 files changed, 87 insertions(+), 749 deletions(-) delete mode 100644 .gitignore delete mode 100644 app/.env delete mode 100644 app/api/__init__.py delete mode 100644 app/api/project.py delete mode 100644 app/config.py delete mode 100644 app/database.py delete mode 100644 app/db_session.py delete mode 100644 app/documents/shcema.md delete mode 100644 app/domain/__init__.py delete mode 100644 app/domain/project/__init__.py delete mode 100644 app/domain/project/crud.py delete mode 100644 app/domain/project/schemas.py delete mode 100644 app/domain/project/service.py delete mode 100644 app/log.yaml delete mode 100644 app/logger.py delete mode 100644 app/main.py delete mode 100644 app/module/__init__.py delete mode 100644 app/module/k8s.py delete mode 100644 app/requirements.txt create mode 100644 base/deployment.yaml create mode 100644 base/ingress.yaml create mode 100644 base/kustomization.yaml create mode 100644 base/service.yaml create mode 100644 dev/kustomization.yaml create mode 100644 dev/nameReference.yaml diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 0e74795..0000000 --- a/.gitignore +++ /dev/null @@ -1,162 +0,0 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -cover/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -.pybuilder/ -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -# For a library or package, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: -# .python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# poetry -# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. -# This is especially recommended for binary packages to ensure reproducibility, and is more -# commonly ignored for libraries. -# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control -#poetry.lock - -# pdm -# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. -#pdm.lock -# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it -# in version control. -# https://pdm.fming.dev/#use-with-ide -.pdm.toml - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# Cython debug symbols -cython_debug/ - -# PyCharm -# JetBrains specific template is maintained in a separate JetBrains.gitignore that can -# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore -# and can be added to the global gitignore or merged into this file. For a more nuclear -# option (not recommended) you can uncomment the following to ignore the entire idea folder. -.idea/ - -# vscode -.vscode \ No newline at end of file diff --git a/app/.env b/app/.env deleted file mode 100644 index a529bc0..0000000 --- a/app/.env +++ /dev/null @@ -1,14 +0,0 @@ -LOCAL_POSTGRESQL_HOST="192.168.10.10:31850" -LOCAL_POSTGRESQL_USER="root" -LOCAL_POSTGRESQL_PASSWORD="password" -LOCAL_POSTGRESQL_DB="jcp" - -DEV_POSTGRESQL_HOST="127.0.0.1:5432" -DEV_POSTGRESQL_USER="root" -DEV_POSTGRESQL_PASSWORD="password" -DEV_POSTGRESQL_DB="jcp" - -PROD_POSTGRESQL_HOST="127.0.0.1:5432" -PROD_POSTGRESQL_USER="root" -PROD_POSTGRESQL_PASSWORD="password" -PROD_POSTGRESQL_DB="jcp" \ No newline at end of file diff --git a/app/api/__init__.py b/app/api/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/app/api/project.py b/app/api/project.py deleted file mode 100644 index 9de51d6..0000000 --- a/app/api/project.py +++ /dev/null @@ -1,93 +0,0 @@ -from fastapi import APIRouter, Depends, status -from fastapi.responses import JSONResponse -from sqlalchemy.orm import Session -from db_session import get_db -from domain.project.schemas import ( - RequestCreateProject, - RequestDeleteProject, - RequestGetProject -) -from domain.project.service import ProjectManager -from logger import log - -router = APIRouter( - prefix="/api/v1/project", - tags=["project"] -) - -@router.get("/") -async def project( - name: str = None, db: Session = Depends(get_db) - ): - """프로젝트 조회""" - log.info("============= /project/ is called ============= ") - project_manager = ProjectManager() - - if name is None: - return JSONResponse( - status_code=status.HTTP_400_BAD_REQUEST, - content="이름을 입력하지 않았습니다" - ) - - request = RequestGetProject(name=name) - - try: - status_code, detail = project_manager.getProject(request=request, db=db) - except Exception as e: - log.error(f"[프로젝트 조회 서비스 호출오류] 예기치 못한 오류: {e}") - return JSONResponse( - status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, - content="" - ) - - return JSONResponse( - status_code=status_code, - content=dict(detail) - ) - -@router.post("/") -async def create( - request: RequestCreateProject, db: Session = Depends(get_db) - ): - """프로젝트 생성""" - log.info("============= /project/create is called ============= ") - project_manager = ProjectManager() - try: - status_code, detail = project_manager.createProject(request=request, db=db) - except Exception as e: - log.error(f"[프로젝트 생성 서비스 호출오류] 예기치 못한 오류: {e}") - return JSONResponse( - status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, - content="" - ) - - return JSONResponse( - status_code=status_code, - content=dict(detail) - ) - -@router.delete("/") -async def delete( - request: RequestDeleteProject, db: Session = Depends(get_db) - ): - """ - 프로젝트 삭제 - :param request: 사용자 삭제요청 - :param db: db 세션 - :return: - """ - log.info("============= /project/delete is called ============= ") - project_manager = ProjectManager() - try: - status_code, detail = project_manager.deleteProject(request=request, db=db) - except Exception as e: - log.error(f"[프로젝트 삭제 서비스 호출오류] 예기치 못한 오류: {e}") - return JSONResponse( - status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, - content="프로젝트 삭제 실패" - ) - - return JSONResponse( - status_code=status_code, - content=dict(detail) - ) \ No newline at end of file diff --git a/app/config.py b/app/config.py deleted file mode 100644 index f716ec0..0000000 --- a/app/config.py +++ /dev/null @@ -1,52 +0,0 @@ -from typing import Optional -from pydantic import BaseSettings, Field - - -class GlobalConfig(BaseSettings): - """공통 설정""" - ENV_STATE: str = Field("local", env="MODE") - - POSTGRESQL_HOST: Optional[str] = None - POSTGRESQL_USER: Optional[str] = None - POSTGRESQL_PASSWORD: Optional[str] = None - POSTGRESQL_DB: Optional[str] = None - - class Config: - """BaseSettings 설정""" - env_file: str = ".env" - -class LocalConfig(GlobalConfig): - """개발 설정""" - class Config: - """BaseSettings 설정""" - env_prefix: str = "LOCAL_" - -class DevConfig(GlobalConfig): - """개발 설정""" - class Config: - """BaseSettings 설정""" - env_prefix: str = "DEV_" - -class ProdConfig(GlobalConfig): - """운영 설정""" - class Config: - """BaseSettings 설정""" - env_prefix: str = "PROD_" - -class FactoryConfig: - """설정 로드""" - def __init__(self, env_state: Optional[str]): - self.env_state = env_state - - def __call__(self): - if self.env_state == "local": - return LocalConfig() - - if self.env_state == "dev": - return DevConfig() - - elif self.env_state == "prod": - return ProdConfig() - - -cnf = FactoryConfig(GlobalConfig().ENV_STATE)() diff --git a/app/database.py b/app/database.py deleted file mode 100644 index e442d04..0000000 --- a/app/database.py +++ /dev/null @@ -1,8 +0,0 @@ -from sqlalchemy import create_engine -from config import cnf -from sqlalchemy.orm import sessionmaker - -SQLALCHEMY_DATABASE_URL = f"postgresql://{cnf.POSTGRESQL_USER}:{cnf.POSTGRESQL_PASSWORD}@{cnf.POSTGRESQL_HOST}/{cnf.POSTGRESQL_DB}" -engine = create_engine(SQLALCHEMY_DATABASE_URL, echo=True) - -SessionLocal = sessionmaker(bind=engine, autocommit=False, autoflush=False) diff --git a/app/db_session.py b/app/db_session.py deleted file mode 100644 index 607fd36..0000000 --- a/app/db_session.py +++ /dev/null @@ -1,10 +0,0 @@ -from database import SessionLocal - - -def get_db(): - '''DB 세션관리''' - db = SessionLocal() - try: - yield db - finally: - db.close() diff --git a/app/documents/shcema.md b/app/documents/shcema.md deleted file mode 100644 index 1e0bf65..0000000 --- a/app/documents/shcema.md +++ /dev/null @@ -1,27 +0,0 @@ -# 개요 -* DB 초기화 스크립트 - -# 스크립트 -```sql - -CREATE TABLE users ( - id serial PRIMARY KEY, - name VARCHAR (50) UNIQUE NOT NULL, - created_at TIMESTAMP NOT NULL, - updated_at TIMESTAMP NOT NULL -); - -CREATE TABLE projects ( - id serial PRIMARY KEY, - user_id integer NOT NULL, - name VARCHAR ( 50 ) UNIQUE NOT NULL, - description VARCHAR ( 255 ), - created_at TIMESTAMP NOT NULL, - updated_at TIMESTAMP NOT NULL, - CONSTRAINT fk_user_id FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE ON UPDATE CASCADE -); - -INSERT - INTO users (name, created_at, updated_at) - VALUES ('test-user', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); -``` \ No newline at end of file diff --git a/app/domain/__init__.py b/app/domain/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/app/domain/project/__init__.py b/app/domain/project/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/app/domain/project/crud.py b/app/domain/project/crud.py deleted file mode 100644 index 2465e94..0000000 --- a/app/domain/project/crud.py +++ /dev/null @@ -1,73 +0,0 @@ -from sqlalchemy.orm import Session -from domain.project.schemas import ( - RequestCreateProject, - RequestDeleteProject, - RequestGetProject -) -from sqlalchemy import exc, text -from logger import log - - -def createProject(request: RequestCreateProject, db: Session): - """프로젝트 생성""" - try: - statement = text(""" - INSERT INTO - projects (name, user_id, created_at, updated_at) - VALUES(:name, :user_id ,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP) - """) - db.execute(statement, { - "name": request.name, - "user_id": request.user_id - }) - db.commit() - log.info(f"create project success: {request.name}") - except exc.IntegrityError as e: - db.rollback() - raise RuntimeError(e) - except Exception as e: - log.error(f"[-] other error: {e}") - db.rollback() - raise RuntimeError(e) - -def deleteProject(request: RequestDeleteProject, db: Session): - """프로젝트 삭제""" - try: - statement = text(""" - DELETE FROM projects where user_id=(:user_id) and name=(:name) - """) - db.execute(statement, { - "user_id": request.user_id, - "name": request.name - }) - db.commit() - log.info(f"delete project success: {request.name}") - except exc.IntegrityError as e: - log.error(f"[-] {e}이 project table에 없습니다.: {e}") - db.rollback() - raise RuntimeError(e) - except Exception as e: - db.rollback() - raise RuntimeError(e) - -def getProject(request: RequestGetProject, db: Session): - """프로젝트 조회""" - try: - statement = text(""" - SELECT id, name, description - from projects - where user_id=(:user_id) and name=(:name) - """) - row = db.execute(statement, { - "user_id": request.user_id, - "name": request.name - }) - log.info(f"get project success: {request.name}") - except exc.IntegrityError as e: - log.error(f"[-] {e}이 project table에 없습니다.: {e}") - raise RuntimeError(e) - except Exception as e: - log.error(f"[-] other error: {e}") - raise RuntimeError(e) - else: - return row diff --git a/app/domain/project/schemas.py b/app/domain/project/schemas.py deleted file mode 100644 index a418e81..0000000 --- a/app/domain/project/schemas.py +++ /dev/null @@ -1,33 +0,0 @@ -from pydantic import BaseModel - - -class RequestGetProject(BaseModel): - """프로젝트 조회 요청""" - user_id: int = 1 # 테스트 user_id - name: str - -class ResponseGetProject(BaseModel): - """프로젝트 조회 응답""" - id: str - name: str - error_detail: str - -class RequestCreateProject(BaseModel): - """프로젝트 생성 요청""" - user_id: int = 1 # 테스트 user_id - name: str - -class ResponseCreateProject(BaseModel): - """프로젝트 생성 응답""" - name: str - error_detail: str - -class RequestDeleteProject(BaseModel): - """프로젝트 삭제 요청""" - user_id: int = 1 # 테스트 user_id - name: str - -class ResponseDeleteProject(BaseModel): - """프로젝트 삭제 응답""" - name: str - error_detail: str \ No newline at end of file diff --git a/app/domain/project/service.py b/app/domain/project/service.py deleted file mode 100644 index b99e740..0000000 --- a/app/domain/project/service.py +++ /dev/null @@ -1,158 +0,0 @@ -from fastapi import status -from kubernetes.client.exceptions import ApiException -from domain.project.schemas import ( - RequestCreateProject, - ResponseCreateProject, - RequestDeleteProject, - ResponseDeleteProject, - ResponseGetProject, - RequestGetProject -) -import domain.project.crud as project_crud -from logger import log -from module.k8s import JCPK8S - - -class ProjectManager: - def createProject(self, request: RequestCreateProject, db) -> (int, ResponseCreateProject): - """프로젝트 생성""" - k8s = JCPK8S() - - if not self.createProjectValid(namespace=request.name): - return False - - # 쿠버네티스 namespace 생성 - try: - k8s.createNamespace(namespace=request.name) - except ApiException as e: - if e.status == 409: - log.error(f"[프로젝트 생성 오류] k8s namespace {request.name}이 이미 존재합니다") - return status.HTTP_409_CONFLICT, \ - ResponseCreateProject( - name=request.name, - error_detail=f"{request.name}이 이미 존재합니다." - ) - - log.error(f"[프로젝트 생성 오류] k8s namespace {request.name} 기타 생성오류: {e.status}. {e}") - return status.HTTP_500_INTERNAL_SERVER_ERROR, \ - ResponseCreateProject( - name=request.name, - error_detail=str(e) - ) - - # github repo 생성 - # createRepo(repo_name=request.name, token=request.github_token) - - # db 업데이트 - try: - project_crud.createProject(request=request, db=db) - except Exception as e: - db_error_code = e.args[0].orig.pgcode - if db_error_code == "23503": - log.error(f"[프로젝트 생성 오류] 데이터베이스 오류: user_id가 존재하지 않음 {db_error_code}->{e}") - else: - log.error(f"[프로젝트 생성 오류] 데이터베이스 오류: 기타에러 {e.args[0].code}->{e}") - - # 생성했던 쿠버네티스 네임스페이스 삭제 - try: - k8s.deleteNamespace(namespace=request.name) - except Exception: - pass - - return status.HTTP_500_INTERNAL_SERVER_ERROR, \ - ResponseCreateProject( - name=request.name, - error_detail="프로젝트 생성을 실패했습니다." - ) - - return status.HTTP_201_CREATED, \ - ResponseCreateProject( - name=request.name, - error_detail="" - ) - - def deleteProject(self, request: RequestDeleteProject, db) -> (int, ResponseDeleteProject): - """프로젝트 삭제""" - k8s = JCPK8S() - - # 쿠버네티스 네임스페이스 삭제 - try: - k8s.deleteNamespace(namespace=request.name) - except ApiException as e: - pass - - # DB행 삭제 - try: - project_crud.deleteProject(request=request, db=db) - except Exception as e: - pass - - return status.HTTP_200_OK, \ - ResponseDeleteProject( - name=request.name, - error_detail="" - ) - - def getProject(self, request: RequestGetProject, db) -> (int, ResponseGetProject): - """프로젝트 조회""" - - try: - result = project_crud.getProject(requset=request, db=db) - except Exception as e: - log.error(f"[프로젝트 조회 오류] {request.name} 조회 실패 -> 데이터베이스 오류: {e}") - return status.HTTP_500_INTERNAL_SERVER_ERROR, \ - ResponseGetProject( - id=-1, - name=request.name, - error_detail="프로젝트 조회를 실패했습니다." - ) - - if result.rowcount != 1: - log.error(f"[프로젝트 조회 실패] 단일건 조회({request.name})지만 2개 이상 조회 되었습니다") - return status.HTTP_500_INTERNAL_SERVER_ERROR, \ - ResponseGetProject( - id=-1, - name=request.name, - error_detail="프로젝트 조회를 실패했습니다" - ) - - searched_project = {} - for row in result: - searched_project = dict(row) - - return status.HTTP_200_OK, \ - ResponseGetProject( - id=searched_project["id"], - name=searched_project["name"], - error_detail="" - ) - - def createProjectValid(self, namespace: str) -> bool: - """ - 프로젝트 생성 유효성 검사 - ① k8s namespace 확인 - - :params - namespace: 생성할 쿠버네티스 namespace - - :return - bool - True: 유효성 검사 성공 - False: 유효성 검사 실패 - """ - - return self.isExistK8sNamespace(namespace=namespace) - - def isExistK8sNamespace(self, namespace) -> bool: - """ - 쿠버네티스 namespace 있는지 확인 - - :params - namespace: 생성할 쿠버네티스 namespace - - :return - bool - True: namespace 존재 - False: namespace 미존재 - """ - return True diff --git a/app/log.yaml b/app/log.yaml deleted file mode 100644 index 4dba71e..0000000 --- a/app/log.yaml +++ /dev/null @@ -1,19 +0,0 @@ -# reference: https://docs.python.org/ko/3/howto/logging.html -version: 1 -formatters: - simple: - format: '%(asctime)s - %(name)s - %(levelname)s - %(message)s' -handlers: - console: - class: logging.StreamHandler - level: DEBUG - formatter: simple - stream: ext://sys.stdout -loggers: - simple: - level: DEBUG - handlers: [console] - propagate: no -root: - level: DEBUG - handlers: [console] \ No newline at end of file diff --git a/app/logger.py b/app/logger.py deleted file mode 100644 index 012df62..0000000 --- a/app/logger.py +++ /dev/null @@ -1,8 +0,0 @@ -import logging -import yaml - -with open('log.yaml', 'r') as f: - config = yaml.safe_load(f) - -logging.config.dictConfig(config) -log = logging.getLogger('simple') diff --git a/app/main.py b/app/main.py deleted file mode 100644 index aed815e..0000000 --- a/app/main.py +++ /dev/null @@ -1,15 +0,0 @@ -from fastapi import FastAPI -from config import cnf -from api.project import router as project_router -from logger import log - - -app = FastAPI() -app.include_router(project_router) - -@app.get("/") -def read_root(): - log.info(cnf.POSTGRESQL_HOST) - log.info(cnf.POSTGRESQL_USER) - log.info(cnf.POSTGRESQL_PASSWORD) - return {"Hello": "World"} diff --git a/app/module/__init__.py b/app/module/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/app/module/k8s.py b/app/module/k8s.py deleted file mode 100644 index 3a862a6..0000000 --- a/app/module/k8s.py +++ /dev/null @@ -1,32 +0,0 @@ -from kubernetes import client, config -from config import cnf - - -class JCPK8S: - def __init__(self): - if cnf.ENV_STATE == "local": - config.load_kube_config() - - self.v1 = client.CoreV1Api() - - def createNamespace(self, namespace) -> None: - """ - namespace 생성 - - :param - namespace: namespace 이름 - """ - ns = client.V1Namespace() - ns.metadata = client.V1ObjectMeta(name=namespace) - self.v1.create_namespace(ns) - - def deleteNamespace(self, namespace) -> None: - """ - namespace 삭제 - - :param - namespace: namespace 이름 - :return: - """ - ns = client.V1Namespace() - self.v1.delete_namespace(namespace) diff --git a/app/requirements.txt b/app/requirements.txt deleted file mode 100644 index 6207959..0000000 --- a/app/requirements.txt +++ /dev/null @@ -1,45 +0,0 @@ -anyio==3.5.0 -asgiref==3.5.0 -cachetools==5.1.0 -certifi==2021.10.8 -cffi==1.15.0 -charset-normalizer==2.0.12 -click==8.1.2 -colorama==0.4.4 -Deprecated==1.2.13 -fastapi==0.75.2 -flake8==4.0.1 -google-auth==2.6.6 -greenlet==1.1.2 -h11==0.13.0 -idna==3.3 -kubernetes==23.6.0 -mccabe==0.6.1 -oauthlib==3.2.0 -psycopg2-binary==2.9.3 -pyaml==21.10.1 -pyasn1==0.4.8 -pyasn1-modules==0.2.8 -pycodestyle==2.8.0 -pycparser==2.21 -pydantic==1.9.0 -pyflakes==2.4.0 -PyGithub==1.55 -PyJWT==2.4.0 -PyNaCl==1.5.0 -python-dateutil==2.8.2 -python-dotenv==0.20.0 -pytz==2022.1 -PyYAML==6.0 -requests==2.27.1 -requests-oauthlib==1.3.1 -rsa==4.8 -six==1.16.0 -sniffio==1.2.0 -SQLAlchemy==1.4.36 -starlette==0.17.1 -typing_extensions==4.2.0 -urllib3==1.26.9 -uvicorn==0.17.6 -websocket-client==1.3.2 -wrapt==1.14.1 diff --git a/base/deployment.yaml b/base/deployment.yaml new file mode 100644 index 0000000..3d5eec0 --- /dev/null +++ b/base/deployment.yaml @@ -0,0 +1,25 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: backend-python +spec: + revisionHistoryLimit: 3 + selector: + matchLabels: + app: backend-python + template: + metadata: + labels: + app: backend-python + spec: + nodeSelector: + role: infra + containers: + - name: core + image: core-image + resources: + limits: + memory: "512Mi" + cpu: "0.5" + ports: + - containerPort: 80 \ No newline at end of file diff --git a/base/ingress.yaml b/base/ingress.yaml new file mode 100644 index 0000000..e750c7c --- /dev/null +++ b/base/ingress.yaml @@ -0,0 +1,17 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: backend-python +spec: + ingressClassName: nginx + rules: + - host: core.choilab.xyz + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: backend-python + port: + number: 80 \ No newline at end of file diff --git a/base/kustomization.yaml b/base/kustomization.yaml new file mode 100644 index 0000000..cdc82fe --- /dev/null +++ b/base/kustomization.yaml @@ -0,0 +1,5 @@ +resources: +- deployment.yaml +- service.yaml +- ingress.yaml +namespace: jcp \ No newline at end of file diff --git a/base/service.yaml b/base/service.yaml new file mode 100644 index 0000000..c66fdd0 --- /dev/null +++ b/base/service.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: Service +metadata: + name: backend-python +spec: + selector: + app: backend-python + ports: + - port: 80 + targetPort: 80 \ No newline at end of file diff --git a/dev/kustomization.yaml b/dev/kustomization.yaml new file mode 100644 index 0000000..7433781 --- /dev/null +++ b/dev/kustomization.yaml @@ -0,0 +1,24 @@ +bases: + - ../base + +patches: + - target: + kind: Ingress + name: backend-python + patch: |- + - op: replace + path: /spec/rules/0/host + value: dev-core.choilab.xyz + +namePrefix: dev- + +configurations: + - nameReference.yaml + +commonLabels: + app: dev-backend-python + +images: + - name: core-image + newName: 192.168.0.66:31831/core + newTag: dev2.1.1 diff --git a/dev/nameReference.yaml b/dev/nameReference.yaml new file mode 100644 index 0000000..9517332 --- /dev/null +++ b/dev/nameReference.yaml @@ -0,0 +1,6 @@ +nameReference: +- kind: Service + version: v1 + fieldSpecs: + - path: spec/rules/http/paths/backend/serviceName + kind: Ingress \ No newline at end of file From 8ee0e999ac693e69dd4c2151e954a17c8a0f57c0 Mon Sep 17 00:00:00 2001 From: choisungwook Date: Wed, 8 Jun 2022 21:14:02 +0900 Subject: [PATCH 02/21] =?UTF-8?q?ingress=20=EC=A3=BC=EC=86=8C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dev/kustomization.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/kustomization.yaml b/dev/kustomization.yaml index 7433781..97d6f56 100644 --- a/dev/kustomization.yaml +++ b/dev/kustomization.yaml @@ -8,7 +8,7 @@ patches: patch: |- - op: replace path: /spec/rules/0/host - value: dev-core.choilab.xyz + value: dev-backend.choilab.xyz namePrefix: dev- From 1fa607b964ac1bb20bddb48782b43035215b8d0c Mon Sep 17 00:00:00 2001 From: jenkins Date: Wed, 8 Jun 2022 21:37:12 +0900 Subject: [PATCH 03/21] change image:tag --- dev/kustomization.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dev/kustomization.yaml b/dev/kustomization.yaml index 97d6f56..0f72c33 100644 --- a/dev/kustomization.yaml +++ b/dev/kustomization.yaml @@ -20,5 +20,6 @@ commonLabels: images: - name: core-image - newName: 192.168.0.66:31831/core - newTag: dev2.1.1 + newName: 192.168.0.66:31831/python-backend + newTag: dev0.1.3 + From e4f8e6071ca97c7d8f438518adb4ef5faca3709b Mon Sep 17 00:00:00 2001 From: jenkins Date: Wed, 8 Jun 2022 21:55:54 +0900 Subject: [PATCH 04/21] change image:tag --- dev/kustomization.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/kustomization.yaml b/dev/kustomization.yaml index 0f72c33..e72e3cd 100644 --- a/dev/kustomization.yaml +++ b/dev/kustomization.yaml @@ -21,5 +21,5 @@ commonLabels: images: - name: core-image newName: 192.168.0.66:31831/python-backend - newTag: dev0.1.3 + newTag: dev0.1.4 From 32b61c0069e784707d84070d3adcfcfcde807dad Mon Sep 17 00:00:00 2001 From: jenkins Date: Wed, 8 Jun 2022 21:58:16 +0900 Subject: [PATCH 05/21] change image:tag --- dev/kustomization.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/kustomization.yaml b/dev/kustomization.yaml index e72e3cd..2313c8d 100644 --- a/dev/kustomization.yaml +++ b/dev/kustomization.yaml @@ -21,5 +21,5 @@ commonLabels: images: - name: core-image newName: 192.168.0.66:31831/python-backend - newTag: dev0.1.4 + newTag: dev0.1.5 From 13c9551f6020c5788ffb62defda5f9934656c6be Mon Sep 17 00:00:00 2001 From: jenkins Date: Wed, 8 Jun 2022 22:05:33 +0900 Subject: [PATCH 06/21] change image:tag --- dev/kustomization.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/kustomization.yaml b/dev/kustomization.yaml index 2313c8d..e1ea66d 100644 --- a/dev/kustomization.yaml +++ b/dev/kustomization.yaml @@ -21,5 +21,5 @@ commonLabels: images: - name: core-image newName: 192.168.0.66:31831/python-backend - newTag: dev0.1.5 + newTag: dev0.1.6 From 3b3a7ab5484032779b72079a22e0adc337b6ec8d Mon Sep 17 00:00:00 2001 From: jenkins Date: Wed, 8 Jun 2022 22:22:31 +0900 Subject: [PATCH 07/21] change image:tag --- dev/kustomization.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/kustomization.yaml b/dev/kustomization.yaml index e1ea66d..327fb19 100644 --- a/dev/kustomization.yaml +++ b/dev/kustomization.yaml @@ -21,5 +21,5 @@ commonLabels: images: - name: core-image newName: 192.168.0.66:31831/python-backend - newTag: dev0.1.6 + newTag: dev0.1.7 From 724683efe0eb2bbae4f0a2dafdc1ed9411fd0b0a Mon Sep 17 00:00:00 2001 From: choisungwook Date: Wed, 8 Jun 2022 22:55:07 +0900 Subject: [PATCH 08/21] =?UTF-8?q?serviceaccount=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base/deployment.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/base/deployment.yaml b/base/deployment.yaml index 3d5eec0..a5fde55 100644 --- a/base/deployment.yaml +++ b/base/deployment.yaml @@ -12,6 +12,7 @@ spec: labels: app: backend-python spec: + serviceAccount: "backend" nodeSelector: role: infra containers: From fcdc76269205e9c45963515c99edd12c7a6b7070 Mon Sep 17 00:00:00 2001 From: jenkins Date: Wed, 8 Jun 2022 23:02:23 +0900 Subject: [PATCH 09/21] change image:tag --- dev/kustomization.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/kustomization.yaml b/dev/kustomization.yaml index 327fb19..ea506b0 100644 --- a/dev/kustomization.yaml +++ b/dev/kustomization.yaml @@ -21,5 +21,5 @@ commonLabels: images: - name: core-image newName: 192.168.0.66:31831/python-backend - newTag: dev0.1.7 + newTag: dev0.1.8 From 8b2e0262cdee60f0ec9617eaa7500214fa480a21 Mon Sep 17 00:00:00 2001 From: jenkins Date: Wed, 8 Jun 2022 23:07:52 +0900 Subject: [PATCH 10/21] change image:tag --- dev/kustomization.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/kustomization.yaml b/dev/kustomization.yaml index ea506b0..a74c7a2 100644 --- a/dev/kustomization.yaml +++ b/dev/kustomization.yaml @@ -21,5 +21,5 @@ commonLabels: images: - name: core-image newName: 192.168.0.66:31831/python-backend - newTag: dev0.1.8 + newTag: dev0.1.9 From 990f2cf996723db58f3c9287bedbcf5714f25155 Mon Sep 17 00:00:00 2001 From: jenkins Date: Thu, 16 Jun 2022 21:03:48 +0900 Subject: [PATCH 11/21] change image:tag From 2184a858861263d64f65f9f47295cae2e62241fd Mon Sep 17 00:00:00 2001 From: jenkins Date: Thu, 16 Jun 2022 23:44:58 +0900 Subject: [PATCH 12/21] change image:tag --- dev/kustomization.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/dev/kustomization.yaml b/dev/kustomization.yaml index a74c7a2..6d9f82b 100644 --- a/dev/kustomization.yaml +++ b/dev/kustomization.yaml @@ -1,6 +1,5 @@ bases: - ../base - patches: - target: kind: Ingress @@ -9,17 +8,12 @@ patches: - op: replace path: /spec/rules/0/host value: dev-backend.choilab.xyz - namePrefix: dev- - configurations: - nameReference.yaml - commonLabels: app: dev-backend-python - images: - name: core-image newName: 192.168.0.66:31831/python-backend newTag: dev0.1.9 - From d30ad922c24e88ddd77b60b750ba2e5854b61410 Mon Sep 17 00:00:00 2001 From: jenkins Date: Thu, 16 Jun 2022 23:49:50 +0900 Subject: [PATCH 13/21] change image:tag --- dev/kustomization.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/dev/kustomization.yaml b/dev/kustomization.yaml index 6d9f82b..b0a2291 100644 --- a/dev/kustomization.yaml +++ b/dev/kustomization.yaml @@ -17,3 +17,4 @@ images: - name: core-image newName: 192.168.0.66:31831/python-backend newTag: dev0.1.9 + newTage: 20 From a9ae5fc51b1bc0cd2ad116b213e23ee22f0fea24 Mon Sep 17 00:00:00 2001 From: jenkins_bot Date: Sat, 18 Jun 2022 18:58:42 +0900 Subject: [PATCH 14/21] change image:tag --- dev/kustomization.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/kustomization.yaml b/dev/kustomization.yaml index b0a2291..66853ba 100644 --- a/dev/kustomization.yaml +++ b/dev/kustomization.yaml @@ -17,4 +17,4 @@ images: - name: core-image newName: 192.168.0.66:31831/python-backend newTag: dev0.1.9 - newTage: 20 + newTage: 21 From ca7639520ae54465deef052090ff30455a1390c9 Mon Sep 17 00:00:00 2001 From: jenkins_bot Date: Sat, 18 Jun 2022 19:01:49 +0900 Subject: [PATCH 15/21] change image:tag --- dev/kustomization.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/kustomization.yaml b/dev/kustomization.yaml index 66853ba..4764652 100644 --- a/dev/kustomization.yaml +++ b/dev/kustomization.yaml @@ -16,5 +16,5 @@ commonLabels: images: - name: core-image newName: 192.168.0.66:31831/python-backend - newTag: dev0.1.9 + newTag: 22 newTage: 21 From c701d892c7945bd3c1bc5ef4ff0b1b58d50a9ce1 Mon Sep 17 00:00:00 2001 From: choisungwook Date: Sat, 18 Jun 2022 19:05:21 +0900 Subject: [PATCH 16/21] =?UTF-8?q?=EC=82=AC=EC=9A=A9=ED=95=98=EC=A7=80=20?= =?UTF-8?q?=EC=95=8A=EB=8A=94=20=EB=9D=BC=EC=9D=B8=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dev/kustomization.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/dev/kustomization.yaml b/dev/kustomization.yaml index 4764652..7a5f2cd 100644 --- a/dev/kustomization.yaml +++ b/dev/kustomization.yaml @@ -17,4 +17,3 @@ images: - name: core-image newName: 192.168.0.66:31831/python-backend newTag: 22 - newTage: 21 From 66eef721082ea1d17ce700bdec0460483fc7feba Mon Sep 17 00:00:00 2001 From: choisungwook Date: Sat, 18 Jun 2022 19:06:36 +0900 Subject: [PATCH 17/21] =?UTF-8?q?newtag=20=ED=83=80=EC=9E=85=20=EC=88=98?= =?UTF-8?q?=EC=A0=95(int=20->=20str)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dev/kustomization.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/kustomization.yaml b/dev/kustomization.yaml index 7a5f2cd..e625d0f 100644 --- a/dev/kustomization.yaml +++ b/dev/kustomization.yaml @@ -16,4 +16,4 @@ commonLabels: images: - name: core-image newName: 192.168.0.66:31831/python-backend - newTag: 22 + newTag: "22" From 2be23acf192a380d0509a984a9103422f38af5e5 Mon Sep 17 00:00:00 2001 From: jenkins_bot Date: Sun, 19 Jun 2022 14:44:43 +0900 Subject: [PATCH 18/21] change image:tag --- dev/kustomization.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/kustomization.yaml b/dev/kustomization.yaml index e625d0f..9292853 100644 --- a/dev/kustomization.yaml +++ b/dev/kustomization.yaml @@ -16,4 +16,4 @@ commonLabels: images: - name: core-image newName: 192.168.0.66:31831/python-backend - newTag: "22" + newTag: "23" From 63b06dca276b148e9c66f3aa3bc5e66fbec3a634 Mon Sep 17 00:00:00 2001 From: jenkins_bot Date: Sun, 19 Jun 2022 14:50:53 +0900 Subject: [PATCH 19/21] change image:tag --- dev/kustomization.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/kustomization.yaml b/dev/kustomization.yaml index 9292853..bc38cf2 100644 --- a/dev/kustomization.yaml +++ b/dev/kustomization.yaml @@ -16,4 +16,4 @@ commonLabels: images: - name: core-image newName: 192.168.0.66:31831/python-backend - newTag: "23" + newTag: "24" From 7a55b862003c9b85e7380d2b98dfd502441325ba Mon Sep 17 00:00:00 2001 From: jenkins_bot Date: Sun, 19 Jun 2022 15:14:49 +0900 Subject: [PATCH 20/21] change image:tag --- dev/kustomization.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/kustomization.yaml b/dev/kustomization.yaml index bc38cf2..2b70a6c 100644 --- a/dev/kustomization.yaml +++ b/dev/kustomization.yaml @@ -16,4 +16,4 @@ commonLabels: images: - name: core-image newName: 192.168.0.66:31831/python-backend - newTag: "24" + newTag: "25" From ed410e41628bb56911460bf71493d2e8a70863da Mon Sep 17 00:00:00 2001 From: jenkins_bot Date: Sun, 26 Jun 2022 15:48:44 +0900 Subject: [PATCH 21/21] change image:tag --- dev/kustomization.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/kustomization.yaml b/dev/kustomization.yaml index 2b70a6c..7686eb5 100644 --- a/dev/kustomization.yaml +++ b/dev/kustomization.yaml @@ -16,4 +16,4 @@ commonLabels: images: - name: core-image newName: 192.168.0.66:31831/python-backend - newTag: "25" + newTag: "26"