Docsright arrowTelepresenceright arrow2.4right arrowManually injecting the Traffic Agent

4 min • read

Manually injecting the Traffic Agent

You can directly modify your workload's YAML configuration to add the Telepresence Traffic Agent and enable it to be intercepted.

When you use a Telepresence intercept, Telepresence automatically edits the workload and services when you use telepresence uninstall --agent <your_agent_name>. In some GitOps workflows, you may need to use the Telepresence Mutating Webhook to keep intercepted workloads unmodified while you target changes on specific pods.

Procedure

You can manually inject the agent into Deployments, StatefulSets, or ReplicaSets. The example on this page uses the following Deployment:

The deployment is being exposed by the following service:

1. Generating the YAML

First, generate the YAML for the traffic-agent container:

Next, generate the YAML for the volume:

2. Injecting the YAML into the Deployment

You need to add the Deployment YAML you genereated to include the container and the volume. These are placed as elements of spec.template.spec.containers and spec.template.spec.volumes respectively. You also need to modify spec.template.metadata.annotations and add the annotation telepresence.getambassador.io/manually-injected: "true". These changes should look like the following:

3. Modifying the service

Once the modified deployment YAML has been applied to the cluster, you need to modify the Service to route traffic to the Traffic Agent. You can do this by changing the exposed targetPort to 9900. The resulting service should look like: