Skip to main content
In this lesson we’ll learn how to access Kubernetes volumes attached to a pod when intercepting that service with Telepresence for Kubernetes. By mounting pod volumes on your local machine you can let a local process read the same ConfigMaps or files the in-cluster pod uses — enabling a dev workflow where your local service behaves like the cluster service. Key pieces:
  • 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 named db-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-info ConfigMap into the pod at /tmp using a volume named db-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:
Create an intercept and mount volumes (automatic/random mount location):
When you run that command, Telepresence prints details similar to:
Open a new shell and inspect the automatic mount point (use the mount path shown in your Telepresence output):
Note: Telepresence exposes the ConfigMap keys as files in the mount directory. Your local application must either read those files (or use symlinks) or you must set environment variables locally so the app can access config via 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

  1. Leave the current intercept:
  1. Re-intercept and provide a mount path (example /tmp/example123):
Inspect the chosen path:

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=/path to 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.

Watch Video