App Labels¶
ohMyHelm kann automatisch ein app-Label zu Ihren Deployments und StatefulSets hinzufügen.
Übersicht¶
Das app-Label ist ein standardisiertes Kubernetes-Label, das häufig für:
- Service-Selektoren
- Pod-Affinität/Anti-Affinität
- Monitoring und Alerting
- Log-Aggregation
verwendet wird.
Aktivierung¶
Resultierende Manifeste¶
Deployment¶
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-application
labels:
app: my-application
spec:
selector:
matchLabels:
app: my-application
template:
metadata:
labels:
app: my-application
StatefulSet¶
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: my-application
labels:
app: my-application
spec:
selector:
matchLabels:
app: my-application
template:
metadata:
labels:
app: my-application
Anwendungsfälle¶
Service-Selektor¶
Der Service verwendet automatisch das app-Label:
apiVersion: v1
kind: Service
metadata:
name: my-application
spec:
selector:
app: my-application # Matched durch applabel
ports:
- port: 80
Pod-Anti-Affinität¶
Verteilen Sie Pods auf verschiedene Nodes:
chart:
applabel: true
fullnameOverride: "my-application"
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchLabels:
app: my-application
topologyKey: kubernetes.io/hostname
Prometheus ServiceMonitor¶
Das app-Label für Monitoring-Selektoren:
chart:
applabel: true
monitoring:
- name: my-application
namespace: monitoring
release: prometheus
endpoints:
- port: metrics
interval: 30s
Best Practices¶
- Konsistente Benennung - Verwenden Sie
fullnameOverridefür vorhersehbare Label-Werte - Aktivieren für Production -
applabel: trueverbessert die Kubernetes-Integration - Kombinieren mit anderen Labels - Ergänzen Sie mit
app.kubernetes.io/Labels für bessere Standardisierung
Standard Kubernetes Labels¶
Zusätzlich zum app-Label setzt ohMyHelm auch die empfohlenen Kubernetes-Labels:
labels:
app: my-application
app.kubernetes.io/name: my-application
app.kubernetes.io/instance: release-name
app.kubernetes.io/version: "1.0.0"
app.kubernetes.io/managed-by: Helm