
Goal
- Seamless development environment in Kubernetes
- Keep your local development tools, no commit or push required
- Helping local continuous development and deployment of microservice applications
Prerequisites
- telepresence
- kubectl
- k8s cluster
How to
Install Telepresence
Install telepresence on your local laptop, please follow the documentation for the installation steps. The k8s cluster for testing purposes is running on Azure Kubernetes Service. Please set context Kubernetes cluster.
$ kubectlconfig use-context aks-playground-1$ telepresence connect
When we use the command telepresence connect to the Kubernetes cluster side, Telepresence will create a namespace ambassador and traffic manager deployment. On the client side, Telepresence set up DNS to enable local access to Kubernetes Cluster. So we don’t need kubectl port-forward to manually configure access to local services. When you access a remote service the DNS resolves to a specific IP
address. For more details, see the Telepresence architecture documentation

Telepresence status
Root Daemon: RunningVersion : v2.4.9 (api 3)DNS :Remote IP : 10.0.0.10Exclude suffixes: [.arpa .com .io .net .org .ru]Include suffixes: []Timeout : 4sAlso Proxy : (0 subnets)Never Proxy: (1 subnets)User Daemon: RunningVersion : v2.4.9 (api 3)Ambassador Cloud : Logged outStatus : ConnectedKubernetes server : https://aks-playground-01-dns-d78da381.hcp.southeastasia.azmk8s.io:443Kubernetes context: aks-playground-01Telepresence proxy: ON (networking to the cluster is enabled)Intercepts : 0 total
The Telepresence daemon process creates a Virtual Network Interface (VIF) when Telepresence connects to the Kubernetes cluster
Verify from the client side, the client will get 10.0.0.10 ( kube-dns) as the DNS Server on Virtual Network Interfaces ( tel0 ). The Telepresence
DNS resolver is dynamically configured to resolve names using the namespaces of currently active intercepts.
Link 123 (tel0)Current Scopes: DNSLLMNR setting: yesMulticastDNS setting: noDNSSEC setting: noDNSSEC supported: noDNS Servers: 10.0.0.10DNS Domain: ~ambassador~default~development~ingress-internal~kube-node-lease~kube-public~kube-systemcluster.local
basically, we are able to resolve the service inside kubernetes cluster with the following format servicename.namespaces. for example we try to connect dataprocessingservice on development namespaces
nslookup dataprocessingservice.development

Create a sample deployment in Kubernetes cluster
git clone https://github.com/datawire/edgey-corp-python.gitcd edgey-corp-pythonkubectl apply -f k8s-config/edgey-corp-web-app-no-mapping.yaml -n development
Since this scenario we will access to the ingress, create an ingress object to provide routing rules to verylargejavaservice
spec:rules:- host: verylargejavaservice.development.internalhttp:paths:- backend:service:name: verylargejavaservice
Verify the deployment on k8s
kubectl get deployment,svc,ing -n development
NAME READY UP-TO-DATE AVAILABLE AGEdeployment.apps/dataprocessingservice 1/1 1 1 21mdeployment.apps/verylargedatastore 1/1 1 1 21mdeployment.apps/verylargejavaservice 1/1 1 1 21mNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEservice/dataprocessingservice ClusterIP 10.0.31.245 <none> 3000/TCP 21mservice/verylargedatastore ClusterIP 10.0.4.75 <none> 8080/TCP 21mservice/verylargejavaservice ClusterIP 10.0.155.58 <none> 8080/TCP 21mNAME CLASS HOSTS ADDRESS PORTS AGEingress.networking.k8s.io/verylargejavaservice <none> verylargejavaservice. <none> 21m
Connection test to verylargejavaservice. below several services, such us verylargejavaservice, dataprocessingservice and verylargedatastore are running on K8s Cluster. Please ignore the wording on the symbol cloud

Intercept dataprocessingservice on that running on k8s cluster into your local environment
$ telepresence intercept dataprocessingservice --port 3000 -n development
Using Deployment dataprocessingserviceinterceptedIntercept name : dataprocessingservice-developmentState : ACTIVEWorkload kind : DeploymentDestination : 127.0.0.1:3000Volume Mount Point: /tmp/telfs-2442392270
in parallel you are working on development microservice dataprocessingservice on your laptop, once the intercept is already activated, the traffic from external toward dataprocessingservice will be routed to the local laptop

after you make changes code DEFAULT_COLOR = ‘orange’ on local development, we can see the changes when we access the service again, Traffic from verylargejaveservice will be routed to local laptop with orange color.
