From b919bd3d22d9b14cba5a64340720ef35aed5fa14 Mon Sep 17 00:00:00 2001
From: Sheogorath <sheogorath@shivering-isles.com>
Date: Mon, 26 Feb 2024 20:28:54 +0100
Subject: [PATCH] refactor(jellyfin): Rework structure to make kustomize more
 universal

---
 apps/base/jellyfin/amd-gpu/kustomization.yaml     | 15 +++++++++++++++
 apps/base/jellyfin/deployment.yaml                |  2 --
 .../jellyfin/jellyfin-pdb-mgr/README.md           |  0
 .../jellyfin/jellyfin-pdb-mgr/deployment.yaml     |  0
 .../jellyfin/jellyfin-pdb-mgr/kustomization.yaml  |  0
 .../jellyfin-pdb-mgr/poddisruptionbudget.yaml     |  0
 .../jellyfin/jellyfin-pdb-mgr/role.yaml           |  0
 apps/base/jellyfin/kustomization.yaml             |  8 --------
 .../jellyfin/allow-from-ingress.patch.yaml        |  0
 .../jellyfin/allow-to-public-web.patch.yaml       |  0
 apps/k8s01/jellyfin/kustomization.yaml            |  9 ++++++++-
 11 files changed, 23 insertions(+), 11 deletions(-)
 create mode 100644 apps/base/jellyfin/amd-gpu/kustomization.yaml
 rename apps/{k8s01 => base}/jellyfin/jellyfin-pdb-mgr/README.md (100%)
 rename apps/{k8s01 => base}/jellyfin/jellyfin-pdb-mgr/deployment.yaml (100%)
 rename apps/{k8s01 => base}/jellyfin/jellyfin-pdb-mgr/kustomization.yaml (100%)
 rename apps/{k8s01 => base}/jellyfin/jellyfin-pdb-mgr/poddisruptionbudget.yaml (100%)
 rename apps/{k8s01 => base}/jellyfin/jellyfin-pdb-mgr/role.yaml (100%)
 rename apps/{base => k8s01}/jellyfin/allow-from-ingress.patch.yaml (100%)
 rename apps/{base => k8s01}/jellyfin/allow-to-public-web.patch.yaml (100%)

diff --git a/apps/base/jellyfin/amd-gpu/kustomization.yaml b/apps/base/jellyfin/amd-gpu/kustomization.yaml
new file mode 100644
index 000000000..63f8bee75
--- /dev/null
+++ b/apps/base/jellyfin/amd-gpu/kustomization.yaml
@@ -0,0 +1,15 @@
+apiVersion: kustomize.config.k8s.io/v1alpha1
+kind: Component
+
+patches:
+  - patch: |-
+      - op: add
+        path: /spec/template/spec/containers/0/resources/requests/amd.com~1gpu
+        value: 1
+      - op: add
+        path: /spec/template/spec/containers/0/resources/limits/amd.com~1gpu
+        value: 1
+    target:
+      group: apps
+      version: v1
+      kind: Deployment
\ No newline at end of file
diff --git a/apps/base/jellyfin/deployment.yaml b/apps/base/jellyfin/deployment.yaml
index ea42f570e..07246e800 100644
--- a/apps/base/jellyfin/deployment.yaml
+++ b/apps/base/jellyfin/deployment.yaml
@@ -54,11 +54,9 @@ spec:
           name: jellyfin-cache
         resources:
           requests:
-            amd.com/gpu: 1
             memory: 2Gi
             cpu: 100m
           limits:
-            amd.com/gpu: 1
             memory: 3.5Gi
             cpu: "4"
         securityContext:
diff --git a/apps/k8s01/jellyfin/jellyfin-pdb-mgr/README.md b/apps/base/jellyfin/jellyfin-pdb-mgr/README.md
similarity index 100%
rename from apps/k8s01/jellyfin/jellyfin-pdb-mgr/README.md
rename to apps/base/jellyfin/jellyfin-pdb-mgr/README.md
diff --git a/apps/k8s01/jellyfin/jellyfin-pdb-mgr/deployment.yaml b/apps/base/jellyfin/jellyfin-pdb-mgr/deployment.yaml
similarity index 100%
rename from apps/k8s01/jellyfin/jellyfin-pdb-mgr/deployment.yaml
rename to apps/base/jellyfin/jellyfin-pdb-mgr/deployment.yaml
diff --git a/apps/k8s01/jellyfin/jellyfin-pdb-mgr/kustomization.yaml b/apps/base/jellyfin/jellyfin-pdb-mgr/kustomization.yaml
similarity index 100%
rename from apps/k8s01/jellyfin/jellyfin-pdb-mgr/kustomization.yaml
rename to apps/base/jellyfin/jellyfin-pdb-mgr/kustomization.yaml
diff --git a/apps/k8s01/jellyfin/jellyfin-pdb-mgr/poddisruptionbudget.yaml b/apps/base/jellyfin/jellyfin-pdb-mgr/poddisruptionbudget.yaml
similarity index 100%
rename from apps/k8s01/jellyfin/jellyfin-pdb-mgr/poddisruptionbudget.yaml
rename to apps/base/jellyfin/jellyfin-pdb-mgr/poddisruptionbudget.yaml
diff --git a/apps/k8s01/jellyfin/jellyfin-pdb-mgr/role.yaml b/apps/base/jellyfin/jellyfin-pdb-mgr/role.yaml
similarity index 100%
rename from apps/k8s01/jellyfin/jellyfin-pdb-mgr/role.yaml
rename to apps/base/jellyfin/jellyfin-pdb-mgr/role.yaml
diff --git a/apps/base/jellyfin/kustomization.yaml b/apps/base/jellyfin/kustomization.yaml
index e9dcce4f7..9992ea96a 100644
--- a/apps/base/jellyfin/kustomization.yaml
+++ b/apps/base/jellyfin/kustomization.yaml
@@ -8,11 +8,3 @@ resources:
   - pvc.yaml
   - service.yaml
   - serviceaccount.yaml
-  - ../../../shared/networkpolicies/deny-by-default-ingress.yaml
-  - ../../../shared/networkpolicies/deny-by-default-egress.yaml
-  - ../../../shared/networkpolicies/allow-from-ingress.yaml
-  - ../../../shared/networkpolicies/allow-to-public-web.yaml
-
-patches:
-  - path: allow-from-ingress.patch.yaml
-  - path: allow-to-public-web.patch.yaml
diff --git a/apps/base/jellyfin/allow-from-ingress.patch.yaml b/apps/k8s01/jellyfin/allow-from-ingress.patch.yaml
similarity index 100%
rename from apps/base/jellyfin/allow-from-ingress.patch.yaml
rename to apps/k8s01/jellyfin/allow-from-ingress.patch.yaml
diff --git a/apps/base/jellyfin/allow-to-public-web.patch.yaml b/apps/k8s01/jellyfin/allow-to-public-web.patch.yaml
similarity index 100%
rename from apps/base/jellyfin/allow-to-public-web.patch.yaml
rename to apps/k8s01/jellyfin/allow-to-public-web.patch.yaml
diff --git a/apps/k8s01/jellyfin/kustomization.yaml b/apps/k8s01/jellyfin/kustomization.yaml
index df4093d69..83a20de74 100644
--- a/apps/k8s01/jellyfin/kustomization.yaml
+++ b/apps/k8s01/jellyfin/kustomization.yaml
@@ -15,6 +15,10 @@ resources:
   - slo.yaml
   - jellyfin-token.yaml
   - ../../../shared/resourcequotas/default.yaml
+  - ../../../shared/networkpolicies/deny-by-default-ingress.yaml
+  - ../../../shared/networkpolicies/deny-by-default-egress.yaml
+  - ../../../shared/networkpolicies/allow-from-ingress.yaml
+  - ../../../shared/networkpolicies/allow-to-public-web.yaml
 
 patches:
   - path: deployment.yaml
@@ -23,6 +27,9 @@ patches:
       group: apps
       version: v1
       name: jellyfin
+  - path: allow-from-ingress.patch.yaml
+  - path: allow-to-public-web.patch.yaml
 
 components:
-  - jellyfin-pdb-mgr
\ No newline at end of file
+  - ../../base/jellyfin/amd-gpu
+  - ../../base/jellyfin/jellyfin-pdb-mgr
\ No newline at end of file
-- 
GitLab