- A local Node.js application that simulates the service.
- A Deployment that mounts a ConfigMap as a volume.
- The ConfigMap with the data keys.
- Telepresence intercept steps that mount the pod volume locally.
Local Node.js example (local service)
This Node.js example reads configuration from the environment (process.env) but, when using Telepresence mounts, you can also read values from files placed by a ConfigMap mount.
Deployment volume configuration (mounting a ConfigMap)
This snippet shows the Deployment mounting a ConfigMap nameddb-info as a volume called db-config into the pod at /tmp.
ConfigMap (db-info)
The ConfigMap contains DB connection values that will appear as files when mounted as a volume.How it works — explanation
- The Deployment mounts the
db-infoConfigMap into the pod at/tmpusing a volume nameddb-config. - When the ConfigMap is mounted as a volume, Kubernetes creates files in the container filesystem — one file per key (
DB_HOST,DB_PASSWORD,DB_USERNAME) with the corresponding content. - When you run a Telepresence intercept that mounts pod volumes, Telepresence mirrors that volume onto your local filesystem so your local process can access the same files.
- Telepresence either creates a random mount path by default or you can request a specific mount path.
Mounting a ConfigMap as files does not populate process environment variables (e.g.,
process.env). If your application expects env vars, either: (a) use envFrom or explicit env entries in the Deployment for in-cluster pods, (b) read the files from the Telepresence mount in your local app, or (c) generate a local .env or export variables before running your local process.Quick reference table
Telepresence commands and examples
Check current intercepts:process.env.
If you prefer a consistent local path instead of a random Telepresence mount path, you can specify a fixed mount path with the
--mount= option. Ensure the target directory is writable by Telepresence.Specify a custom mount path
- Leave the current intercept:
- Re-intercept and provide a mount path (example
/tmp/example123):
Summary
- Telepresence for Kubernetes can mount Kubernetes volumes (including ConfigMaps mounted as volumes) into a local directory when you intercept a service.
- By default Telepresence creates a mount at a random path; use
--mount=/pathto choose a fixed path. - Mounting a ConfigMap exposes its keys as files — it does not automatically create environment variables in your local process. Adjust your local application to read the Telepresence mount, create symlinks, or export variables before running.
Links and references
- Telepresence course: Telepresence for Kubernetes
- Project docs: Telepresence documentation
- Kubernetes docs: ConfigMap and Volumes