149 lines
4.0 KiB
YAML
149 lines
4.0 KiB
YAML
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: nginx-deployment
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels:
|
|
app: izaac
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: izaac
|
|
spec:
|
|
containers:
|
|
- name: nginx
|
|
image: nginx:latest
|
|
ports:
|
|
- containerPort: 80
|
|
volumeMounts:
|
|
- name: nginx-conf-volume
|
|
mountPath: /etc/nginx/nginx.conf
|
|
subPath: nginx.conf
|
|
- name: static-volume
|
|
mountPath: /usr/share/nginx/html
|
|
- name: static-media
|
|
mountPath: /usr/share/nginx/media
|
|
volumes:
|
|
- name: nginx-conf-volume
|
|
configMap:
|
|
name: nginx-config
|
|
- name: static-volume
|
|
persistentVolumeClaim:
|
|
claimName: static-pvc
|
|
- name: static-media
|
|
persistentVolumeClaim:
|
|
claimName: media-pvc
|
|
---
|
|
apiVersion: v1
|
|
kind: ConfigMap
|
|
metadata:
|
|
name: nginx-config
|
|
data:
|
|
nginx.conf: |
|
|
user nginx;
|
|
worker_processes auto;
|
|
|
|
error_log /var/log/nginx/error.log warn;
|
|
pid /var/run/nginx.pid;
|
|
|
|
events {
|
|
worker_connections 1024;
|
|
}
|
|
|
|
http {
|
|
include /etc/nginx/mime.types;
|
|
default_type application/octet-stream;
|
|
|
|
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
|
'$status $body_bytes_sent "$http_referer" '
|
|
'"$http_user_agent" "$http_x_forwarded_for"';
|
|
|
|
access_log /var/log/nginx/access.log main;
|
|
|
|
sendfile on;
|
|
#tcp_nopush on;
|
|
|
|
keepalive_timeout 65;
|
|
|
|
#gzip on;
|
|
|
|
server {
|
|
listen 80;
|
|
server_name localhost;
|
|
|
|
location /static {
|
|
alias /usr/share/nginx/html; # Upewnij się, że ta ścieżka jest zgodna z `mountPath` w Twoim konfigu Deploymentu Nginx
|
|
expires 30d;
|
|
add_header Pragma public;
|
|
add_header Cache-Control "public";
|
|
try_files $uri =404;
|
|
}
|
|
location /media {
|
|
alias /usr/share/nginx/media;
|
|
expires 30d;
|
|
add_header Pragma public;
|
|
add_header Cache-Control "public";
|
|
try_files $uri =404;
|
|
}
|
|
location /api {
|
|
proxy_pass http://izaac-backend:8000; # Upewnij się, że ta nazwa jest zgodna z nazwą serwisu Twojej aplikacji Django
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
}
|
|
location /admin {
|
|
proxy_pass http://izaac-backend:8000; # Upewnij się, że ta nazwa jest zgodna z nazwą serwisu Twojej aplikacji Django
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
}
|
|
location / {
|
|
proxy_pass http://izaac-frontend:80; # Upewnij się, że ta nazwa jest zgodna z nazwą serwisu Twojej aplikacji Django
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
}
|
|
}
|
|
}
|
|
---
|
|
apiVersion: networking.k8s.io/v1
|
|
kind: Ingress
|
|
metadata:
|
|
name: izaac-ingress
|
|
annotations:
|
|
kubernetes.io/ingress.class: "traefik"
|
|
traefik.ingress.kubernetes.io/router.tls: "true"
|
|
spec:
|
|
tls:
|
|
- hosts:
|
|
- "*.knck.pl"
|
|
- "izaac.knck.pl"
|
|
secretName: tls-secret
|
|
rules:
|
|
- host: izaac.knck.pl
|
|
http:
|
|
paths:
|
|
- path: /
|
|
pathType: Prefix
|
|
backend:
|
|
service:
|
|
name: izaac
|
|
port:
|
|
number: 80
|
|
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: izaac
|
|
spec:
|
|
selector:
|
|
app: izaac
|
|
ports:
|
|
- protocol: TCP
|
|
port: 80
|
|
targetPort: 80
|