From ccb23dee0de169d4602dc96f7cbfe43bd0ad6afa Mon Sep 17 00:00:00 2001 From: Joseph Hanson Date: Thu, 28 Mar 2024 16:14:47 -0500 Subject: [PATCH] Deploy immich db. --- .../apps/media/immich/app/kustomization.yaml | 17 ++++ .../media/immich/app/postgresCluster.yaml | 89 +++++++++++++++++++ .../apps/media/immich/app/resources/init.sql | 1 + kubernetes/apps/media/immich/ks.yaml | 30 +++++++ kubernetes/apps/media/kustomization.yaml | 9 ++ kubernetes/apps/media/namespace.yaml | 9 ++ 6 files changed, 155 insertions(+) create mode 100644 kubernetes/apps/media/immich/app/kustomization.yaml create mode 100644 kubernetes/apps/media/immich/app/postgresCluster.yaml create mode 100644 kubernetes/apps/media/immich/app/resources/init.sql create mode 100644 kubernetes/apps/media/immich/ks.yaml create mode 100644 kubernetes/apps/media/kustomization.yaml create mode 100644 kubernetes/apps/media/namespace.yaml diff --git a/kubernetes/apps/media/immich/app/kustomization.yaml b/kubernetes/apps/media/immich/app/kustomization.yaml new file mode 100644 index 00000000..9677e165 --- /dev/null +++ b/kubernetes/apps/media/immich/app/kustomization.yaml @@ -0,0 +1,17 @@ +--- +# yaml-language-server: $schema=https://json.schemastore.org/kustomization +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + # - ./externalsecret.yaml + - ./postgresCluster.yaml + # - ./pvc.yaml + # - ./helmrelease.yaml +configMapGenerator: + - name: immich-databse-init-sql + files: + - init.sql=./resources/init.sql +generatorOptions: + disableNameSuffixHash: true + annotations: + kustomize.toolkit.fluxcd.io/substitute: disabled diff --git a/kubernetes/apps/media/immich/app/postgresCluster.yaml b/kubernetes/apps/media/immich/app/postgresCluster.yaml new file mode 100644 index 00000000..fc3f2bf2 --- /dev/null +++ b/kubernetes/apps/media/immich/app/postgresCluster.yaml @@ -0,0 +1,89 @@ +--- +# yaml-language-server: $schema=https://ks.hsn.dev/postgres-operator.crunchydata.com/postgrescluster_v1beta1.json +apiVersion: postgres-operator.crunchydata.com/v1beta1 +kind: PostgresCluster +metadata: + name: &name "${APP}" +spec: + postgresVersion: 16 + # dataSource: + # pgbackrest: + # stanza: db + # configuration: + # - secret: + # name: pgo-s3-creds + # global: + # repo1-path: "/${APP}/repo1" + # repo1-s3-uri-style: path + # repo: + # name: repo1 + # s3: + # bucket: "crunchy-postgres" + # endpoint: "s3.hsn.dev" + # region: "us-east-1" + patroni: + dynamicConfiguration: + synchronous_mode: true + postgresql: + synchronous_commit: "on" + pg_hba: + - hostnossl all all 10.244.0.0/16 md5 + - hostssl all all all md5 + databaseInitSQL: + name: immich-databse-init-sql + key: init.sql + instances: + - name: postgres + metadata: + labels: + app.kubernetes.io/name: pgo-${APP} + replicas: 2 + dataVolumeClaimSpec: + storageClassName: openebs-hostpath + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 5Gi + topologySpreadConstraints: + - maxSkew: 1 + topologyKey: "kubernetes.io/hostname" + whenUnsatisfiable: "DoNotSchedule" + labelSelector: + matchLabels: + postgres-operator.crunchydata.com/cluster: ${APP} + postgres-operator.crunchydata.com/data: postgres + users: + - name: "immich" + databases: + - "immich" + options: "SUPERUSER" + password: + type: AlphaNumeric + backups: + pgbackrest: + configuration: + - secret: + name: pgo-s3-creds + global: + archive-push-queue-max: 4GiB + repo1-retention-full: "14" + repo1-retention-full-type: time + repo1-path: "/${APP}/repo1" + repo1-s3-uri-style: path + manual: + repoName: repo1 + options: + - --type=full + metadata: + labels: + app.kubernetes.io/name: pgo-${APP}-backup + repos: + - name: repo1 + schedules: + full: "0 1 * * 0" + differential: "0 1 * * 1-6" + s3: + bucket: "crunchy-postgres" + endpoint: "s3.hsn.dev" + region: "us-east-1" diff --git a/kubernetes/apps/media/immich/app/resources/init.sql b/kubernetes/apps/media/immich/app/resources/init.sql new file mode 100644 index 00000000..ffa2e58c --- /dev/null +++ b/kubernetes/apps/media/immich/app/resources/init.sql @@ -0,0 +1 @@ +CREATE EXTENSION vector; \ No newline at end of file diff --git a/kubernetes/apps/media/immich/ks.yaml b/kubernetes/apps/media/immich/ks.yaml new file mode 100644 index 00000000..61788fa7 --- /dev/null +++ b/kubernetes/apps/media/immich/ks.yaml @@ -0,0 +1,30 @@ +--- +# yaml-language-server: $schema=https://ks.hsn.dev/kustomize.toolkit.fluxcd.io/kustomization_v1.json +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: &app immich + namespace: flux-system +spec: + targetNamespace: media + commonMetadata: + labels: + app.kubernetes.io/name: *app + dependsOn: + - name: crunchy-postgres-operator + - name: external-secrets-stores + - name: dragonfly + path: ./kubernetes/apps/media/immich/app + prune: true + sourceRef: + kind: GitRepository + name: homelab + wait: false + interval: 30m + retryInterval: 1m + timeout: 5m + postBuild: + substitute: + APP: *app + DB_NAME: immich + DB_USER: immich diff --git a/kubernetes/apps/media/kustomization.yaml b/kubernetes/apps/media/kustomization.yaml new file mode 100644 index 00000000..6df031b5 --- /dev/null +++ b/kubernetes/apps/media/kustomization.yaml @@ -0,0 +1,9 @@ +--- +# yaml-language-server: $schema=https://json.schemastore.org/kustomization.json +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + # Pre Flux-Kustomizations + - ./namespace.yaml + # Flux-Kustomizations + - ./immich/ks.yaml diff --git a/kubernetes/apps/media/namespace.yaml b/kubernetes/apps/media/namespace.yaml new file mode 100644 index 00000000..8ff6d8c3 --- /dev/null +++ b/kubernetes/apps/media/namespace.yaml @@ -0,0 +1,9 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: media + labels: + kustomize.toolkit.fluxcd.io/prune: disabled + volsync.backube/privileged-movers: "true" + pgo-enabled-hsn.dev: "true"