Adding Your Service

In order for your services to take advantage of Linkerd, they need to have Linkerd’s data plane proxy added to their pods. This is typically done by annotating the namespace, deployment, or pod with the linkerd/inject: true Kubernetes annotation, which will trigger automatic proxy injection when the resources are created. (See the proxy injection page for more on how this works.)

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

Note that simply adding the annotation to a resource with pre-existing pods will 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 a rolling update, 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 manifest to Kubernetes:

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

This example transforms the deployment.yml file to add injection annotations in 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 query Linkerd for traffic metrics about them, e.g. by using linkerd stat:

linkerd stat deployments -n MYNAMESPACE

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

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

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.:

MYCONTAINER linkerd-proxy

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

Dashboard
Dashboard

More reading

For more information on how the inject command works and all of the parameters that can be set, see the linkerd inject reference page.

For details on how autoinjection works, see the the proxy injection page.