Namespaces¶
Der Namespaces-Helper erstellt Kubernetes Namespaces als Teil Ihres Helm-Releases.
Übersicht¶
Mit dem Namespaces-Helper können Sie Namespaces erstellen, bevor andere Ressourcen deployed werden. Dies ist besonders nützlich für:
- Multi-Namespace-Deployments
- Infrastruktur-Setup
- Tenant-Isolation
Basis-Konfiguration¶
Pre-Install Hook¶
Empfohlen
Setzen Sie setPreInstallHook: true um sicherzustellen, dass der Namespace vor allen anderen Ressourcen erstellt wird.
namespaces:
setPreInstallHook: true # Namespace wird vor allen anderen Ressourcen erstellt
spaces:
- name: my-namespace
Mehrere Namespaces¶
namespaces:
setPreInstallHook: true
spaces:
- name: production
- name: staging
- name: development
- name: monitoring
- name: logging
Mit Labels und Annotations¶
namespaces:
setPreInstallHook: true
spaces:
- name: production
labels:
environment: production
team: platform
annotations:
description: "Production workloads"
- name: staging
labels:
environment: staging
team: platform
Vollständiges Beispiel¶
Multi-Environment Setup¶
# Chart.yaml
apiVersion: v2
name: infrastructure
version: 1.0.0
dependencies:
- name: ohmyhelm
alias: infra
repository: https://gitlab.com/ayedocloudsolutions/ohmyhelm
version: 1.13.0
# values.yaml
infra:
namespaces:
setPreInstallHook: true
spaces:
- name: prod-apps
labels:
environment: production
istio-injection: enabled
- name: prod-data
labels:
environment: production
backup: enabled
- name: staging-apps
labels:
environment: staging
- name: monitoring
labels:
purpose: observability
- name: cert-manager
labels:
purpose: infrastructure
Wichtige Hinweise¶
Namespace-Löschung
Namespaces, die mit einem Helm Hook erstellt wurden, werden nicht automatisch gelöscht wenn Sie helm uninstall ausführen. Dies ist ein Sicherheitsmechanismus um versehentlichen Datenverlust zu vermeiden.
Manuelles Löschen¶
Automatisches Löschen (nicht empfohlen)¶
Wenn Sie automatisches Löschen wünschen, erstellen Sie den Namespace stattdessen ohne Hook:
namespaces:
setPreInstallHook: false # Wird mit Release gelöscht
spaces:
- name: temporary-namespace
Kombination mit anderen Helpern¶
infra:
# Zuerst Namespaces erstellen
namespaces:
setPreInstallHook: true
spaces:
- name: production
# Dann Secrets im Namespace
secrets:
- name: db-credentials
namespace: production
values:
password: ""
# Und ConfigMaps
configs:
- name: app-config
namespace: production
values:
config.yaml: |
environment: production
Best Practices¶
- Immer
setPreInstallHook: trueverwenden für zuverlässige Reihenfolge - Labels für Organisation - Verwenden Sie konsistente Labels für Filtering
- Resource Quotas - Definieren Sie Quotas pro Namespace für Multi-Tenancy
- Network Policies - Isolieren Sie Namespaces mit Network Policies
- Dokumentation - Beschreiben Sie den Zweck jedes Namespaces in Annotations