Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy releases/k8s-manifests c12c9cb #66

Merged
merged 3 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions balancer/ConfigMap/backend-env.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
data:
DATABASE: postgres
DEBUG: 'FALSE'
DJANGO_ALLOWED_HOSTS: 'frontend localhost 127.0.0.1 [::1]'
EMAIL_HOST: smtp.gmail.com
EMAIL_HOST_USER: balancer-noreply@gmail.com
EMAIL_PORT: '587'
LOGIN_REDIRECT_URL: 'https://balancertestsite.com/login'
SQL_ENGINE: django.db.backends.postgresql
SQL_PORT: '5432'
kind: ConfigMap
metadata:
labels:
app.kubernetes.io/component: backend
name: backend-env
namespace: balancer
90 changes: 64 additions & 26 deletions balancer/ConfigMap/nginx-conf.yaml
Original file line number Diff line number Diff line change
@@ -1,44 +1,82 @@
apiVersion: v1
data:
nginx.conf: |
user nginx;
worker_processes 1;
worker_processes 1;

user nobody nogroup;
# 'user nobody nobody;' for systems with 'nobody' as a group instead
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;

events {
worker_connections 1024;
worker_connections 1024; # increase if you have lots of clients
accept_mutex off; # set to 'on' if nginx worker_processes > 1
# 'use epoll;' to enable for Linux 2.6+
# 'use kqueue;' to enable for FreeBSD, OSX
}

http {
include /etc/nginx/mime.types;
error_log /var/log/nginx/error_log;
access_log /var/log/nginx/access_log;
include mime.types;
# fallback in case we can't determine a type
default_type application/octet-stream;
access_log /var/log/nginx/access.log combined;
sendfile on;

upstream gunicorn_server {
# fail_timeout=0 means we always retry an upstream even if it failed
# to return a good HTTP response

# for UNIX domain socket setups
# server unix:/tmp/gunicorn.sock fail_timeout=0;

# for a TCP configuration
# "backend" here is the name of the kubernetes service
server backend:8000 fail_timeout=0;
}

server {
listen 80;
listen [::]:80;
server_name localhost;
# if no Host match, close the connection to prevent host spoofing
listen 80 default_server;
return 444;
}

location /access_log {
alias /var/log/nginx/access_log;
}
location /error_log {
alias /var/log/nginx/error_log;
server {
# use 'listen 80 deferred;' for Linux
# use 'listen 80 accept_filter=httpready;' for FreeBSD
listen 80 deferred;
client_max_body_size 4G;

# set the correct host(s) for your site
server_name localhost;

keepalive_timeout 5;

# path for static files
root /usr/share/nginx/html;
location ~ (^\/api\/|^\/auth\/|^\/admin) {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
# we don't want nginx trying to do something clever with
# redirects, we set the Host: header above already.
proxy_redirect off;
proxy_pass http://gunicorn_server;
}

location / {
root /usr/share/nginx/html;
index index.html index.htm;
index index.html;
try_files $uri $uri/ /index.html;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
# root /usr/share/nginx/html;

#}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}
kind: ConfigMap
metadata:
labels:
app.kubernetes.io/component: frontend
name: nginx-conf
namespace: balancer
55 changes: 55 additions & 0 deletions balancer/Deployment/backend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/component: backend
name: backend
namespace: balancer
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/component: backend
strategy: {}
template:
metadata:
labels:
app.kubernetes.io/component: backend
spec:
containers:
- args:
- gunicorn
- 'balancer_backend.wsgi:application'
- '--bind'
- '0.0.0.0:8000'
env:
- name: SQL_HOST
value: db-service
- name: SQL_USER
valueFrom:
secretKeyRef:
key: POSTGRES_USER
name: postgresql
- name: SQL_DATABASE
valueFrom:
secretKeyRef:
key: POSTGRES_DB
name: postgresql
- name: SQL_PASSWORD
valueFrom:
secretKeyRef:
key: POSTGRES_PASSWORD
name: postgresql
envFrom:
- configMapRef:
name: backend-env
- secretRef:
name: backend
image: 'ghcr.io/codeforphilly/balancer-main/backend:latest'
imagePullPolicy: Always
name: backend
ports:
- containerPort: 8000
protocol: TCP
resources: {}
restartPolicy: Always
54 changes: 0 additions & 54 deletions balancer/Deployment/frontend-static.yaml

This file was deleted.

43 changes: 43 additions & 0 deletions balancer/Deployment/frontend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/component: frontend
name: frontend
namespace: balancer
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/component: frontend
strategy: {}
template:
metadata:
annotations:
kompose.cmd: kompose convert -c -f docker-compose.prod.yml -o helm-chart
kompose.version: 1.31.2 (a92241f79)
labels:
app.kubernetes.io/component: frontend
io.kompose.network/balancer-main-default: 'true'
spec:
containers:
- image: 'ghcr.io/codeforphilly/balancer-main/frontend:latest'
imagePullPolicy: Always
name: frontend
ports:
- containerPort: 80
protocol: TCP
resources: {}
volumeMounts:
- mountPath: /etc/nginx/nginx.conf
name: nginx-conf
readOnly: true
subPath: nginx.conf
restartPolicy: Always
volumes:
- configMap:
items:
- key: nginx.conf
path: nginx.conf
name: nginx-conf
name: nginx-conf
29 changes: 29 additions & 0 deletions balancer/Ingress/balancer-ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
name: balancer-ingress
namespace: balancer
spec:
rules:
- host: balancer.sandbox.k8s.phl.io
http:
paths:
- backend:
service:
name: frontend
port:
name: http
path: /
pathType: Prefix
- host: balancertestsite.com
http:
paths:
- backend:
service:
name: frontend
port:
name: http
path: /
pathType: Prefix
13 changes: 13 additions & 0 deletions balancer/PersistentVolumeClaim/postgres-data-claim.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
labels:
app.kubernetes.io/component: db
name: postgres-data-claim
namespace: balancer
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi
8 changes: 5 additions & 3 deletions balancer/SealedSecret/backend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ metadata:
spec:
encryptedData:
EMAIL_HOST_PASSWORD: >-
AgC/1ooxNBa/IT8EHI1ImULDg0vcNOcgEpMsNFuD05+f9QM2RBRCVlw6hWZRWyqNPFa3+LrEPGyo+LwrAAdJUVjs1vvq9C/GevDzkSRPwdjMeR5dCsRBIZxC3TSiiF/xTwUheBFRoUstsqGt1jRV8crknkHeUzmMT0NahkV5vfnkCrvLgTuZrHduWNBreUT12SQwS3o62/r8aK9MTXUjwdrXdr25zQYvisSfODoJpApWjpurM28iHT+5pt3bxJfxxRg8rNTBCI4TxJ1vCLZNKYACyaHTQcsStsQqH5f7yoOPf7tH89GVZN+fjWSwhVbaL5VDdE6Qi6U8+yKHSI80gV3okczHUt9d8mrbh7m2RIHbLLIK9xq/WSos3MC+i1bNfLGA5gOfIDSIBkovqDh2lIwlV4qTYrSqdZlyyc/djf4dMmxbTtCb6FjplmGAEQCGmERg9TIg/XZcGfhkiJEVIZ1wcov8zAs7KwydpMLJFFpbFfmkb7akIq1tDlYWrpygO2tGcZIXr9sMnjsG09hLTx9EbUArdhMCsol6mM+q9OuZtDVg9Kzb59F5DhrbtnIheTyONvu7X/0Rn9arUxjdzBKf5gaw69MuPyynbpwRjSEqmHv5mp/VkBtDXObWeEi4IM0+cgi2il/y2rIxIHu/lPoZ290fx343FceXsJUuwc3PUCOEk6Sajw2j8j3x0iP9W8/lhdHcJ0uBrmNPVdiuIoJS
AgBYzAgOfX97gTS3lrQWGQaHK0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egf/MgGl6cTONLt/Xtaf6KLXJMFhGmoOAl8tonkN/gdi4f6tcEaa7cZne2AraFDwBPYUu20iAaFNdw+rHPAK92vsjqfNG0yjsCPVLaw5kR2Uynmcpkn75zbPlVDC3IzwAeZqdV0PqD01Iqc+ACqodidvqGTaJ5ot2maz1ZUnt/bkbgnxE4Tad1KLQPgmB/Bj1fhanz+H+zuP/eSQGxcELLojfXzGEN9MECLqhkeyRwYa5/PgKXt+ZIm5qydsfeBD4WoCLKUbWrxkYCclvyfAc45KJqHzwiAK
template:
metadata:
creationTimestamp: null
Expand Down
14 changes: 14 additions & 0 deletions balancer/Service/backend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/component: backend
name: backend
namespace: balancer
spec:
ports:
- name: gunicorn
port: 8000
targetPort: 8000
selector:
app.kubernetes.io/component: backend
12 changes: 12 additions & 0 deletions balancer/Service/db-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: db-service
namespace: balancer
spec:
ports:
- port: 5432
protocol: TCP
selector:
app.kubernetes.io/component: db
type: NodePort
20 changes: 0 additions & 20 deletions balancer/Service/frontend-static.yaml

This file was deleted.

Loading
Loading