Adding Your Service

In order for your services to take advantage of Linkerd, they need to haveLinkerd's data plane proxy added to their pods. This is typically done byannotating the namespace, deployment, or pod with the linkerd.io/inject: enabled Kubernetes annotation, which will trigger _automatic proxy injection_when the resources are created. There is a full list of the configurationoptions available in reference. (See theproxy injection page for more on how thisworks.)

For convenience, Linkerd provides a linkerd inject text transform command will add thisannotation to a given Kubernetes manifest. Of course, these annotations can beset by other mechanisms.

Note that simply adding the annotation to a resource with pre-existing podswill not automatically inject those pods. You will need to update the pods(e.g. with kubectl rollout restart etc.) for them to be injected. With arollingupdate,the proxy often can be added to a live service without interruption.)

Example

To add the data plane proxies to a service defined in a Kubernetes manifest,you can use linkerd inject to add the annotations before applying the manifestto Kubernetes:

  1. cat deployment.yml | linkerd inject - | kubectl apply -f -

This example transforms the deployment.yml file to add injection annotationsin the correct places, then applies it to the cluster.

Verifying the data plane pods have been injected

Once your services have been added to the mesh, you will be able to queryLinkerd for traffic metrics about them, e.g. by using linkerd stat:

  1. linkerd stat deployments -n MYNAMESPACE

Note that it may take several seconds for these metrics to appear once the dataplane proxies have been injected.

Alternatively, you can query Kubernetes for the list of containers in the pods,and ensure that the proxy is listed:

  1. kubectl -n MYNAMESPACE get po -o jsonpath='{.items[0].spec.containers[*].name}'

If everything was successful, you'll see linkerd-proxy in the output, e.g.:

  1. MYCONTAINER linkerd-proxy

Finally, you can verify that everything is working by verifying that thecorresponding resources are reported to be meshed in the “Meshed” column of theLinkerd dashboard.

Dashboard)Dashboard

NoteThere is currently anissuewhereby network calls made during initialization of your application may fail asthe linkerd-proxy has yet to start. If your application exits when theseinitializations fail, and has a restartPolicy of Always (default) orOnFailure (providing your application exits with with a failure i.e.exit(1)), your container will restart with the linkerd-proxy ready, thusallowing your application to successfully complete initializations.

More reading

For more information on how the inject command works and all of the parametersthat can be set, see the linkerd inject referencepage.

For details on how autoinjection works, see the the proxy injectionpage.