Configuration is the set of values and settings that determines how a software component operates. For a microservice, environment variables provide a practical way to supply deployment-specific values without changing application code. section 2.6.6
Require a port before startup
A Node.js service reads its HTTP port from process.env.PORT and refuses to start when PORT is missing. Running export PORT=3000 or set PORT=3000 supplies the required value; the service can then start with node src/index.js. Failing early identifies configuration mistakes before they become debugging problems. section 2.6.6
Listing 6.2 Deploying our microservice to Kubernetes on Azure
apiVersion: apps/v1
kind: Deployment
metadata:
name: video-streaming
spec:
replicas: 1
selector:
matchLabels:
app: video-streaming
template:
metadata:
labels:
app: video-streaming
spec:
containers:
- name: video-streaming
image: bmdk1.azurecr.io/video-streaming:1 #1
imagePullPolicy: IfNotPresent #2
env:
- name: PORT
value: "4000"
---
apiVersion: v1
kind: Service
metadata:
name: video-streaming
spec:
selector:
app: video-streaming
type: LoadBalancer #3
ports:
- protocol: TCP
port: 80
targetPort: 4000
A Kubernetes manifest combines deployment settings, an environment variable, container image behavior, and service exposure for production deployment. section 6.11.4
Configuration becomes more useful as deployment concerns grow:
- Kubernetes configuration can select a published container image, control image pulling, provide PORT, and expose a service through a LoadBalancer; external exposure requires care. section 6.11.4
- Terraform variables prevent repeated values across infrastructure code files, allowing important settings to change in one place. section 7.10
- A separate application-configuration repository can centralize deployed service versions and environment variables, support history and promotion, and restrict access, but adds deployment phases and error risks. section 12.2.7






















