feat: Добавлена k8s поддержка и Dockerfile
This commit is contained in:
parent
7e6320aa9e
commit
75bb1bc612
3
API/.gitignore
vendored
Normal file
3
API/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
k8s/helm/teamfolio-api/templates/secrets.yaml
|
||||||
|
.venv
|
||||||
|
*.pyc
|
||||||
18
API/app/Dockerfile
Normal file
18
API/app/Dockerfile
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
FROM python:3.10-slim
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
libpq-dev \
|
||||||
|
libmagic1 \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY req.txt .
|
||||||
|
|
||||||
|
RUN pip install --no-cache-dir -r req.txt
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
EXPOSE 8000
|
||||||
|
|
||||||
|
CMD ["uvicorn", "app.main:app", "--host=0.0.0.0"]
|
||||||
@ -4,7 +4,7 @@ from typing import Optional, Any, Coroutine
|
|||||||
|
|
||||||
import aiofiles
|
import aiofiles
|
||||||
from fastapi import HTTPException, status, UploadFile
|
from fastapi import HTTPException, status, UploadFile
|
||||||
from magic import magic
|
import magic
|
||||||
from sqlalchemy.ext.asyncio import AsyncSession
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
from starlette.responses import FileResponse
|
from starlette.responses import FileResponse
|
||||||
from werkzeug.utils import secure_filename
|
from werkzeug.utils import secure_filename
|
||||||
|
|||||||
5
API/k8s/helm/teamfolio-api/Chart.yaml
Normal file
5
API/k8s/helm/teamfolio-api/Chart.yaml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
apiVersion: v2
|
||||||
|
name: teamfolio-api-app
|
||||||
|
description: Teamfolio API project
|
||||||
|
version: 0.1.0
|
||||||
|
appVersion: "1.0"
|
||||||
35
API/k8s/helm/teamfolio-api/templates/deployment.yaml
Normal file
35
API/k8s/helm/teamfolio-api/templates/deployment.yaml
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: {{ .Chart.Name }}
|
||||||
|
spec:
|
||||||
|
replicas: {{ .Values.replicaCount }}
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: {{ .Chart.Name }}
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: {{ .Chart.Name }}
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: {{ .Chart.Name }}
|
||||||
|
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
||||||
|
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||||
|
ports:
|
||||||
|
- containerPort: {{ .Values.service.port }}
|
||||||
|
env:
|
||||||
|
- name: SECRET_KEY
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: teamfolio-api-secret
|
||||||
|
key: SECRET_KEY
|
||||||
|
volumeMounts:
|
||||||
|
- name: uploads-volume
|
||||||
|
mountPath: {{ .Values.persistence.uploads.containerPath }}
|
||||||
|
resources:
|
||||||
|
{{- toYaml .Values.resources | nindent 12 }}
|
||||||
|
volumes:
|
||||||
|
- name: uploads-volume
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: "{{ .Release.Name }}-uploads-pvc"
|
||||||
23
API/k8s/helm/teamfolio-api/templates/ingress.yaml
Normal file
23
API/k8s/helm/teamfolio-api/templates/ingress.yaml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
apiVersion: networking.k8s.io/v1
|
||||||
|
kind: Ingress
|
||||||
|
metadata:
|
||||||
|
name: teamfolio-api-ingress
|
||||||
|
annotations:
|
||||||
|
cert-manager.io/cluster-issuer: lets-encrypt
|
||||||
|
spec:
|
||||||
|
tls:
|
||||||
|
- hosts:
|
||||||
|
- {{ .Values.ingress.domain }}
|
||||||
|
secretName: {{ .Values.ingress.secretTLSName }}
|
||||||
|
ingressClassName: public
|
||||||
|
rules:
|
||||||
|
- host: {{ .Values.ingress.domain }}
|
||||||
|
http:
|
||||||
|
paths:
|
||||||
|
- path: {{ .Values.ingress.path }}
|
||||||
|
pathType: {{ .Values.ingress.pathType }}
|
||||||
|
backend:
|
||||||
|
service:
|
||||||
|
name: {{ .Chart.Name }}-service
|
||||||
|
port:
|
||||||
|
number: {{ .Values.service.port }}
|
||||||
29
API/k8s/helm/teamfolio-api/templates/pvc.yaml
Normal file
29
API/k8s/helm/teamfolio-api/templates/pvc.yaml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{{- if .Values.persistence.uploads.enabled }}
|
||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolume
|
||||||
|
metadata:
|
||||||
|
name: {{ .Release.Name }}-uploads-pv
|
||||||
|
spec:
|
||||||
|
capacity:
|
||||||
|
storage: {{ .Values.persistence.uploads.size }}
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
storageClassName: microk8s-hostpath
|
||||||
|
hostPath:
|
||||||
|
path: {{ .Values.persistence.path }}/uploads
|
||||||
|
type: DirectoryOrCreate
|
||||||
|
persistentVolumeReclaimPolicy: Retain
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
metadata:
|
||||||
|
name: {{ .Release.Name }}-uploads-pvc
|
||||||
|
spec:
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
storageClassName: microk8s-hostpath
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: {{ .Values.persistence.uploads.size }}
|
||||||
|
volumeName: {{ .Release.Name }}-uploads-pv
|
||||||
|
{{- end }}
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
name: teamfolio-api-secret
|
||||||
|
type: Opaque
|
||||||
|
data:
|
||||||
|
SECRET_KEY:
|
||||||
|
DATABASE_URL:
|
||||||
11
API/k8s/helm/teamfolio-api/templates/service.yaml
Normal file
11
API/k8s/helm/teamfolio-api/templates/service.yaml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: {{ .Chart.Name }}-service
|
||||||
|
spec:
|
||||||
|
type: {{ .Values.service.type }}
|
||||||
|
ports:
|
||||||
|
- port: {{ .Values.service.port }}
|
||||||
|
targetPort: {{ .Values.service.port }}
|
||||||
|
selector:
|
||||||
|
app: {{ .Chart.Name }}
|
||||||
30
API/k8s/helm/teamfolio-api/values.yaml
Normal file
30
API/k8s/helm/teamfolio-api/values.yaml
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
replicaCount: 1
|
||||||
|
|
||||||
|
image:
|
||||||
|
repository: archi341/teamfolio-api
|
||||||
|
tag: latest
|
||||||
|
pullPolicy: Always
|
||||||
|
|
||||||
|
service:
|
||||||
|
type: ClusterIP
|
||||||
|
port: 8000
|
||||||
|
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
memory: 512Mi
|
||||||
|
cpu: 500m
|
||||||
|
|
||||||
|
persistence:
|
||||||
|
path: /mnt/k8s_storage/teamfolio-api
|
||||||
|
uploads:
|
||||||
|
enabled: true
|
||||||
|
size: 7Gi
|
||||||
|
containerPath: /app/uploads
|
||||||
|
|
||||||
|
ingress:
|
||||||
|
secretTLSName: teamfolio-api-tls-secret
|
||||||
|
|
||||||
|
domain: api.numerum.team
|
||||||
|
|
||||||
|
path: /
|
||||||
|
pathType: Prefix
|
||||||
BIN
API/req.txt
BIN
API/req.txt
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user