Files
homelab/k8s/apps/videohosting/templates/sts-linuxservices.yaml
T
2023-11-09 13:40:36 -05:00

140 lines
3.6 KiB
YAML

{{ range $k, $v := .Values.services }}
---
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 }}: "{{$envValue}}"
{{ end }}
---
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 }}
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{$k}}
spec:
selector:
matchLabels:
app: {{$k}}
replicas: 1
revisionHistoryLimit: 2
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 }}
template:
metadata:
labels:
app: {{$k}}
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
resources:
{{- $v.podResources | toYaml | nindent 12 }}
ports:
{{ range $portName, $portValue := $v.ports.tcp }}
- containerPort: {{ $portValue }}
protocol: TCP
name: {{$portName}}
{{ end }}
{{- if $v.ports.udp -}}
{{ range $portName, $portValue := $v.ports.udp }}
- containerPort: {{ $portValue }}
protocol: UDP
name: {{$portName}}
{{ end }}
{{ end }}
volumeMounts:
- name: config
mountPath: /config
- name: torrents
mountPath: /torrents
{{- if $v.health.liveness }}
livenessProbe:
httpGet:
path: {{$v.health.liveness}}
port: web
scheme: HTTP
initialDelaySeconds: 10
failureThreshold: 10
timeoutSeconds: 30
{{ end -}}
{{- if $v.health.readiness }}
readinessProbe:
httpGet:
path: {{$v.health.readiness}}
port: web
scheme: HTTP
initialDelaySeconds: 10
failureThreshold: 10
timeoutSeconds: 30
{{ end }}
startupProbe:
tcpSocket:
port: web
initialDelaySeconds: 10
failureThreshold: 10
timeoutSeconds: 30
volumes:
- name: torrents
nfs:
server: "{{ $.Values.global.nfs.server }}"
path: "{{ $.Values.global.nfs.additionalShares.torrents }}"
readOnly: false
{{ end }}