liveBook · Manning

Envsubst

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

envsubst is a command-line utility that substitutes references to environment variables in input text with their corresponding values.

envsubst is a Linux command-line utility that replaces environment-variable references in input text with their current values. It keeps deployment configuration such as registry URLs and image versions separate from application code. section 8.9.2

A practical deployment workflow is:

  • Set variables such as CONTAINER_REGISTRY and VERSION in the shell or automated workflow. section 8.9.2
  • Pass a Kubernetes deployment template to envsubst through standard input. section 8.9.2
  • Use the expanded configuration directly or pipe it into kubectl for Kubernetes deployment. section 10.9.2

Expand a deployment template

export CONTAINER_REGISTRY=<url-for-your-registry> export VERSION=1 cd chapter-8-example-3 envsubst < ./scripts/kubernetes/deploy.yaml section 8.9.2

cd chapter-8-example-3
envsubst < ./scripts/kubernetes/deploy.yaml

The runnable command shows how a deployment template receives values from the current environment. section 8.9.2

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

How deep it goes
Explains substitution operationally through exported variables and a runnable command, without detailing parsing rules or implementation internals.
Examples
Demonstrates VERSION and CONTAINER_REGISTRY expansion in deploy.yaml, then pipes expanded configurations to kubectl.
What it assumes
Assumes shell usage, environment variables, deployment templates, and Kubernetes workflows; recommends practicing locally before automation.
What you can do after
Operate envsubst manually and incorporate it into shell-based continuous-deployment workflows for Kubernetes.
How it connects
Connects shell scripts, environment variables, Kubernetes, kubectl, container registries, and continuous deployment.

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.