liveBook · Manning

Configuration

As explained in Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform

A set of values and settings that determine how a software component operates.

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

How Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform covers it

How deep it goes
Explains required values, fail-fast validation, deployment manifests, shared Terraform variables, and repository trade-offs.
Examples
Uses a Node.js PORT variable, a Kubernetes YAML manifest, Terraform variables, and a separate application-configuration repository.
What it assumes
Assumes familiarity with microservices and introduces configuration through Node.js environment variables before expanding to deployment tooling.
What you can do after
Operate/configure microservices by supplying required environment variables and managing deployment settings across environments.
How it connects
Connects environment variables, microservices, Kubernetes, Terraform variables, infrastructure as code, and continuous delivery.

Also explained in

Compare how 23 books explain configuration →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform. The section links point to the parts of the book it draws on.