---
# System prepended metadata

title: Telepresence 2

---

# Telepresence 2 


## Helpful links
GitHub open-source code base. We are aiming for full feature parity and for Telepresence 2 to take over as the primary version before Kubecon EU. (May 2nd)
[Telepresence 1 - Main branch](https://github.com/telepresenceio/telepresence)
[Telepresence 2 - release/v2](https://github.com/telepresenceio/telepresence/tree/release/v2)

[Whats new in T2](https://blog.getambassador.io/whats-new-in-telepresence-2-dbdff62b82d5)
* Architected for multiple users
* Faster to startup
* Is more reliable, with support for features such as re-connects
* Supports VPNs


## Command reference
[Client Reference for Telepresence 2](https://www.getambassador.io/docs/latest/telepresence/reference/client/)

Connect to cluster
```
telepresence connect
```


### DNS Resolution
[DNS Resolution](https://www.getambassador.io/docs/latest/telepresence/reference/dns/)

1. FQDN
    * `curl -ik https://kubernetes.default.svc.cluster.local`
2. Namespace 
    * `curl -ik https://kubernetes.default`
3. Direct during intercept 
    * `curl -ik https://kubernetes`
4. [External dependencies](https://kubernetes.io/docs/concepts/services-networking/service/#externalname)
    * `kubectl create service externalname a8r --external-name getambassador.io`
    * `nc -zv a8r.default 80`
    * `kubectl create service externalname googledns --external-name 8.8.4.4`
    * `ping googledns.default`

### Intercepts
[Intercept a Service in Your Own Environment](https://www.getambassador.io/docs/latest/telepresence/howtos/intercepts/)

1. `telepresence intercept dataprocessingservice --port 3000`

### Volume Mounts
[Volume Mounts](https://www.getambassador.io/docs/latest/telepresence/reference/volume/)

[Create Config Map](https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/)
```bash
kubectl create configmap game-vars --from-literal=enemies=aliens --from-literal=lives=3 --from-literal=enemies.cheat=true --from-literal=enemies.cheat.level=noGoodRotten --from-literal=secret.code.passphrase=UUDDLRLRBABAS --from-literal=secret.code.allowed=true --from-literal=secret.code.lives=30    
```

Create deployment and service, with config map mounted
```yaml=
kubectl apply -f - <<EOF
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
        - name: test-container
          image: nginx        
          ports:
          - containerPort: 80
          volumeMounts:
          - name: config-volume
            mountPath: /etc/config
      volumes:
        - name: config-volume
          configMap:
            name: game-vars
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: nginx
  name: nginx-deployment
  namespace: default
spec:
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app: nginx
  sessionAffinity: None
  type: ClusterIP
EOF
```

Start intercept with custom mount point and `ls` the mounted folder 
```
telepresence intercept nginx-deployment --port=80 --mount=/var/tmp/nginx
ls /var/tmp/nginx/etc/config/
```


### Environment Variables
[Environment Variables](https://www.getambassador.io/docs/latest/telepresence/reference/environment/)

Create env demo deployment
```yaml=
kubectl apply -f - <<EOF
apiVersion: apps/v1
kind: Deployment
metadata:
  name: envar-demo
  labels:
    purpose: demonstrate-envars
spec:
  replicas: 1
  selector:
    matchLabels:
      purpose: demonstrate-envars
  template:
    metadata:
      labels:
        purpose: demonstrate-envars
    spec:
      containers:
      - name: envar-demo-container
        image: gcr.io/google-samples/node-hello:1.0
        env:
        - name: DEMO_GREETING
          value: "Hello from the environment"
        - name: DEMO_FAREWELL
          value: "Such a sweet sorrow"
---
apiVersion: v1
kind: Service
metadata:
  labels:
    purpose: demonstrate-envars
  name: envar-demo
  namespace: default
spec:
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80
  selector:
    purpose: demonstrate-envars
  sessionAffinity: None
  type: ClusterIP
EOF
```

Subshell
```
telepresence intercept envar-demo-container --port 8888  -- /bin/bash
env | grep DEMO
```

More options to source environment variables
1. Env file
    *  `telepresence intercept envar-demo-container --port 8888 --env-file=these_vars`
2. Json file
    * `telepresence intercept envar-demo-container --port 8888  --env-json=FILENAME`
3. Command
    * `telepresence intercept envar-demo-container --port 8888  -- [COMMAND]`

### Preview URLs
[Collaborate using Preview URLs | Ambassador](https://www.getambassador.io/docs/pre-release/telepresence/howtos/preview-urls/)

[Telepresence Go Quickstart](https://www.getambassador.io/docs/telepresence/latest/quick-start/qs-go/)

Apply Edgey Corp Application
```
k apply -f  https://raw.githubusercontent.com/datawire/edgey-corp-go/master/k8s-config/edgey-corp-web-app-no-mapping.yaml
```
Clone the code locally
```
git clone https://github.com/datawire/edgey-corp-go.git
```


1. Telepresence login
2. Telepresence dashboard
3. Telepresence preview 


## Architecture Deep Dive
![](https://i.imgur.com/17vjXSb.png)

(https://www.getambassador.io/docs/latest/telepresence/reference/architecture/)
