From 9ea515e140f9c3a7a90c7b97c8bf8744525e8fed Mon Sep 17 00:00:00 2001
From: Remy Moll <me@moll.re>
Date: Sun, 4 Feb 2024 00:52:25 +0100
Subject: [PATCH] fixes

---
 deployment/kustomization.yaml        |  6 ++++--
 deployment/nginx.deployment.yaml     | 12 ++++++------
 deployment/nginx.ingress.yaml        |  8 ++++----
 deployment/nginx.service.yaml        |  4 ++--
 deployment/quartz-build.cronjob.yaml | 22 ++++++++++++----------
 5 files changed, 28 insertions(+), 24 deletions(-)

diff --git a/deployment/kustomization.yaml b/deployment/kustomization.yaml
index 15b94a5..13865be 100644
--- a/deployment/kustomization.yaml
+++ b/deployment/kustomization.yaml
@@ -8,7 +8,7 @@ resources:
   - nginx.deployment.yaml
   - nginx.service.yaml
   - nginx-auth.sealedsecret.yaml
-  # - nginx.ingress.yaml
+  - nginx.ingress.yaml
   - quartz-build.cronjob.yaml
   - s3-credentials.sealedsecret.yaml
 
@@ -28,4 +28,6 @@ images:
     newName: public.ecr.aws/aws-cli/aws-cli
     newTag: latest
 
-
+  - name: nginx
+    newName: nginx
+    newTag: "1.25"
diff --git a/deployment/nginx.deployment.yaml b/deployment/nginx.deployment.yaml
index 6cfa49b..b4d4199 100644
--- a/deployment/nginx.deployment.yaml
+++ b/deployment/nginx.deployment.yaml
@@ -1,18 +1,18 @@
 apiVersion: apps/v1
 kind: Deployment
 metadata:
-  name: quartz-physics
+  name: quartz
 spec:
   selector:
     matchLabels:
-      app: quartz-physics
+      app: quartz
   template:
     metadata:
       labels:
-        app: quartz-physics
+        app: quartz
     spec:
       containers:
-      - name: quartz-physics
+      - name: quartz
         image: nginx
         resources:
           limits:
@@ -22,12 +22,12 @@ spec:
         - containerPort: 80
         volumeMounts:
         - mountPath: /usr/share/nginx/html
-          name: quartz-physics
+          name: quartz
         - mountPath: /etc/nginx/nginx.conf
           subPath: nginx.conf
           name: nginx
       volumes:
-      - name: quartz-physics
+      - name: quartz
         persistentVolumeClaim:
           claimName: quartz-nfs
       - name: nginx
diff --git a/deployment/nginx.ingress.yaml b/deployment/nginx.ingress.yaml
index fa62222..3f5e901 100644
--- a/deployment/nginx.ingress.yaml
+++ b/deployment/nginx.ingress.yaml
@@ -1,17 +1,17 @@
 apiVersion: traefik.containo.us/v1alpha1
 kind: IngressRoute
 metadata:
-  name: quartz-physics-ingress
+  name: quartz-ingress
 spec:
   entryPoints:
     - websecure
   routes:
     - match: Host(`physics.kluster.moll.re`)
       middlewares:
-        - name: quartz-physics-auth
+        - name: quartz-auth
       kind: Rule
       services:
-        - name: quartz-physics-web
+        - name: quartz-web
           port: 80
   tls:
     certResolver: default-tls
@@ -20,7 +20,7 @@ spec:
 apiVersion: traefik.containo.us/v1alpha1
 kind: Middleware
 metadata:
-  name: quartz-physics-auth
+  name: quartz-auth
 spec:
   basicAuth:
     secret: nginx-auth
diff --git a/deployment/nginx.service.yaml b/deployment/nginx.service.yaml
index faac3c6..0cf9694 100644
--- a/deployment/nginx.service.yaml
+++ b/deployment/nginx.service.yaml
@@ -1,10 +1,10 @@
 apiVersion: v1
 kind: Service
 metadata:
-  name: quartz-physics-web
+  name: quartz-web
 spec:
   selector:
-    app: quartz-physics
+    app: quartz
   ports:
     - protocol: TCP
       port: 80
diff --git a/deployment/quartz-build.cronjob.yaml b/deployment/quartz-build.cronjob.yaml
index 805d79f..7cfc043 100644
--- a/deployment/quartz-build.cronjob.yaml
+++ b/deployment/quartz-build.cronjob.yaml
@@ -27,7 +27,7 @@ spec:
             - name: S3_REGION
               value: us-west-1
             command: ["/bin/sh", "-c"]
-            args: ["aws --endpoint-url https://s3.kluster.moll.re s3 sync s3://$S3_BUCKET /config"]
+            args: ["aws --endpoint-url https://s3.kluster.moll.re s3 sync s3://$S3_BUCKET /vault"]
 
             volumeMounts:
               - name: vault
@@ -49,20 +49,22 @@ spec:
           - name: quartz-build
             image: node
             command: ["/bin/sh", "-c"]
-            args:
-              - cd /config &&
-              - ln -s /vault content
-              - npm ci &&
-              - npx quartz build &&
-              - rm -rfv /dist/* &&
-              - cp --verbose -r public/* /dist
-
+            args: 
+              - >-
+                cd /config &&
+                ln -s /vault content &&
+                npm ci &&
+                npx quartz build &&
+                rm -rfv /dist/* &&
+                cp --verbose -r /config/public/* /dist 
+            # can't just ln to the dist folder, because quartz deletes it before rebuilding
             volumeMounts:
             - name: vault
               mountPath: /vault
             - name: dist
               mountPath: /dist
-
+            - name: config
+              mountPath: /config
           restartPolicy: Never
 
           volumes: