diff --git a/k8s/apps/videohosting/templates/sts-db.yaml b/k8s/apps/videohosting/templates/sts-db.yaml new file mode 100644 index 0000000..7945aea --- /dev/null +++ b/k8s/apps/videohosting/templates/sts-db.yaml @@ -0,0 +1,125 @@ +--- +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/templates/sts-linuxservices.yaml b/k8s/apps/videohosting/templates/sts-linuxservices.yaml index a882096..4ec13fd 100644 --- a/k8s/apps/videohosting/templates/sts-linuxservices.yaml +++ b/k8s/apps/videohosting/templates/sts-linuxservices.yaml @@ -1,4 +1,4 @@ -{{ range $k, $v := .Values.linuxserverServices }} +{{ range $k, $v := .Values.services }} --- apiVersion: v1 kind: ConfigMap @@ -48,6 +48,8 @@ spec: replicas: 1 revisionHistoryLimit: 2 updateStrategy: + rollingUpdate: + partition: 0 type: RollingUpdate volumeClaimTemplates: - metadata: @@ -101,6 +103,32 @@ spec: mountPath: /config - name: torrents mountPath: /torrents + {{- if $v.health.liveness }} + livenessProbe: + httpGet: + path: {{$v.health.liveness}} + port: http + scheme: HTTP + initialDelaySeconds: 10 + failureThreshold: 10 + timeoutSeconds: 30 + {{ end -}} + {{- if $v.health.readiness }} + readinessProbe: + httpGet: + path: {{$v.health.readiness}} + port: http + scheme: HTTP + initialDelaySeconds: 10 + failureThreshold: 10 + timeoutSeconds: 30 + {{ end }} + startupProbe: + tcpSocket: + port: http + initialDelaySeconds: 10 + failureThreshold: 10 + timeoutSeconds: 30 volumes: - name: torrents nfs: diff --git a/k8s/apps/videohosting/templates/sts-plex.yaml b/k8s/apps/videohosting/templates/sts-plex.yaml index 1bbd6e5..7bf827f 100644 --- a/k8s/apps/videohosting/templates/sts-plex.yaml +++ b/k8s/apps/videohosting/templates/sts-plex.yaml @@ -135,13 +135,8 @@ spec: - containerPort: 32414 protocol: UDP - containerPort: 32469 - resources: - limits: - cpu: 8 - memory: "10Gi" - requests: - cpu: 4 - memory: "4Gi" + resources: + {{- .Values.plex.resources | toYaml | nindent 12 }} volumeMounts: - name: config mountPath: /config @@ -155,6 +150,12 @@ spec: subPath: movies - name: family-videos mountPath: /family-videos + startupProbe: + tcpSocket: + port: plex + initialDelaySeconds: 10 + failureThreshold: 10 + timeoutSeconds: 30 volumes: - name: torrents nfs: diff --git a/k8s/apps/videohosting/values.yaml b/k8s/apps/videohosting/values.yaml index 3dd632f..af72327 100644 --- a/k8s/apps/videohosting/values.yaml +++ b/k8s/apps/videohosting/values.yaml @@ -8,8 +8,27 @@ global: plex: repo: "plexinc/pms-docker" tag: "latest" + resources: + limits: + cpu: 8 + memory: "10Gi" + requests: + cpu: 4 + memory: "4Gi" -linuxserverServices: +database: + repo: postgres + tag: 16.0-alpine + pgdata: /var/lib/postgresql/data + resources: + limits: + cpu: 500m + memory: "800Mi" + requests: + cpu: 250m + memory: "256Mi" + +services: sonarr: repo: lscr.io/linuxserver/sonarr tag: "latest" @@ -25,6 +44,9 @@ linuxserverServices: storage: 10Gi limits: storage: 100Gi + health: + readiness: "/ping" + liveness: "/ping" ports: tcp: web: 8989 @@ -38,6 +60,9 @@ linuxserverServices: requests: cpu: 250m memory: "500M" + health: + readiness: "/ping" + liveness: "/ping" configVolumesResources: requests: storage: 10Gi @@ -58,6 +83,9 @@ linuxserverServices: requests: cpu: 250m memory: "500M" + health: + readiness: "/health" + liveness: "/health" configVolumesResources: requests: storage: 10Gi @@ -82,6 +110,7 @@ linuxserverServices: requests: cpu: 800m memory: "4Gi" + health: {} configVolumesResources: requests: storage: 10Gi diff --git a/k8s/argoapps/apps-values/ingresses.yaml b/k8s/argoapps/apps-values/ingresses.yaml index f687c44..4825d95 100644 --- a/k8s/argoapps/apps-values/ingresses.yaml +++ b/k8s/argoapps/apps-values/ingresses.yaml @@ -74,7 +74,7 @@ services: port: 3000 group: "Core" # vh services - {{- range $k, $v := .Values.videohosting.linuxserverServices }} + {{- range $k, $v := .Values.videohosting.services }} - prefix: "{{ $k }}.vh" service: "{{ $k }}" namespace: "apps-videohosting" diff --git a/k8s/argoapps/values.yaml b/k8s/argoapps/values.yaml index a7a3829..7feff12 100644 --- a/k8s/argoapps/values.yaml +++ b/k8s/argoapps/values.yaml @@ -26,7 +26,7 @@ global: host: 192.168.0.23 videohosting: - linuxserverServices: + services: sonarr: ports: tcp: