Zum Inhalt

Chart-Modus

Der Chart-Modus von ohMyHelm erstellt ein vollständiges Kubernetes-Deployment mit allen notwendigen Ressourcen.

Was ist der Chart-Modus?

Wenn Sie chart.enabled: true setzen, erstellt ohMyHelm automatisch:

  • Deployment oder StatefulSet - Je nach Konfiguration
  • Service - Für Netzwerk-Zugriff auf Ihre Pods
  • Ingress - Optional für externen Zugriff
  • ServiceAccount & RBAC - Optional für Kubernetes-Berechtigungen
  • ConfigMaps und Secrets - Für Konfiguration und sensible Daten
  • Jobs - Optional für Setup-Tasks
  • Init-Container und Sidecars - Für Multi-Container-Pods
  • HorizontalPodAutoscaler - Optional für Auto-Scaling
  • Prometheus ServiceMonitor - Optional für Monitoring

Warum den Chart-Modus verwenden?

Der Chart-Modus ist ideal, wenn Sie:

  • Schnell eine Anwendung deployen möchten ohne eigene Templates zu schreiben
  • Konsistente Deployment-Patterns über mehrere Anwendungen hinweg brauchen
  • Ein einfaches, aber vollständiges Kubernetes-Deployment benötigen
  • Keine Zeit haben, komplexe Helm-Templates zu entwickeln

Basis-Verwendung

Minimale Konfiguration für ein Deployment:

# Chart.yaml
apiVersion: v2
name: my-app
version: 1.0.0

dependencies:
  - name: ohmyhelm
    alias: app
    repository: https://gitlab.com/ayedocloudsolutions/ohmyhelm
    version: 1.13.0
# values.yaml
app:
  chart:
    enabled: true
    fullnameOverride: "my-app"

    container:
      image: nginx:latest
      ports:
        - name: http
          containerPort: 80

    service:
      type: ClusterIP
      ports:
        - port: 80
          targetPort: http

Deployment vs. StatefulSet

Deployment (Standard)

Für stateless Anwendungen:

chart:
  enabled: true
  statefulset: false  # Standard-Wert

  container:
    image: myapp:latest

Verwenden Sie Deployments für: - Stateless Webservices - APIs - Frontend-Anwendungen - Worker-Prozesse

StatefulSet

Für stateful Anwendungen mit persistentem Storage:

chart:
  enabled: true
  statefulset: true

  container:
    image: postgres:14

  statefulsetVolume:
    volumeMounts:
      - name: data
        mountPath: /var/lib/postgresql/data

    volumeClaimTemplates:
      - metadata:
          name: data
        spec:
          accessModes:
            - ReadWriteOnce
          resources:
            requests:
              storage: 10Gi

Verwenden Sie StatefulSets für: - Datenbanken (PostgreSQL, MySQL, MongoDB) - Message Queues (Kafka, RabbitMQ) - Distributed Systems (Elasticsearch, Cassandra)

Wichtige Konfigurationsoptionen

Namen

chart:
  nameOverride: "my-app"        # Teilweise Überschreibung
  fullnameOverride: "my-app"    # Vollständige Überschreibung (empfohlen)

Replicas

chart:
  replicaCount: 3  # Anzahl der Pod-Replicas

Health Checks

chart:
  container:
    livenessProbe:
      httpGet:
        path: /health
        port: http
      initialDelaySeconds: 30
      periodSeconds: 10

    readinessProbe:
      httpGet:
        path: /ready
        port: http
      initialDelaySeconds: 10
      periodSeconds: 5

Ressourcen

chart:
  resources:
    limits:
      cpu: 1000m
      memory: 1Gi
    requests:
      cpu: 100m
      memory: 256Mi

Autoscaling

chart:
  autoscaling:
    enabled: true
    minReplicas: 2
    maxReplicas: 10
    targetCPUUtilizationPercentage: 80

Weitere Themen

Detaillierte Dokumentation zu spezifischen Features:

Vollständiges Beispiel

# Chart.yaml
apiVersion: v2
name: production-app
version: 1.0.0

dependencies:
  - name: ohmyhelm
    alias: app
    repository: https://gitlab.com/ayedocloudsolutions/ohmyhelm
    version: 1.13.0
# values.yaml
app:
  chart:
    enabled: true
    fullnameOverride: "production-app"

    container:
      image: registry.example.com/myapp:v1.2.3
      ports:
        - name: http
          containerPort: 8080
        - name: metrics
          containerPort: 9090

      env:
        - name: DATABASE_HOST
          value: postgres.default.svc.cluster.local
        - name: DATABASE_USER
          valueFrom:
            secretKeyRef:
              name: db-credentials
              key: username

      livenessProbe:
        httpGet:
          path: /health
          port: http
        initialDelaySeconds: 30

      readinessProbe:
        httpGet:
          path: /ready
          port: http
        initialDelaySeconds: 10

    service:
      type: ClusterIP
      ports:
        - port: 80
          targetPort: http
          name: http
        - port: 9090
          targetPort: metrics
          name: metrics

    ingressSimple:
      enabled: true
      host: app.example.com
      path: /
      tlsSecretName: app-tls
      annotations:
        cert-manager.io/cluster-issuer: letsencrypt-prod

    autoscaling:
      enabled: true
      minReplicas: 3
      maxReplicas: 20
      targetCPUUtilizationPercentage: 80

    resources:
      limits:
        cpu: 2000m
        memory: 2Gi
      requests:
        cpu: 200m
        memory: 512Mi

    monitoring:
      - enabled: true
        name: app-metrics
        namespace: monitoring
        release: prometheus
        endpoints:
          - port: metrics
            interval: 30s
            path: /metrics

Best Practices

  1. Verwenden Sie fullnameOverride für vorhersehbare Ressourcen-Namen
  2. Implementieren Sie Health Checks für Production-Deployments
  3. Setzen Sie Ressourcen-Limits um Resource Starvation zu vermeiden
  4. Verwenden Sie feste Image-Tags in Production (nicht latest)
  5. Aktivieren Sie Autoscaling für variable Workloads
  6. Nutzen Sie StatefulSets nur wenn nötig - Deployments sind einfacher

Siehe auch