add playmat to k3s
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: imgcache-config
|
||||
namespace: playmat
|
||||
data:
|
||||
imgcache.conf.template: |
|
||||
resolver kube-dns.kube-system.svc.cluster.local ipv6=off valid=300s;
|
||||
resolver_timeout 5s;
|
||||
proxy_cache_path /var/cache/nginx/scryfall/images levels=1:2 keys_zone=scryfall_images:50m max_size=${IMGCACHE_IMAGES_MAX_SIZE} inactive=365d use_temp_path=off;
|
||||
proxy_cache_path /var/cache/nginx/scryfall/api levels=1:2 keys_zone=scryfall_api:20m max_size=${IMGCACHE_API_MAX_SIZE} inactive=365d use_temp_path=off;
|
||||
limit_req_zone $server_port zone=scryfall_upstream:1m rate=${IMGCACHE_API_RATE};
|
||||
limit_req_status 429;
|
||||
proxy_buffer_size 32k;
|
||||
proxy_buffers 16 32k;
|
||||
proxy_busy_buffers_size 64k;
|
||||
server {
|
||||
listen 8080;
|
||||
server_name _;
|
||||
location = /healthz { access_log off; default_type text/plain; return 200 "ok\n"; }
|
||||
location ~ ^/img/(cards|backs)/ {
|
||||
proxy_set_header Host $1.scryfall.io;
|
||||
proxy_set_header User-Agent "PlaymatXMageImageCache/1.0 (+https://github.com/arcanite24/playmat)";
|
||||
proxy_set_header Accept "*/*";
|
||||
proxy_set_header Accept-Encoding "";
|
||||
proxy_ssl_server_name on;
|
||||
proxy_ssl_verify ${IMGCACHE_UPSTREAM_TLS_VERIFY};
|
||||
proxy_cache scryfall_images;
|
||||
proxy_cache_key $request_uri;
|
||||
proxy_cache_valid 200 301 302 365d;
|
||||
proxy_pass https://$1.scryfall.io$request_uri;
|
||||
}
|
||||
location = /img/api/cards/collection {
|
||||
limit_except POST { deny all; }
|
||||
proxy_pass https://api.scryfall.com/cards/collection;
|
||||
proxy_set_header Host api.scryfall.com;
|
||||
proxy_set_header User-Agent "PlaymatXMageImageCache/1.0 (+https://github.com/arcanite24/playmat)";
|
||||
proxy_cache scryfall_api;
|
||||
proxy_cache_methods GET HEAD POST;
|
||||
proxy_cache_key "$request_method$request_uri$request_body";
|
||||
proxy_cache_valid 200 24h;
|
||||
}
|
||||
location /img/api/ {
|
||||
proxy_pass https://api.scryfall.com/;
|
||||
proxy_set_header Host api.scryfall.com;
|
||||
proxy_set_header User-Agent "PlaymatXMageImageCache/1.0 (+https://github.com/arcanite24/playmat)";
|
||||
proxy_ssl_server_name on;
|
||||
proxy_cache scryfall_api;
|
||||
proxy_cache_key $request_uri;
|
||||
proxy_cache_valid 200 301 302 24h;
|
||||
}
|
||||
location / { return 404; }
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: imgcache
|
||||
namespace: playmat
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy:
|
||||
type: Recreate
|
||||
selector:
|
||||
matchLabels:
|
||||
app: imgcache
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: imgcache
|
||||
spec:
|
||||
securityContext:
|
||||
seccompProfile:
|
||||
type: RuntimeDefault
|
||||
containers:
|
||||
- name: imgcache
|
||||
image: nginx:1.30.5-alpine
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 8080
|
||||
env:
|
||||
- name: IMGCACHE_IMAGES_MAX_SIZE
|
||||
value: 4g
|
||||
- name: IMGCACHE_API_MAX_SIZE
|
||||
value: 512m
|
||||
- name: IMGCACHE_API_RATE
|
||||
value: 10r/s
|
||||
- name: IMGCACHE_API_BURST
|
||||
value: "20"
|
||||
- name: IMGCACHE_CARDS_UPSTREAM
|
||||
value: https://cards.scryfall.io
|
||||
- name: IMGCACHE_BACKS_UPSTREAM
|
||||
value: https://backs.scryfall.io
|
||||
- name: IMGCACHE_API_UPSTREAM
|
||||
value: https://api.scryfall.com
|
||||
- name: IMGCACHE_FALLBACK
|
||||
value: "off"
|
||||
- name: IMGCACHE_UPSTREAM_TLS_VERIFY
|
||||
value: "on"
|
||||
volumeMounts:
|
||||
- name: imgcache-data
|
||||
mountPath: /var/cache/nginx/scryfall
|
||||
- name: config
|
||||
mountPath: /etc/nginx/templates/default.conf.template
|
||||
subPath: imgcache.conf.template
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /healthz
|
||||
port: http
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 10
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /healthz
|
||||
port: http
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 30
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities:
|
||||
drop:
|
||||
- ALL
|
||||
resources:
|
||||
requests:
|
||||
cpu: 50m
|
||||
memory: 64Mi
|
||||
limits:
|
||||
cpu: 300m
|
||||
memory: 256Mi
|
||||
volumes:
|
||||
- name: imgcache-data
|
||||
persistentVolumeClaim:
|
||||
claimName: imgcache-data
|
||||
- name: config
|
||||
configMap:
|
||||
name: imgcache-config
|
||||
@@ -0,0 +1,12 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: imgcache
|
||||
namespace: playmat
|
||||
spec:
|
||||
selector:
|
||||
app: imgcache
|
||||
ports:
|
||||
- name: http
|
||||
port: 8080
|
||||
targetPort: http
|
||||
@@ -0,0 +1,25 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: playmat
|
||||
namespace: playmat
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: letsencrypt-prod
|
||||
traefik.ingress.kubernetes.io/router.entrypoints: websecure
|
||||
spec:
|
||||
ingressClassName: traefik
|
||||
rules:
|
||||
- host: playmat.aleshym.co
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: web
|
||||
port:
|
||||
name: http
|
||||
tls:
|
||||
- hosts:
|
||||
- playmat.aleshym.co
|
||||
secretName: playmat-tls
|
||||
@@ -0,0 +1,15 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
resources:
|
||||
- namespace.yaml
|
||||
- pvc.yaml
|
||||
- imgcache-configmap.yaml
|
||||
- xmage-deployment.yaml
|
||||
- xmage-service.yaml
|
||||
- imgcache-deployment.yaml
|
||||
- imgcache-service.yaml
|
||||
- web-deployment.yaml
|
||||
- web-service.yaml
|
||||
- ingress.yaml
|
||||
- network-policy.yaml
|
||||
@@ -0,0 +1,4 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: playmat
|
||||
@@ -0,0 +1,15 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: allow-ingress-from-traefik-and-playmat
|
||||
namespace: playmat
|
||||
spec:
|
||||
podSelector: {}
|
||||
policyTypes:
|
||||
- Ingress
|
||||
ingress:
|
||||
- from:
|
||||
- namespaceSelector:
|
||||
matchLabels:
|
||||
kubernetes.io/metadata.name: kube-system
|
||||
- podSelector: {}
|
||||
@@ -0,0 +1,25 @@
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: xmage-data
|
||||
namespace: playmat
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
storageClassName: local-path
|
||||
resources:
|
||||
requests:
|
||||
storage: 5Gi
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: imgcache-data
|
||||
namespace: playmat
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
storageClassName: local-path
|
||||
resources:
|
||||
requests:
|
||||
storage: 5Gi
|
||||
@@ -0,0 +1,64 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: web
|
||||
namespace: playmat
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: web
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: web
|
||||
spec:
|
||||
securityContext:
|
||||
seccompProfile:
|
||||
type: RuntimeDefault
|
||||
containers:
|
||||
- name: web
|
||||
image: ghcr.io/arcanite24/playmat-web:master
|
||||
imagePullPolicy: Always
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 80
|
||||
env:
|
||||
- name: DOMAIN
|
||||
value: playmat.aleshym.co
|
||||
- name: TLS_MODE
|
||||
value: external
|
||||
- name: UPSTREAM_PROXIES
|
||||
value: 10.42.0.0/16
|
||||
- name: XMAGE_GATEWAY
|
||||
value: off
|
||||
- name: XMAGE_ALLOWED_ORIGINS
|
||||
value: https://playmat.aleshym.co
|
||||
- name: XMAGE_PUBLIC_URL
|
||||
value: https://playmat.aleshym.co
|
||||
- name: CADDY_IP
|
||||
value: 127.0.0.1
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: http
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 10
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: http
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 30
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities:
|
||||
drop:
|
||||
- ALL
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 128Mi
|
||||
limits:
|
||||
cpu: 500m
|
||||
memory: 256Mi
|
||||
@@ -0,0 +1,12 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: web
|
||||
namespace: playmat
|
||||
spec:
|
||||
selector:
|
||||
app: web
|
||||
ports:
|
||||
- name: http
|
||||
port: 80
|
||||
targetPort: http
|
||||
@@ -0,0 +1,116 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: xmage
|
||||
namespace: playmat
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy:
|
||||
type: Recreate
|
||||
selector:
|
||||
matchLabels:
|
||||
app: xmage
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: xmage
|
||||
spec:
|
||||
securityContext:
|
||||
seccompProfile:
|
||||
type: RuntimeDefault
|
||||
initContainers:
|
||||
- name: prepare-data
|
||||
image: busybox:1.37
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- mkdir -p /data/db /data/cards-db /data/logs /data/saved /data/updates
|
||||
volumeMounts:
|
||||
- name: xmage-data
|
||||
mountPath: /data
|
||||
containers:
|
||||
- name: xmage
|
||||
image: ghcr.io/arcanite24/playmat-server:master
|
||||
imagePullPolicy: Always
|
||||
ports:
|
||||
- name: bridge
|
||||
containerPort: 17172
|
||||
- name: health
|
||||
containerPort: 17173
|
||||
env:
|
||||
- name: XMAGE_ALLOWED_ORIGINS
|
||||
value: https://playmat.aleshym.co
|
||||
- name: XMAGE_PUBLIC_URL
|
||||
value: https://playmat.aleshym.co
|
||||
- name: XMAGE_SERVER_NAME
|
||||
value: playmat
|
||||
- name: XMAGE_TRUSTED_PROXIES
|
||||
value: 10.42.0.0/16
|
||||
- name: XMAGE_AUTH
|
||||
value: "false"
|
||||
- name: XMAGE_ACCESS
|
||||
value: open
|
||||
- name: XMAGE_CAREER
|
||||
value: "on"
|
||||
- name: XMAGE_SAVE_GAMES
|
||||
value: "false"
|
||||
- name: XMAGE_REPLAYS
|
||||
value: "true"
|
||||
- name: XMAGE_UPDATE_CHECK
|
||||
value: "off"
|
||||
- name: XMAGE_MEMORY
|
||||
value: 768m
|
||||
- name: XMAGE_MAX_GAME_THREADS
|
||||
value: "2"
|
||||
- name: XMAGE_MAX_AI_OPPONENTS
|
||||
value: "2"
|
||||
- name: XMAGE_GATEWAY
|
||||
value: off
|
||||
- name: XMAGE_AI_BACKEND
|
||||
value: java
|
||||
volumeMounts:
|
||||
- name: xmage-data
|
||||
mountPath: /opt/xmage/db
|
||||
subPath: db
|
||||
- name: xmage-data
|
||||
mountPath: /opt/xmage/cards-db
|
||||
subPath: cards-db
|
||||
- name: xmage-data
|
||||
mountPath: /opt/xmage/logs
|
||||
subPath: logs
|
||||
- name: xmage-data
|
||||
mountPath: /opt/xmage/saved
|
||||
subPath: saved
|
||||
- name: xmage-data
|
||||
mountPath: /opt/xmage/updates
|
||||
subPath: updates
|
||||
startupProbe:
|
||||
tcpSocket:
|
||||
port: health
|
||||
periodSeconds: 15
|
||||
failureThreshold: 60
|
||||
readinessProbe:
|
||||
tcpSocket:
|
||||
port: bridge
|
||||
periodSeconds: 10
|
||||
livenessProbe:
|
||||
tcpSocket:
|
||||
port: bridge
|
||||
initialDelaySeconds: 120
|
||||
periodSeconds: 30
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities:
|
||||
drop:
|
||||
- ALL
|
||||
resources:
|
||||
requests:
|
||||
cpu: 500m
|
||||
memory: 1Gi
|
||||
limits:
|
||||
cpu: 1500m
|
||||
memory: 2Gi
|
||||
volumes:
|
||||
- name: xmage-data
|
||||
persistentVolumeClaim:
|
||||
claimName: xmage-data
|
||||
@@ -0,0 +1,15 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: xmage
|
||||
namespace: playmat
|
||||
spec:
|
||||
selector:
|
||||
app: xmage
|
||||
ports:
|
||||
- name: bridge
|
||||
port: 17172
|
||||
targetPort: bridge
|
||||
- name: health
|
||||
port: 17173
|
||||
targetPort: health
|
||||
@@ -0,0 +1,20 @@
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: playmat
|
||||
namespace: argocd
|
||||
spec:
|
||||
project: default
|
||||
source:
|
||||
repoURL: https://git.aleshym.co/funman300/k3s-homelab.git
|
||||
targetRevision: main
|
||||
path: apps/playmat
|
||||
destination:
|
||||
server: https://kubernetes.default.svc
|
||||
namespace: playmat
|
||||
syncPolicy:
|
||||
automated:
|
||||
prune: true
|
||||
selfHeal: true
|
||||
syncOptions:
|
||||
- CreateNamespace=true
|
||||
Reference in New Issue
Block a user