0Pricing
LLM Apps in Production (RAG + Vector DB + Caching) · Lección

Gestionar configuración y secretos durante el despliegue

Aprenda a externalizar la configuración e inyectar de forma segura secretos como claves de API en aplicaciones LLM desplegadas mediante variables de entorno, mapas de configuración y gestores de secretos.

Gestionar configuración y secretos durante el despliegue es una lección gratuita de LLM Apps in Production (RAG + Vector DB + Caching) en CoddyKit. Esta es la lección 4 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de LLM Apps in Production (RAG + Vector DB + Caching), y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de LLM Apps in Production (RAG + Vector DB + Caching) incluye 4 lecciones en total.

Partes de esta lección aún no han sido traducidas y se muestran en inglés.

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.

Preguntas frecuentes

¿La lección «Gestionar configuración y secretos durante el despliegue» es gratis?

Sí — el texto completo de «Gestionar configuración y secretos durante el despliegue» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de LLM Apps in Production (RAG + Vector DB + Caching), actualiza a CoddyKit PRO. El curso de LLM Apps in Production (RAG + Vector DB + Caching) incluye 4 lecciones en total.

¿Qué aprenderé en «Gestionar configuración y secretos durante el despliegue»?

Aprenda a externalizar la configuración e inyectar de forma segura secretos como claves de API en aplicaciones LLM desplegadas mediante variables de entorno, mapas de configuración y gestores de secr… Practicas LLM Apps in Production (RAG + Vector DB + Caching) con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.

¿Necesito experiencia previa para empezar LLM Apps in Production (RAG + Vector DB + Caching)?

No se requiere experiencia previa. LLM Apps in Production (RAG + Vector DB + Caching) en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 4 de 4.

¿Cuánto tiempo toma la lección «Gestionar configuración y secretos durante el despliegue»?

La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.

¿Puedo escribir y ejecutar código en esta lección de LLM Apps in Production (RAG + Vector DB + Caching)?

Sí. Cada lección de LLM Apps in Production (RAG + Vector DB + Caching) incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.

Todas las lecciones de este curso

  1. Containerización de aplicaciones LLM con Docker
  2. Orquestación con Kubernetes para lograr escalabilidad
  3. CI/CD para la implementación de aplicaciones LLM
  4. Gestionar configuración y secretos durante el despliegue
← Volver a LLM Apps in Production (RAG + Vector DB + Caching)