Files
homelab/k8s/apps/basic-webapps/templates/sts-services.yaml
T
Ariel Sosnovsky 5b6d0c9e71 Big Update
- basic webapps
- no more cpu limits
2023-12-21 10:16:55 -05:00

100 lines
2.6 KiB
YAML

{{ range $k, $v := .Values.services }}
---
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: Deployment
metadata:
name: {{$k}}
spec:
selector:
matchLabels:
app: {{$k}}
replicas: 1
revisionHistoryLimit: 2
updateStrategy:
rollingUpdate:
partition: 1
type: RollingUpdate
template:
metadata:
labels:
app: {{$k}}
spec:
affinity:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
preference:
matchExpressions:
- key: homelab/capacity
operator: In
values:
{{ $v.capacity | toYaml | nindent 20 }}
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.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 }}