Adding Your Service

In order for your service to take advantage of Linkerd, it needs to have theproxy sidecar added to its resource definition. This is done by using theLinkerd CLI to update the definition and output YAMLthat can be passed to kubectl. By using Kubernetes’ rolling updates, theavailability of your application will not be affected.

To add Linkerd to your service, run:

  1. linkerd inject deployment.yml \
  2. | kubectl apply -f -

deployment.yml is the Kubernetes config file containing yourapplication. This will add the proxy sidecar along with an initContainer thatconfigures iptables to pass all traffic through the proxy. By applying this newconfiguration via kubectl, a rolling update of your deployment will betriggered replacing each pod with a new one.

You will know that your service has been successfully added to the service meshif it’s pods are reported to be meshed in the Meshed column of the Linkerddashboard.

Dashboard

Dashboard

You can always get to the Linkerd dashboard by running:

  1. linkerd dashboard

Protocol support

Linkerd is capable of proxying all TCP traffic, including WebSockets and HTTPtunneling, and reporting top-line metrics (success rates, latencies, etc) forall HTTP, HTTP/2, and gRPC traffic.

Server-speaks-first protocols

For protocols where the server sends data before the client sends data overconnections that aren’t protected by TLS, Linkerd cannot automatically recognizethe protocol used on the connection. Two common examples of this type ofprotocol are MySQL and SMTP. If you are using Linkerd to proxy plaintext MySQLor SMTP requests on their default ports (3306 and 25, respectively), then Linkerdis able to successfully identify these protocols based on the port. If you’reusing non-default ports, or if you’re using a different server-speaks-firstprotocol, then you’ll need to manually configure Linkerd to recognize theseprotocols.

If you’re working with a protocol that can’t be automatically recognized byLinkerd, use the —skip-inbound-ports and —skip-outbound-ports flags whenrunning linkerd inject.

For example, if your application makes requests to a MySQL database running onport 4406, use the command:

  1. linkerd inject deployment.yml --skip-outbound-ports=4406 \
  2. | kubectl apply -f -

Likewise if your application runs an SMTP server that accepts incoming requestson port 35, use the command:

  1. linkerd inject deployment.yml --skip-inbound-ports=35 \
  2. | kubectl apply -f -

Inject Reference

For more information on how the inject command works and all of the parametersthat can be set, look at the reference.

Notes

  • Applications that use protocols where the server sends data before the clientsends data may require additional configuration. See theProtocol support section above.
  • gRPC applications that use grpc-go must use grpc-go version 1.3 or later dueto a bug in earlier versions.

原文: https://linkerd.io/2/adding-your-service/