Posts

Showing posts from August, 2025

What is a Pod Environment Variable

 An environment variable is just a key-value pair that you pass into a container at runtime, so the application inside can read it without you hardcoding values in code or image. In Kubernetes, Pods support environment variables through the container spec: env:   - name: DB_USER     value: admin echo $DB_USER # admin 2. Why use environment variables in Pods? They help you: Make apps configurable without rebuilding the image → You can change DB_HOST or API_KEY by updating YAML, no code change. Separate secrets & configs from code → Avoid hardcoding credentials in the container image. Control behavior for different environments (dev, staging, prod) → Same image, different environment variables. Read runtime data from Kubernetes → Pull Pod metadata (name, namespace, IP, etc.) into your app automatically. 3. Ways to set Environment Variables in Pods A. Hardcoded values Good for small static values. env: - name: MODE value: producti...