diff --git a/k8s/apps/videohosting/templates/sts-arrs.yaml b/k8s/apps/videohosting/templates/sts-arrs.yaml index 4b22a88..36f609e 100644 --- a/k8s/apps/videohosting/templates/sts-arrs.yaml +++ b/k8s/apps/videohosting/templates/sts-arrs.yaml @@ -28,6 +28,8 @@ spec: template: engineVersion: v2 data: + CONNECTION_STRING: |- + {{ `postgresql://{{.username}}:{{.password}}@{{.host}}:{{.port}}/` }}{{$k}} config.xml: |- info @@ -36,7 +38,7 @@ spec: 443 * - 258c8ca51bc54161889705caaf32a824 + {{ `{{.password}}` }} External DisabledForLocalAddresses Docker @@ -85,6 +87,7 @@ spec: - port: 443 targetPort: 443 name: "https" + --- apiVersion: apps/v1 kind: StatefulSet @@ -186,4 +189,43 @@ spec: server: "{{ $.Values.global.nfs.server }}" path: "{{ $.Values.global.nfs.additionalShares.torrents }}" readOnly: false +{{ if $v.migrateDbFromSqllite.enabled }} +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: "migrate-{{$k}}" + namespace: "{{ .Release.Namespace }}" + annotations: + helm.sh/hook: pre-install + helm.sh/hook-delete-policy: hook-succeeded +spec: + template: + spec: + containers: + - name: migration + image: "ghcr.io/roxedus/pgloader" + command: + - --with "quote identifiers" + - --with "data only" + - /data/{{$k}}.db + - "${CONNECTION_STRING}" + volumeMounts: + - mountPath: /app + name: tffiles + env: + - name: CONNECTION_STRING + valueFrom: + secretKeyRef: + name: "{{$k}}-config" + key: "CONNECTION_STRING" + volumeMounts: + - mountPath: "/data" + name: data + volumes: + - name: data + persistentVolumeClaim: + claimName: "{{ $v.migrateDbFromSqllite.claimName }}" + restartPolicy: Never + backoffLimit: 2 {{ end }} \ No newline at end of file diff --git a/k8s/apps/videohosting/templates/sts-db.yaml b/k8s/apps/videohosting/templates/sts-db.yaml deleted file mode 100644 index 7945aea..0000000 --- a/k8s/apps/videohosting/templates/sts-db.yaml +++ /dev/null @@ -1,125 +0,0 @@ ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: db-envs -data: - PGDATA: {{ .Values.database.pgdata }} - ---- -apiVersion: v1 -kind: Secret -type: Opaque -metadata: - name: db-cred - annotations: - secret-generator.v1.mittwald.de/autogenerate: "POSTGRES_PASSWORD" -stringData: - POSTGRES_USER: "postgres" - ---- -kind: Service -apiVersion: v1 -metadata: - name: db -spec: - selector: - app: db - type: ClusterIP - ports: - - port: 5432 - targetPort: 5432 - name: "pg" - ---- -apiVersion: apps/v1 -kind: StatefulSet -metadata: - name: db -spec: - selector: - matchLabels: - app: db - replicas: 1 - revisionHistoryLimit: 2 - updateStrategy: - type: RollingUpdate - volumeClaimTemplates: - - metadata: - finalizers: - - kubernetes.io/pvc-protection - name: data - spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 10Gi - limits: - storage: 100Gi - template: - metadata: - labels: - app: db - spec: - affinity: - nodeAffinity: - preferredDuringSchedulingIgnoredDuringExecution: - - weight: 1 - preference: - matchExpressions: - - key: homelab/capacity - operator: In - values: - - low - - med - containers: - - name: db - image: "{{ .Values.database.repo }}:{{ .Values.database.tag }}" - imagePullPolicy: "Always" - envFrom: - - configMapRef: - name: db-envs - - secretRef: - name: db-cred - ports: - - containerPort: 5432 - name: db - resources: - {{- .Values.database.resources | toYaml | nindent 12 }} - volumeMounts: - - name: data - mountPath: {{ .Values.database.pgdata }} - startupProbe: - tcpSocket: - port: db - initialDelaySeconds: 10 - failureThreshold: 10 - timeoutSeconds: 30 - livenessProbe: - exec: - command: - - /bin/sh - - '-c' - - exec pg_isready -U "postgres" -h 127.0.0.1 -p 5432 - failureThreshold: 6 - initialDelaySeconds: 30 - periodSeconds: 10 - successThreshold: 1 - timeoutSeconds: 5 - readinessProbe: - exec: - command: - - /bin/sh - - '-c' - - '-e' - - > - exec pg_isready -U "postgres" -h 127.0.0.1 -p 5432 - - [ -f /opt/bitnami/postgresql/tmp/.initialized ] || [ -f - /bitnami/postgresql/.initialized ] - failureThreshold: 6 - initialDelaySeconds: 5 - periodSeconds: 10 - successThreshold: 1 - timeoutSeconds: 5 \ No newline at end of file diff --git a/k8s/apps/videohosting/values.yaml b/k8s/apps/videohosting/values.yaml index 491c9d8..13928a7 100644 --- a/k8s/apps/videohosting/values.yaml +++ b/k8s/apps/videohosting/values.yaml @@ -16,22 +16,13 @@ plex: cpu: 4 memory: "4Gi" -database: - repo: postgres - tag: 16.0-alpine - pgdata: /var/lib/postgresql/data - resources: - limits: - cpu: 500m - memory: "256Mi" - requests: - cpu: 250m - memory: "256Mi" - arrs: sonarr: repo: lscr.io/linuxserver/sonarr tag: "latest" + migrateDbFromSqllite: + enabled: false + claimName: changeme podResources: limits: cpu: 2 @@ -48,6 +39,9 @@ arrs: radarr: repo: lscr.io/linuxserver/radarr tag: "latest" + migrateDbFromSqllite: + enabled: false + claimName: changeme podResources: limits: cpu: 2