got to exercise
This commit is contained in:
parent
47dcffc97a
commit
0465146fec
1 changed files with 164 additions and 37 deletions
|
|
@ -1,5 +1,21 @@
|
||||||
# ======================================================
|
# ======================================================
|
||||||
# WGER - PRODUCTION (exercise.juntekim.com)
|
# WGER - PRODUCTION ARCHITECTURE
|
||||||
|
# Traefik → nginx → wger → postgres
|
||||||
|
# ======================================================
|
||||||
|
|
||||||
|
# -------------------------
|
||||||
|
# STORAGE CLASS
|
||||||
|
# -------------------------
|
||||||
|
---
|
||||||
|
apiVersion: storage.k8s.io/v1
|
||||||
|
kind: StorageClass
|
||||||
|
metadata:
|
||||||
|
name: wger-local-storage
|
||||||
|
provisioner: kubernetes.io/no-provisioner
|
||||||
|
volumeBindingMode: WaitForFirstConsumer
|
||||||
|
|
||||||
|
# ======================================================
|
||||||
|
# PERSISTENT VOLUMES
|
||||||
# ======================================================
|
# ======================================================
|
||||||
|
|
||||||
# -------------------------
|
# -------------------------
|
||||||
|
|
@ -13,8 +29,7 @@ metadata:
|
||||||
spec:
|
spec:
|
||||||
capacity:
|
capacity:
|
||||||
storage: 2Gi
|
storage: 2Gi
|
||||||
accessModes:
|
accessModes: [ReadWriteOnce]
|
||||||
- ReadWriteOnce
|
|
||||||
storageClassName: wger-local-storage
|
storageClassName: wger-local-storage
|
||||||
persistentVolumeReclaimPolicy: Retain
|
persistentVolumeReclaimPolicy: Retain
|
||||||
local:
|
local:
|
||||||
|
|
@ -25,17 +40,49 @@ spec:
|
||||||
- matchExpressions:
|
- matchExpressions:
|
||||||
- key: kubernetes.io/hostname
|
- key: kubernetes.io/hostname
|
||||||
operator: In
|
operator: In
|
||||||
values:
|
values: [mist]
|
||||||
- mist
|
|
||||||
|
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: PersistentVolumeClaim
|
kind: PersistentVolumeClaim
|
||||||
metadata:
|
metadata:
|
||||||
name: wger-postgres-pvc
|
name: wger-postgres-pvc
|
||||||
spec:
|
spec:
|
||||||
accessModes:
|
accessModes: [ReadWriteOnce]
|
||||||
- ReadWriteOnce
|
storageClassName: wger-local-storage
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 2Gi
|
||||||
|
|
||||||
|
# -------------------------
|
||||||
|
# STATIC PV
|
||||||
|
# -------------------------
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolume
|
||||||
|
metadata:
|
||||||
|
name: wger-static-pv
|
||||||
|
spec:
|
||||||
|
capacity:
|
||||||
|
storage: 2Gi
|
||||||
|
accessModes: [ReadWriteOnce]
|
||||||
|
storageClassName: wger-local-storage
|
||||||
|
persistentVolumeReclaimPolicy: Retain
|
||||||
|
local:
|
||||||
|
path: /home/kimjunte/k8s_storage/wger/static
|
||||||
|
nodeAffinity:
|
||||||
|
required:
|
||||||
|
nodeSelectorTerms:
|
||||||
|
- matchExpressions:
|
||||||
|
- key: kubernetes.io/hostname
|
||||||
|
operator: In
|
||||||
|
values: [mist]
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
metadata:
|
||||||
|
name: wger-static-pvc
|
||||||
|
spec:
|
||||||
|
accessModes: [ReadWriteOnce]
|
||||||
storageClassName: wger-local-storage
|
storageClassName: wger-local-storage
|
||||||
resources:
|
resources:
|
||||||
requests:
|
requests:
|
||||||
|
|
@ -52,8 +99,7 @@ metadata:
|
||||||
spec:
|
spec:
|
||||||
capacity:
|
capacity:
|
||||||
storage: 5Gi
|
storage: 5Gi
|
||||||
accessModes:
|
accessModes: [ReadWriteOnce]
|
||||||
- ReadWriteOnce
|
|
||||||
storageClassName: wger-local-storage
|
storageClassName: wger-local-storage
|
||||||
persistentVolumeReclaimPolicy: Retain
|
persistentVolumeReclaimPolicy: Retain
|
||||||
local:
|
local:
|
||||||
|
|
@ -64,25 +110,23 @@ spec:
|
||||||
- matchExpressions:
|
- matchExpressions:
|
||||||
- key: kubernetes.io/hostname
|
- key: kubernetes.io/hostname
|
||||||
operator: In
|
operator: In
|
||||||
values:
|
values: [mist]
|
||||||
- mist
|
|
||||||
|
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: PersistentVolumeClaim
|
kind: PersistentVolumeClaim
|
||||||
metadata:
|
metadata:
|
||||||
name: wger-media-pvc
|
name: wger-media-pvc
|
||||||
spec:
|
spec:
|
||||||
accessModes:
|
accessModes: [ReadWriteOnce]
|
||||||
- ReadWriteOnce
|
|
||||||
storageClassName: wger-local-storage
|
storageClassName: wger-local-storage
|
||||||
resources:
|
resources:
|
||||||
requests:
|
requests:
|
||||||
storage: 5Gi
|
storage: 5Gi
|
||||||
|
|
||||||
# -------------------------
|
# ======================================================
|
||||||
# POSTGRES
|
# POSTGRES
|
||||||
# -------------------------
|
# ======================================================
|
||||||
|
|
||||||
---
|
---
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
|
@ -129,9 +173,10 @@ spec:
|
||||||
ports:
|
ports:
|
||||||
- port: 5432
|
- port: 5432
|
||||||
|
|
||||||
# -------------------------
|
# ======================================================
|
||||||
# REDIS
|
# REDIS
|
||||||
# -------------------------
|
# ======================================================
|
||||||
|
|
||||||
---
|
---
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
|
@ -152,8 +197,6 @@ spec:
|
||||||
containers:
|
containers:
|
||||||
- name: redis
|
- name: redis
|
||||||
image: redis:7-alpine
|
image: redis:7-alpine
|
||||||
ports:
|
|
||||||
- containerPort: 6379
|
|
||||||
|
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
|
|
@ -166,9 +209,10 @@ spec:
|
||||||
ports:
|
ports:
|
||||||
- port: 6379
|
- port: 6379
|
||||||
|
|
||||||
# -------------------------
|
# ======================================================
|
||||||
# WGER APP
|
# WGER APP
|
||||||
# -------------------------
|
# ======================================================
|
||||||
|
|
||||||
---
|
---
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
|
@ -190,26 +234,27 @@ spec:
|
||||||
- name: wger
|
- name: wger
|
||||||
image: wger/server:latest
|
image: wger/server:latest
|
||||||
env:
|
env:
|
||||||
- name: DJANGO_SECRET_KEY
|
|
||||||
value: replace-with-long-random-string
|
|
||||||
|
|
||||||
- name: DATABASE_URL
|
- name: DATABASE_URL
|
||||||
value: postgres://wger:wgerpassword@wger-postgres:5432/wger
|
value: postgres://wger:wgerpassword@wger-postgres:5432/wger
|
||||||
|
|
||||||
- name: CACHE_URL
|
- name: CACHE_URL
|
||||||
value: redis://wger-redis:6379/1
|
value: redis://wger-redis:6379/1
|
||||||
|
- name: DJANGO_SECRET_KEY
|
||||||
|
value: replace-with-long-random-string
|
||||||
- name: ALLOWED_HOSTS
|
- name: ALLOWED_HOSTS
|
||||||
value: exercise.juntekim.com
|
value: "*"
|
||||||
|
- name: CSRF_TRUSTED_ORIGINS
|
||||||
|
value: https://exercise.juntekim.com
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 8000
|
- containerPort: 8000
|
||||||
|
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
|
- name: static-storage
|
||||||
|
mountPath: /home/wger/static
|
||||||
- name: media-storage
|
- name: media-storage
|
||||||
mountPath: /home/wger/media
|
mountPath: /home/wger/media
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
|
- name: static-storage
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: wger-static-pvc
|
||||||
- name: media-storage
|
- name: media-storage
|
||||||
persistentVolumeClaim:
|
persistentVolumeClaim:
|
||||||
claimName: wger-media-pvc
|
claimName: wger-media-pvc
|
||||||
|
|
@ -223,12 +268,95 @@ spec:
|
||||||
selector:
|
selector:
|
||||||
app: wger
|
app: wger
|
||||||
ports:
|
ports:
|
||||||
- port: 80
|
- port: 8000
|
||||||
targetPort: 8000
|
targetPort: 8000
|
||||||
|
|
||||||
# -------------------------
|
# ======================================================
|
||||||
|
# NGINX (STATIC + PROXY)
|
||||||
|
# ======================================================
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: wger-nginx-config
|
||||||
|
data:
|
||||||
|
default.conf: |
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
|
||||||
|
location /static/ {
|
||||||
|
alias /home/wger/static/;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /media/ {
|
||||||
|
alias /home/wger/media/;
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://wger:8000;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: wger-nginx
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: wger-nginx
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: wger-nginx
|
||||||
|
spec:
|
||||||
|
nodeSelector:
|
||||||
|
kubernetes.io/hostname: mist
|
||||||
|
containers:
|
||||||
|
- name: nginx
|
||||||
|
image: nginx:alpine
|
||||||
|
ports:
|
||||||
|
- containerPort: 80
|
||||||
|
volumeMounts:
|
||||||
|
- name: static-storage
|
||||||
|
mountPath: /home/wger/static
|
||||||
|
- name: media-storage
|
||||||
|
mountPath: /home/wger/media
|
||||||
|
- name: nginx-config
|
||||||
|
mountPath: /etc/nginx/conf.d
|
||||||
|
volumes:
|
||||||
|
- name: static-storage
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: wger-static-pvc
|
||||||
|
- name: media-storage
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: wger-media-pvc
|
||||||
|
- name: nginx-config
|
||||||
|
configMap:
|
||||||
|
name: wger-nginx-config
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: wger-nginx
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
app: wger-nginx
|
||||||
|
ports:
|
||||||
|
- port: 80
|
||||||
|
targetPort: 80
|
||||||
|
|
||||||
|
# ======================================================
|
||||||
# TRAEFIK INGRESS
|
# TRAEFIK INGRESS
|
||||||
# -------------------------
|
# ======================================================
|
||||||
|
|
||||||
---
|
---
|
||||||
apiVersion: traefik.io/v1alpha1
|
apiVersion: traefik.io/v1alpha1
|
||||||
kind: IngressRoute
|
kind: IngressRoute
|
||||||
|
|
@ -241,8 +369,7 @@ spec:
|
||||||
- match: Host(`exercise.juntekim.com`)
|
- match: Host(`exercise.juntekim.com`)
|
||||||
kind: Rule
|
kind: Rule
|
||||||
services:
|
services:
|
||||||
- name: wger
|
- name: wger-nginx
|
||||||
port: 80
|
port: 80
|
||||||
passHostHeader: true
|
|
||||||
tls:
|
tls:
|
||||||
certResolver: myresolver
|
certResolver: myresolver
|
||||||
Loading…
Add table
Reference in a new issue