feat: dodaj Kubernetes manifeste
This commit is contained in:
68
manifests/app/deployment.yaml
Normal file
68
manifests/app/deployment.yaml
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
|
||||||
|
metadata:
|
||||||
|
name: fastapi-api
|
||||||
|
namespace: student-dinkoglc
|
||||||
|
|
||||||
|
annotations:
|
||||||
|
argocd.argoproj.io/sync-wave: "1"
|
||||||
|
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: fastapi-api
|
||||||
|
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: fastapi-api
|
||||||
|
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: fastapi-api
|
||||||
|
image: vasic/fastapi-todo-api:1.0
|
||||||
|
|
||||||
|
ports:
|
||||||
|
- containerPort: 8000
|
||||||
|
|
||||||
|
env:
|
||||||
|
- name: DATABASE_HOST
|
||||||
|
valueFrom:
|
||||||
|
configMapKeyRef:
|
||||||
|
name: fastapi-config
|
||||||
|
key: DATABASE_HOST
|
||||||
|
|
||||||
|
- name: DATABASE_PORT
|
||||||
|
valueFrom:
|
||||||
|
configMapKeyRef:
|
||||||
|
name: fastapi-config
|
||||||
|
key: DATABASE_PORT
|
||||||
|
|
||||||
|
- name: POSTGRES_USER
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: postgres-secret
|
||||||
|
key: POSTGRES_USER
|
||||||
|
|
||||||
|
- name: POSTGRES_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: postgres-secret
|
||||||
|
key: POSTGRES_PASSWORD
|
||||||
|
|
||||||
|
- name: POSTGRES_DB
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: postgres-secret
|
||||||
|
key: POSTGRES_DB
|
||||||
|
|
||||||
|
readinessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /health
|
||||||
|
port: 8000
|
||||||
|
|
||||||
|
initialDelaySeconds: 15
|
||||||
|
periodSeconds: 5
|
||||||
32
manifests/app/ingress.yaml
Normal file
32
manifests/app/ingress.yaml
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
apiVersion: networking.k8s.io/v1
|
||||||
|
kind: Ingress
|
||||||
|
|
||||||
|
metadata:
|
||||||
|
name: fastapi-api-ingress
|
||||||
|
namespace: student-dinkoglc
|
||||||
|
|
||||||
|
annotations:
|
||||||
|
traefik.ingress.kubernetes.io/router.entrypoints: websecure
|
||||||
|
cert-manager.io/cluster-issuer: letsencrypt-prod
|
||||||
|
|
||||||
|
spec:
|
||||||
|
rules:
|
||||||
|
- host: dinkoglc.fpmoz.sum.ba
|
||||||
|
|
||||||
|
http:
|
||||||
|
paths:
|
||||||
|
- path: /
|
||||||
|
pathType: Prefix
|
||||||
|
|
||||||
|
backend:
|
||||||
|
service:
|
||||||
|
name: fastapi-api-service
|
||||||
|
|
||||||
|
port:
|
||||||
|
number: 80
|
||||||
|
|
||||||
|
tls:
|
||||||
|
- hosts:
|
||||||
|
- dinkoglc.fpmoz.sum.ba
|
||||||
|
|
||||||
|
secretName: fastapi-api-tls
|
||||||
16
manifests/app/service.yaml
Normal file
16
manifests/app/service.yaml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
|
||||||
|
metadata:
|
||||||
|
name: fastapi-api-service
|
||||||
|
namespace: student-dinkoglc
|
||||||
|
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
app: fastapi-api
|
||||||
|
|
||||||
|
ports:
|
||||||
|
- port: 80
|
||||||
|
targetPort: 8000
|
||||||
|
|
||||||
|
type: ClusterIP
|
||||||
11
manifests/config/configmap.yaml
Normal file
11
manifests/config/configmap.yaml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
|
||||||
|
metadata:
|
||||||
|
name: fastapi-config
|
||||||
|
namespace: student-dinkoglc
|
||||||
|
|
||||||
|
data:
|
||||||
|
DATABASE_HOST: postgres-service
|
||||||
|
DATABASE_PORT: "5432"
|
||||||
|
APP_ENV: production
|
||||||
8
manifests/config/namespace.yaml
Normal file
8
manifests/config/namespace.yaml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
|
||||||
|
metadata:
|
||||||
|
name: student-dinkoglc
|
||||||
|
|
||||||
|
labels:
|
||||||
|
managed-by: argocd
|
||||||
13
manifests/config/secret.yaml
Normal file
13
manifests/config/secret.yaml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Secret
|
||||||
|
|
||||||
|
metadata:
|
||||||
|
name: postgres-secret
|
||||||
|
namespace: student-dinkoglc
|
||||||
|
|
||||||
|
type: Opaque
|
||||||
|
|
||||||
|
data:
|
||||||
|
POSTGRES_PASSWORD: c3R1ZGVudDEyMw==
|
||||||
|
POSTGRES_DB: ZmFzdGFwaWRi
|
||||||
|
POSTGRES_USER: ZmFzdGFwaXVzZXI=
|
||||||
51
manifests/database/deployment.yaml
Normal file
51
manifests/database/deployment.yaml
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
|
||||||
|
metadata:
|
||||||
|
name: postgres
|
||||||
|
namespace: student-dinkoglc
|
||||||
|
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: postgres
|
||||||
|
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: postgres
|
||||||
|
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: postgres
|
||||||
|
image: postgres:16-alpine
|
||||||
|
|
||||||
|
envFrom:
|
||||||
|
- secretRef:
|
||||||
|
name: postgres-secret
|
||||||
|
|
||||||
|
ports:
|
||||||
|
- containerPort: 5432
|
||||||
|
|
||||||
|
volumeMounts:
|
||||||
|
- name: postgres-data
|
||||||
|
mountPath: /var/lib/postgresql/data
|
||||||
|
|
||||||
|
readinessProbe:
|
||||||
|
exec:
|
||||||
|
command:
|
||||||
|
- pg_isready
|
||||||
|
- -U
|
||||||
|
- fastapiuser
|
||||||
|
- -d
|
||||||
|
- fastapidb
|
||||||
|
|
||||||
|
initialDelaySeconds: 10
|
||||||
|
periodSeconds: 5
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
- name: postgres-data
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: postgres-pvc
|
||||||
16
manifests/database/pvc.yaml
Normal file
16
manifests/database/pvc.yaml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
|
||||||
|
metadata:
|
||||||
|
name: postgres-pvc
|
||||||
|
namespace: student-dinkoglc
|
||||||
|
|
||||||
|
spec:
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 1Gi
|
||||||
|
|
||||||
|
storageClassName: local-path
|
||||||
16
manifests/database/service.yaml
Normal file
16
manifests/database/service.yaml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
|
||||||
|
metadata:
|
||||||
|
name: postgres-service
|
||||||
|
namespace: student-dinkoglc
|
||||||
|
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
app: postgres
|
||||||
|
|
||||||
|
ports:
|
||||||
|
- port: 5432
|
||||||
|
targetPort: 5432
|
||||||
|
|
||||||
|
type: ClusterIP
|
||||||
Reference in New Issue
Block a user