{{ range $k, $v := .Values.services }} {{ if (not $v.disabled)}} --- apiVersion: v1 kind: ConfigMap metadata: name: {{$k}}-envs data: PUID: "1000" PGID: "1000" TZ: {{ $.Values.global.timezone }} {{- range $envName, $envValue := ($v.envVars | default (dict )) }} {{ $envName }}: "{{tpl $envValue $}}" {{ end }} {{ if (not $v.disableSVC) }} --- kind: Service apiVersion: v1 metadata: name: {{ $k }} spec: selector: app: {{ $k }} type: ClusterIP ports: {{ range $portName, $portValue := $v.ports.tcp }} - port: {{ $portValue }} targetPort: {{ $portValue }} name: "{{ $portName }}" protocol: TCP {{ end }} {{- if $v.ports.udp -}} {{ range $portName, $portValue := $v.ports.udp }} - port: {{ $portValue }} targetPort: {{ $portValue }} name: "{{ $portName }}-udp" protocol: UDP {{ end }} {{- end }} {{ end }} {{- $kind := $v.kind | default "StatefulSet" -}} --- apiVersion: apps/v1 kind: {{ $kind }} metadata: name: {{$k}} spec: selector: matchLabels: app: {{$k}} replicas: 1 revisionHistoryLimit: 2 {{ if (eq $kind "StatefulSet")}} updateStrategy: rollingUpdate: partition: 0 type: RollingUpdate volumeClaimTemplates: - metadata: finalizers: - kubernetes.io/pvc-protection name: config spec: storageClassName: {{ $.Values.global.nfs.storageClass }} accessModes: - ReadWriteOnce resources: {{- $v.configVolumesResources | toYaml | nindent 10 }} {{ end }} template: metadata: labels: app: {{$k}} annotations: checksum/config-env: "{{ $v.envVars | toYaml | sha256sum }}" spec: affinity: nodeAffinity: preferredDuringSchedulingIgnoredDuringExecution: - weight: 1 preference: matchExpressions: - key: homelab/capacity operator: In values: - med - low containers: - name: {{$k}} image: "{{ $v.repo }}:{{ $v.tag }}" imagePullPolicy: Always envFrom: - configMapRef: name: {{$k}}-envs {{ range $envFrom := ($v.envFrom | default list) }} - {{ $envFrom | toJson }} {{ end }} resources: {{- $v.podResources | toYaml | nindent 12 }} {{ if $v.ports}} ports: {{ range $portName, $portValue := $v.ports.tcp }} - containerPort: {{ $portValue }} protocol: TCP name: "tcp-{{ $portName }}" {{ end }} {{- if $v.ports.udp -}} {{ range $portName, $portValue := $v.ports.udp }} - containerPort: {{ $portValue }} protocol: UDP {{ end }} {{ end }} {{ end }} volumeMounts: {{ if (eq $kind "StatefulSet")}} - name: config mountPath: /config {{ end }} - name: torrents mountPath: /torrents {{- if $v.health }} {{- if $v.health.liveness }} livenessProbe: httpGet: path: {{$v.health.liveness}} port: tcp-web scheme: HTTP initialDelaySeconds: 10 failureThreshold: 10 timeoutSeconds: 30 {{ end -}} {{- if $v.health.readiness }} readinessProbe: httpGet: path: {{$v.health.readiness}} port: tcp-web scheme: HTTP initialDelaySeconds: 10 failureThreshold: 10 timeoutSeconds: 30 {{ end }} startupProbe: tcpSocket: port: tcp-web initialDelaySeconds: 10 failureThreshold: 10 timeoutSeconds: 30 {{ end }} volumes: - name: torrents nfs: server: "{{ $.Values.global.nfs.server }}" path: "{{ $.Values.global.nfs.additionalShares.torrents }}" readOnly: false {{ end }} {{ end }}