Telepresence
A tool for connecting to remote cluster services from a local machine
A tool for connecting to remote cluster services from a local machine
Telepresence is a tool developed by Ambassador Labs that lets you connect directly from a local development environment to services in a remote Kubernetes cluster. First released in 2017, it has become a core tool for cloud-native development.
It has two core features. First, it connects your local machine to the cluster network so you can access services in the cluster as if they were on localhost. Second, the Intercept feature routes traffic coming into the cluster to your local machine, enabling real-time debugging.
Telepresence creates a VPN-like tunnel to connect the local machine and the cluster. It injects a sidecar container called Traffic Agent into the target service and forwards traffic to the local machine through it. Environment variables and volumes are also accessible locally.
In practice, it is useful in microservice environments for scenarios where you develop only one service locally while using the cluster's instances of the other dependent services. You can test code changes immediately without building, pushing, and deploying an image every time, making development more than 10 times faster.
# Telepresence ์ค์น (macOS)
brew install datawire/blackbird/telepresence
# ํด๋ฌ์คํฐ์ ์ฐ๊ฒฐ
telepresence connect
# ์ฐ๊ฒฐ ์ํ ํ์ธ
telepresence status
# ํด๋ฌ์คํฐ ์๋น์ค ๋ชฉ๋ก ํ์ธ
telepresence list
# ํน์ ์๋น์ค์ ํธ๋ํฝ์ ๋ก์ปฌ๋ก ๊ฐ๋ก์ฑ๊ธฐ (Intercept)
# user-service:8080์ผ๋ก ๋ค์ด์ค๋ ํธ๋ํฝ์ ๋ก์ปฌ 3000๋ฒ ํฌํธ๋ก ์ ๋ฌ
telepresence intercept user-service --port 3000:8080
# ํ๊ฒฝ ๋ณ์๋ ํจ๊ป ๊ฐ์ ธ์ค๊ธฐ
telepresence intercept user-service --port 3000:8080 --env-file user-service.env
# ํค๋ ๊ธฐ๋ฐ ์ ํ์ intercept (๋ค๋ฅธ ํ์ ์ํฅ ์์ด)
telepresence intercept user-service --port 3000:8080 \
--http-header x-telepresence-intercept=dev-john
# ๋ก์ปฌ์์ ๊ฐ๋ฐ ์๋ฒ ์คํ
source user-service.env
npm run dev # ๋ก์ปฌ 3000๋ฒ ํฌํธ์์ ์คํ
# ํด๋ฌ์คํฐ ๋ด ๋ค๋ฅธ ์๋น์ค ์ง์ ํธ์ถ ํ
์คํธ
curl http://order-service.default.svc.cluster.local:8080/api/orders
# Intercept ์ข
๋ฃ
telepresence leave user-service
# ํด๋ฌ์คํฐ ์ฐ๊ฒฐ ํด์
telepresence quit
# Preview URL ์์ฑ (ํ์๊ณผ ๊ณต์ ๊ฐ๋ฅ)
telepresence intercept user-service --port 3000:8080 --preview-url
# ๋ณผ๋ฅจ ๋ง์ดํธ์ ํจ๊ป intercept
telepresence intercept user-service --port 3000:8080 \
--mount=/tmp/user-service-volumes
Senior: "Local microservice development is too slow. It makes no sense that changing a single line takes 5 minutes for build-push-deploy."
Junior: "Can't we edit code and test right away if we use Telepresence intercept?"
Senior: "Right. Just connect to the staging cluster and run only your own service locally. It makes a huge difference in development speed."
Interviewer: "How did you solve the difficulty of local development in a microservice environment?"
Candidate: "I developed by connecting to the cluster with Telepresence. With intercept, I could bring only the traffic of a specific service to my local machine for real-time debugging, and by using the cluster's instances of the other dependent services, the environment mismatch problem was solved too. The development cycle was shortened from 5 minutes to a few seconds."
Take a mock interview on this topic โ WIA SOOM AI Interview ยท Start for free
Reviewer: "Did local testing go well? Things may behave differently in the cluster environment."
Developer: "I connected to staging with Telepresence and tested there. Since both Redis and PostgreSQL use the cluster's instances, there's no need to worry about environment differences."