{{ range $k, $v := .Values.apps }} {{ if $v.enabled }} --- 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 }} {{ if $v.exposedPorts }} --- kind: Service apiVersion: v1 metadata: name: {{ $k }}-exposed-ports spec: selector: app: {{ $k }} type: LoadBalancer ports: {{- range $exPort, $inPort := $v.exposedPorts }} - port: {{ $exPort }} targetPort: {{ $inPort }} protocol: TCP {{ end }} {{ end }} --- apiVersion: apps/v1 kind: Deployment metadata: name: {{$k}} spec: selector: matchLabels: app: {{$k}} replicas: 1 revisionHistoryLimit: 2 template: metadata: labels: app: {{$k}} spec: affinity: nodeAffinity: preferredDuringSchedulingIgnoredDuringExecution: - weight: 1 preference: matchExpressions: - key: homelab/capacity operator: In values: {{ $v.capacity | toYaml | nindent 20 }} volumes: {{ ($v.volumes | default list) | toJson }} containers: - name: {{$k}} image: "{{ $v.repo }}:{{ $v.tag }}" imagePullPolicy: Always resources: {{- $v.podResources | toYaml | nindent 12 }} 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 }} {{ 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 }} {{ end }} startupProbe: tcpSocket: port: tcp-web initialDelaySeconds: 10 failureThreshold: 10 timeoutSeconds: 30 envFrom: {{ ($v.envFrom | default list) | toJson }} env: {{ ($v.env | default list) | toJson }} volumeMounts: {{ ($v.volumeMounts | default list) | toJson }} {{ end }} {{ end }}