fix: add component label to FastAPI deployment and service for proper pod isolation

This commit is contained in:
dvirlabs 2026-02-16 03:39:12 +02:00
parent 8f088e1546
commit 645a316e5f
3 changed files with 14 additions and 4 deletions

View File

@ -25,3 +25,12 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- define "open-meteo-service.grafanaFullname" -}} {{- define "open-meteo-service.grafanaFullname" -}}
{{- printf "%s-grafana" (include "open-meteo-service.fullname" .) | trunc 63 | trimSuffix "-" -}} {{- printf "%s-grafana" (include "open-meteo-service.fullname" .) | trunc 63 | trimSuffix "-" -}}
{{- end -}} {{- end -}}
{{/*
Selector labels for API component
*/}}
{{- define "open-meteo-service.selectorLabels" -}}
app.kubernetes.io/name: {{ include "open-meteo-service.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: api
{{- end -}}

View File

@ -4,16 +4,17 @@ metadata:
name: {{ include "open-meteo-service.fullname" . }} name: {{ include "open-meteo-service.fullname" . }}
labels: labels:
{{- include "open-meteo-service.labels" . | nindent 4 }} {{- include "open-meteo-service.labels" . | nindent 4 }}
app.kubernetes.io/component: api
spec: spec:
replicas: {{ .Values.replicaCount }} replicas: {{ .Values.replicaCount }}
selector: selector:
matchLabels: matchLabels:
app.kubernetes.io/name: {{ include "open-meteo-service.name" . }} {{- include "open-meteo-service.selectorLabels" . | nindent 6 }}
app.kubernetes.io/instance: {{ .Release.Name }}
template: template:
metadata: metadata:
labels: labels:
{{- include "open-meteo-service.labels" . | nindent 8 }} {{- include "open-meteo-service.labels" . | nindent 8 }}
app.kubernetes.io/component: api
annotations: annotations:
{{- toYaml .Values.podAnnotations | nindent 8 }} {{- toYaml .Values.podAnnotations | nindent 8 }}
spec: spec:

View File

@ -4,6 +4,7 @@ metadata:
name: {{ include "open-meteo-service.fullname" . }} name: {{ include "open-meteo-service.fullname" . }}
labels: labels:
{{- include "open-meteo-service.labels" . | nindent 4 }} {{- include "open-meteo-service.labels" . | nindent 4 }}
app.kubernetes.io/component: api
spec: spec:
type: {{ .Values.service.type }} type: {{ .Values.service.type }}
ports: ports:
@ -12,5 +13,4 @@ spec:
protocol: TCP protocol: TCP
name: http name: http
selector: selector:
app.kubernetes.io/name: {{ include "open-meteo-service.name" . }} {{- include "open-meteo-service.selectorLabels" . | nindent 4 }}
app.kubernetes.io/instance: {{ .Release.Name }}