add kubernetes stuff

This commit is contained in:
Torma Kristóf 2020-11-27 04:18:09 +01:00
parent 5c44768812
commit a194b60077
3 changed files with 72 additions and 1 deletions

View File

@ -0,0 +1,68 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: webshop
namespace: unstablevortex
labels:
app: webshop
spec:
replicas: 1
selector:
matchLabels:
app: webshop
strategy:
type: Recreate
template:
metadata:
labels:
app: webshop
spec:
containers:
- name: webshop
image: registry.kmlabz.com/unstablevortex/webshop
imagePullPolicy: Always
ports:
- containerPort: 8080
imagePullSecrets:
- name: regcred
---
apiVersion: v1
kind: Service
metadata:
name: webshop
namespace: unstablevortex
labels:
app: webshop
spec:
ports:
- name: webshop
port: 80
targetPort: 8080
protocol: TCP
selector:
app: webshop
type: ClusterIP
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: webshop
namespace: unstablevortex
annotations:
kubernetes.io/ingress.class: "nginx"
cert-manager.io/cluster-issuer: "letsencrypt-prod"
nginx.ingress.kubernetes.io/enable-cors: "true"
spec:
tls:
- hosts:
- unstablevortex.k8s.kmlabz.com
secretName: unstablevortex-cert-secret
rules:
- host: unstablevortex.k8s.kmlabz.com
http:
paths:
- path: /
backend:
serviceName: webshop
servicePort: 80

View File

@ -5,9 +5,10 @@ import sentry_sdk
from sentry_sdk.integrations.flask import FlaskIntegration from sentry_sdk.integrations.flask import FlaskIntegration
from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration
from healthcheck import HealthCheck from healthcheck import HealthCheck
from flask_cors import CORS
from utils.config import SENTRY_DSN, RELEASE_ID, RELEASEMODE, POSTGRES_DB, PORT, POSTGRES_HOSTNAME, POSTGRES_PASSWORD, \ from utils.config import SENTRY_DSN, RELEASE_ID, RELEASEMODE, POSTGRES_DB, PORT, POSTGRES_HOSTNAME, POSTGRES_PASSWORD, \
POSTGRES_USERNAME, DEBUG, SECRET_KEY POSTGRES_USERNAME, DEBUG, SECRET_KEY, ALLOWED_ORIGINS
from utils import db, ma, health_database_status, security, user_datastore from utils import db, ma, health_database_status, security, user_datastore
from views import ItemView, LoginView, ProfileView, RegisterView, UploadView from views import ItemView, LoginView, ProfileView, RegisterView, UploadView
@ -41,6 +42,7 @@ health = HealthCheck()
db.init_app(app) db.init_app(app)
ma.init_app(app) ma.init_app(app)
security.init_app(app, user_datastore) security.init_app(app, user_datastore)
CORS(app, origins=ALLOWED_ORIGINS)
formatter = logging.Formatter( formatter = logging.Formatter(
fmt="%(asctime)s - %(levelname)s - %(module)s - %(message)s" fmt="%(asctime)s - %(levelname)s - %(module)s - %(message)s"

View File

@ -25,3 +25,4 @@ POSTGRES_PASSWORD = os.getenv("POSTGRES_PASSWORD", "webshop")
POSTGRES_DB = os.getenv("POSTGRES_DB", "webshop") POSTGRES_DB = os.getenv("POSTGRES_DB", "webshop")
SECRET_KEY = os.getenv("SECRET_KEY") SECRET_KEY = os.getenv("SECRET_KEY")
ALLOWED_ORIGINS = os.environ.get('ALLOWED_ORIGINS', '*')