Back to Linkerd

Introduction

linkerd/docs/config.md

1.7.511.6 KB
Original Source

Introduction

A Linkerd config example

yaml
admin:
  port: 9990

routers:
- protocol: http
  label: int-http
  dtab: |
    /svc       => /#/io.l5d.fs;
  servers:
  - port: 4140
    ip: 0.0.0.0

- protocol: thrift
  servers:
  - port: 8081
    ip: 0.0.0.0
    thriftFramed: true
  client:
    thriftFramed: true
  thriftMethodInDst: false
  dtab: |
    /svc => /#/io.l5d.fs/thrift;

namers:
- kind: io.l5d.fs
  rootDir: disco

telemetry:
- kind: io.l5d.statsd
  experimental: true
  prefix: linkerd
  hostname: 127.0.0.1
  port: 8125
  gaugeIntervalMs: 10000
  sampleRate: 0.01
- kind: io.l5d.tracelog
  sampleRate: 0.2
  level: TRACE

Welcome to the Configuration Reference for Linkerd!

Linkerd's configuration is controlled via a configuration file, which must be provided as a command-line argument. It may be a local file path or - to indicate that the configuration should be read from the standard input. For convenience, the release package includes a default linkerd.yaml file in the config/ directory.

File Format

The configuration may be specified as a JSON or YAML object. There are no requirements on field ordering, though it's generally good style to start a router with the protocol. Five top level keys are supported:

KeyRequiredDescription
adminnoConfigures Linkerd's administrative interface.
routersyesConfigures Linkerd's RPC support for various protocols.
namersnoConfigures Linkerd's integration with various service discovery backends.
telemetrynoConfigures Linkerd's metrics instrumentation.
usagenoConfigures Linkerd usage reporting.

Administrative interface

yaml
admin:
  ip: 127.0.0.1
  port: 9990
  tls:
    certPath: /foo/cert.pem
    keyPath: /foo/key.pem

Linkerd supports an administrative interface, both as a web ui and a collection of json endpoints. The exposed admin port and ip to listen on are configurable via a top-level admin section.

KeyDefault ValueDescription
iploopback addressIP for the admin interface. A value like 0.0.0.0 configures admin to listen on all local IPv4 interfaces.
port9990Port for the admin interface.
socketOptionsnoneSocket options to set for the admin interface.
httpIdentifierPortnonePort for the http identifier debug endpoint.
shutdownGraceMs10000maximum grace period before the Linkerd process exits
tlsno tlsThe admin interface will serve over TLS if this parameter is provided. See TLS.
securityno restrictionsThe admin interface can block sensitive endpoints if configured. See Admin Security
workerThreads2The number of worker threads used to serve the admin interface.

Administrative endpoints

Example admin requests

bash
curl :9990/admin
curl :9990/admin/tracing?enable=true
curl -H "Accept: application/json" :9990/admin/lint
curl -H "Accept: application/json" :9990/admin/threads
curl ":9990/admin/pprof/profile?seconds=10&hz=100"
curl ":9990/delegator.json?path=/http/1.1/GET/foo&dtab=/http/*=>/$/inet/127.1/9990"

Default admin endpoints available in both Linkerd and Namerd:

EndpointDescription
/adminretrieve a list of all available admin endpoints
/admin/announcerset of announcement chains that have run through the announcers
/admin/contentioncall stacks of blocked and waiting threads
/admin/lintresults for all registered linters, set Accept: application/json to force json
/admin/lint.jsonidentical to admin/lint
/admin/pingsimple health check endpoint, returns pong
/admin/pprof/contentionCPU contention profile which identifies blocked threads (Thread.State.BLOCKED), in pprof format. The process will be profiled for 10 seconds at a frequency of 100 hz. These values can be controlled via HTTP request parameters seconds and hz respectively.
/admin/pprof/heapheap profile computed by the heapster agent, output is in pprof format
/admin/pprof/profileCPU usage profile in pprof format. The process will be profiled for 10 seconds at a frequency of 100 hz. These values can be controlled via HTTP request parameters seconds and hz respectively.
/admin/registry.jsondisplays how Linkerd is currently configured across a variety of dimensions including the client stack, server stack, flags, service loader values, system properties, environment variables, build properties and more
/admin/server_infobuild information about this Linkerd
/admin/shutdowninitiate a graceful shutdown
/admin/threadscapture the current stacktraces, set Accept: application/json to force json
/admin/threads.jsonidentical to admin/threads
/admin/tracingenable (/admin/tracing?enable=true) or disable tracing (/admin/tracing?disable=true)
/config.jsoncurrent Linkerd configuration, this should match your config file

Endpoints only available in Linkerd:

EndpointDescription
/bound-names.jsonlist of all known bound names from configured namers. namers must support the EnumeratingNamer trait to make this available, currently only supported by the io.l5d.k8s and io.l5d.fs namers.
/delegator.jsongiven path, dtab, and an optional namespace param, return the delegation tree
/logging.jsoncurrently configured loggers and log levels

Note that in addition to a default set of admin endpoints, Linkerd plugins may dynamically add their own endpoints.

HTTP Identifier Endpoints (running on httpIdentifierPort):

EndpointDescription
/identifies the request and returns a json map of identified results

This administrative interface was originally based on TwitterServer, more information may be found at TwitterServer HTTP Admin interface.

Admin security

Example to disable the endpoint /admin/shutdown exclusively

yaml
admin:
  ip: 127.0.0.1
  port: 9990
  security:
    pathBlacklist:
    - ^/admin/shutdown$

By default all administrative endpoints are accessible. This might not always be desired as this allows for example everybody to shutdown the process if the administrative port is not closed because metrics should be polled from Linkerd. The admin security configuration allows to whitelist or blacklist dedicated administrative endpoints.

yaml
admin:
  ip: 127.0.0.1
  port: 9990
  security:
    uiEnabled: true
    controlEnabled: false
    pathWhitelist:
    - ^/logging[.]json$

The security configuration supports these parameters allowing fine grained control over the administrative endpoints that are available.

KeyDefault ValueDescription
uiEnabledtrueConfigures if all endpoints that belong to the category required to run the administrative ui are available
controlEnabled trueConfigures if the endpoints that belong to the category to control Linkerd are available, i.e. /admin/shutdown and /logging.json
diagnosticsEnabled trueConfigures if all other endpoints are available.
pathWhitelistempty listConfigures paths via regular expressions that should be available for disabled endpoint categories
pathBlacklist empty listConfigures additional paths via regular expressions that should not be available for enabled categories

An administrative endpoint is available if its category is enabled and it is not on the blacklist or if its category is disabled and it is on the whitelist.

Routers Intro

A minimal Linkerd configuration example, which forwards all requests on localhost:8080 to localhost:8888

yaml
routers:
- protocol: http
  dtab: /svc/* => /$/inet/127.1/8888
  servers:
  - port: 8080

All configurations must define a routers key, the value of which must be an array of router configurations. Each router implements RPC for a supported protocol. Linkerd doesn't need to understand the payload in an RPC call, but it does need to know enough about the protocol to determine the logical name of the destination.

See routers.

Namers and Service Discovery

yaml
namers:
- kind: io.l5d.fs
  rootDir: disco

Linkerd supports a variety of common service discovery backends, including ZooKeeper and Consul. Linkerd provides abstractions on top of service discovery lookups that allow the use of arbitrary numbers of service discovery backends, and for precedence and failover rules to be expressed between them. This logic is governed by the routing configuration.

Naming and service discovery are configured via the namers section of the configuration file. A namer acts on paths that start with /# followed by the namer's prefix. See namers.

Telemetry Intro

yaml
telemetry:
- kind: io.l5d.statsd
  experimental: true
  prefix: linkerd
  hostname: 127.0.0.1
  port: 8125
  gaugeIntervalMs: 10000
  sampleRate: 0.01
- kind: io.l5d.tracelog
  sampleRate: 0.2
  level: TRACE

A telemeter may receive stats and trace annotations, i.e. to send to a collector or export. Telemetry data can be collected and exported from a Linkerd process by configuring telemeters via a top-level telemetry section. See telemetry.

Usage

Example usage config

yaml
usage:
 orgId: my-org

In order to make improvements and prioritize features, we'd like to gain a broader picture of how users run Linkerd. Linkerd gathers anonymized usage data, and sends it to Buoyant once an hour. This behavior can be configured or disabled in the usage config.

The kind of data captured is as follows:

  1. How Linkerd is configured (The kinds of namers, initializers, identifiers, transformers, protocols, & interpreters used)
  2. What environments Linkerd is running in (Operating System, Container orchestration solution),
  3. How Linkerd performs in those contexts (JVM performance, Number of requests served)

We do not collect the labels of namers/routers, designated service addresses or directories, dtabs, request/response data, or any other possibly identifying information.

To see the exact payload that is sent query localhost:9990/admin/metrics/usage

KeyDefault ValueDescription
orgIdempty by defaultOptional string of your choosing that identifies your organization
enabledtrueIf set to true, data is sent to Buoyant once per hour

Socket Options

Linkerd supports configuring socket level options for any given interface. i.e. the admin and router interfaces. These configurations are only available on Linux 3.9 distributions and newer.

KeyDefault ValueDescription
noDelaytrueIf set to true, enables the use of TCP_NODELAY on a socket interface
reuseAddrtrueIf set to true, enables the SO_REUSEADDR option
reusePortfalseIf set to true, enables the SO_REUSEPORT option, which can be used to bind another Linkerd process to the same interface port.
readTimeoutMsunboundedConfigures this client or server with given transport-level socket read timeout in milliseconds.
writeTimeoutMsunboundedConfigures this client or server with given transport-level socket write timeout in milliseconds.
keepAlivefalseIf set to true, enables the SO_KEEPALIVE option, which will enable keep alive on the socket.
backlogNoneIf set will adjust the backlog queue size of the socket, a default of None falls back to the OS defined value of SOMAXCONN