LLM Apps in Production (RAG + Vector DB + Caching) · Lektion

Konfiguration und Secrets bei Deployments verwalten

Lernen Sie, Konfigurationen zu externalisieren und Secrets wie API-Schlüssel mithilfe von Umgebungsvariablen, Config Maps und Secret Managern sicher in bereitgestellte LLM-Anwendungen einzuschleusen.

Lektion 4 von 413 Schritte

Konfiguration und Secrets bei Deployments verwalten ist eine kostenlose LLM Apps in Production (RAG + Vector DB + Caching)-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des LLM Apps in Production (RAG + Vector DB + Caching)-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der LLM Apps in Production (RAG + Vector DB + Caching)-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

Config Belongs Outside Code

The same LLM app image runs in dev, staging, and production. The only difference should be configuration, not the code. Hard-coding endpoints or keys forces a rebuild for every environment.

This is the core idea of config externalization.

Config vs Secrets

Two related but distinct concepts:

  • Config — non-sensitive settings: model name, temperature, log level
  • Secrets — sensitive values: API keys, DB passwords, tokens

Secrets need stricter handling and must never be logged.

Environment Variables

The simplest portable mechanism is environment variables.

import os

model = os.environ.get('LLM_MODEL', 'gpt-mini')
temp = float(os.environ.get('LLM_TEMPERATURE', '0.2'))
print('Using', model, 'at temp', temp)

The Twelve-Factor Approach

The twelve-factor methodology says store config in the environment. This keeps the build artifact identical across environments and avoids accidentally committing secrets into version control.

Kubernetes ConfigMaps

In Kubernetes, non-sensitive config lives in a ConfigMap and is injected as env vars or files.

apiVersion: v1
kind: ConfigMap
metadata:
  name: llm-config
data:
  LLM_MODEL: 'gpt-mini'
  LLM_TEMPERATURE: '0.2'

Kubernetes Secrets

Sensitive values go in a Secret object, kept separate from ConfigMaps and mounted with tighter access controls. Base64 encoding is not encryption, so enable encryption at rest.

apiVersion: v1
kind: Secret
metadata:
  name: llm-secrets
type: Opaque
stringData:
  OPENAI_API_KEY: 'set-via-pipeline'

Dedicated Secret Managers

For production, use a dedicated secret manager:

  • HashiCorp Vault
  • AWS Secrets Manager
  • GCP Secret Manager

They offer rotation, audit logs, and fine-grained access far beyond plain env vars.

Fetching Secrets at Runtime

Apps can pull secrets at startup from a manager instead of baking them in. This centralizes rotation.

def load_secret(name):
    store = {'OPENAI_API_KEY': 'sk-demo'}
    if name not in store:
        raise KeyError('missing secret: ' + name)
    return store[name]

print(load_secret('OPENAI_API_KEY')[:7])

Validating Config at Startup

Fail fast: validate that all required config and secrets are present when the app boots, not when the first request arrives. A clear startup error beats a confusing 500 in production.

Avoiding Secret Leaks

Common leak vectors to guard against:

  • Logging full request objects that include keys
  • Echoing env vars in debug endpoints
  • Committing .env files
  • Exposing secrets in error stack traces

Rotation and Per-Environment Keys

Use separate keys per environment and rotate them on a schedule. With a secret manager, rotation updates one place and all instances pick it up without a redeploy.

Quick Check

Test your understanding of Kubernetes config.

Recap

You learned to externalize config from code and separate it from secrets. Use environment variables and ConfigMaps for settings, Secrets and dedicated managers for sensitive values, validate everything at startup, and rotate keys per environment without leaking them in logs.

Kostenlos starten

Lerne LLM Apps in Production (RAG + Vector DB + Caching) mit einem KI-Tutor — kostenlos

Schreibe und führe echten Code in deinem Browser aus, bekomme sofortige Hilfe von einem 24/7 KI-Tutor und setze dein Lernen im Web oder in der App fort.

Kurse
12
Lektionen
48

Häufig gestellte Fragen

Ist die Lektion „Konfiguration und Secrets bei Deployments verwalten“ kostenlos?

Ja — der vollständige Text von „Konfiguration und Secrets bei Deployments verwalten“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des LLM Apps in Production (RAG + Vector DB + Caching)-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der LLM Apps in Production (RAG + Vector DB + Caching)-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Konfiguration und Secrets bei Deployments verwalten“?

Lernen Sie, Konfigurationen zu externalisieren und Secrets wie API-Schlüssel mithilfe von Umgebungsvariablen, Config Maps und Secret Managern sicher in bereitgestellte LLM-Anwendungen einzuschleusen. Du übst LLM Apps in Production (RAG + Vector DB + Caching) mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um LLM Apps in Production (RAG + Vector DB + Caching) zu starten?

Keine Vorkenntnisse erforderlich. LLM Apps in Production (RAG + Vector DB + Caching) auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.

Wie lange dauert die Lektion „Konfiguration und Secrets bei Deployments verwalten“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser LLM Apps in Production (RAG + Vector DB + Caching)-Lektion Code schreiben und ausführen?

Ja. Jede LLM Apps in Production (RAG + Vector DB + Caching)-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. LLM-Anwendungen mit Docker containerisieren
  2. Orchestrierung mit Kubernetes für Skalierbarkeit
  3. CI/CD für die Bereitstellung von LLM-Anwendungen
  4. Konfiguration und Secrets bei Deployments verwalten
← Zurück zu LLM Apps in Production (RAG + Vector DB + Caching)