Giter Site home page Giter Site logo

zhoudaqing / linkerd Goto Github PK

View Code? Open in Web Editor NEW

This project forked from linkerd/linkerd

0.0 2.0 0.0 1.73 MB

A dynamic linker for microservices.

Home Page: https://linkerd.io

License: Apache License 2.0

CSS 1.15% JavaScript 24.90% Scala 73.06% Shell 0.69% Thrift 0.20%

linkerd's Introduction

linkerd

GitHub license Circle CI Coverage Status Slack Status

๐ŸŽˆ Welcome to linkerd! ๐Ÿ‘‹

linkerd is an out-of-process network stack for microservices. It functions as a transparent RPC proxy, handling everything needed to make inter-service RPC safe and sane--including load-balancing, service discovery, instrumentation, and routing.

linkerd is designed to drop into existing applications with a minimum of configuration, and works with many common RPC formats and service discovery backends.

linkerd is built on top of Finagle, a production-tested RPC framework used by high-traffic companies like Twitter, Pinterest, Tumblr, PagerDuty, and others.

For more information, please see linkerd.io.

This repo contains two main projects: linkerd itself and namerd, a service for centrally managing routing policy and fronting service discovery.

Quickstart

Boot linkerd

$ ./sbt linkerd-examples/http:run # build and run linkerd
$ open http://localhost:9990      # open linkerd's admin interface in a browser

More details at linkerd's quickstart

Boot namerd

$ ./sbt namerd-examples/basic:run # build and run namerd
$ open http://localhost:9991      # open namerd's admin interface in a browser
$ curl :4180/api/1/dtabs          # test namerd's http interface

More details at namerd's quickstart

Working in this repository

sbt is used to build and test linkerd. Developers should not use a system-installed version of sbt, and should instead use the ./sbt script, which ensures that a compatible version of sbt is available.

./sbt accepts commands on the command line, or if it is invoked with no arguments it loads an interactive sbt shell:

$ ./sbt
>

The sbt project consists of many sub-projects. To list all projects run:

> projects

These projects are configured in project/LinkerdBuild.scala, which may be edited to include additional sub-projects, build configurations, etc. project/Base.scala is used to augment sbt's api.

You may run commands, for instance, compile on the aggregate project, all, by invoking:

> compile

Commands may be scoped by project, as in:

> router-http/test

Or by configuration as in:

> e2e:test

or

> router-http/e2e:test

The inspect command helps describe how a command is configured:

> inspect tree examples/http:run
[info] examples/http:run = InputTask[Unit]
[info]   +-examples/http:configFile = examples/http.yaml
[info]   | +-examples/http:configuration = http
[info]   |
[info]   +-examples/http:runtimeConfiguration = minimal
[info]   +-*/*:settingsData = Task[sbt.Settings[sbt.Scope]]
[info]

Tests

There are several supported test configurations:

  • test: pure unit tests that do not require system or network
  • e2e: tests that compose multiple modules; may allocate random ephemeral ports and write temporary files
  • integration: tests that rely on external services or programs that require external installation and/or configuration.

Both unit and end-to-end tests are run as part of our Continuous Integration setup.

Tests may be run with:

> test
...
[success] Total time: 14 s, completed Jan 29, 2016 4:24:16 PM
> e2e:test
...
[success] Total time: 8 s, completed Jan 29, 2016 4:25:18 PM

sbt also provides a testQuick command which is especially useful when actively editing code:

> ~testQuick

The validator project provides an integration test that operates on assembled artifacts. It may be run with:

> validator/validateAssembled

Writing tests

Test files for each of the above test configurations are stored in a per-configuration directory structure, e.g.:

$ ls -l router/http/src
e2e
main
test

Tests are written using the ScalaTest testing framework, and specifically the FunSuite mixin, which supports xUnit-like semantics. We avoid using mocking frameworks when testing our own code, as they tend to introduce as many problems as they solve. Tests may leverage the test-util project, which provides some helpers for writing tests against Finagle's asynchronous APIs.

Packaging

Building an executable

linkerd provides a plugin system so that features may be chosen at packaging time. To this end, there are multiple configurations for running and packaging linkerd executables.

The assembly plugin can be used to produce an executable containing all library dependencies. The linkerd subproject has several build configurations to support packaging:

> linkerd/assembly
[info] SHA-1: 5599e65540ebe6122da114be4a8b9a763475b789
[info] Packaging ...linkerd/target/scala-2.11/linkerd-0.0.10-SNAPSHOT-exec ...
[info] Done packaging.
[success] Total time: 14 s, completed Jan 29, 2016 4:29:40 PM
minimal build configuration

The 'minimal' sbt configuration, supporting only the http protocol and the io.l5d.fs namer, is useful for running linkerd during development. This configuration may be specified explicitly to scope build commands:

> linkerd/minimal:assembly
[info] Packaging ...linkerd/target/scala-2.11/linkerd-minimal-0.0.10-SNAPSHOT-exec ...
[info] Done packaging.
[success] Total time: 13 s, completed Jan 29, 2016 4:30:58 PM

Similarly, a namerd executable can be produced with the command:

> namerd/assembly

Releasing

Before releasing ensure that CHANGES.md is updated to include the version that you're trying to release.

By default, the -SNAPSHOT suffix is appended to the version number when building linkerd. In order to build a non-snapshot (i.e. releasable) version of linkerd, the build must occur from a release tag in git.

For example, in order to build the 0.0.10 release of linkerd:

  1. Ensure that the head version is 0.0.10
  2. git tag 0.0.10 && git push origin 0.0.10
  3. ./sbt linkerd/assembly namerd/assembly will produce executables in linkerd/target/scala-2.11/linkerd-0.0.10-exec and namerd/target/scala-2.11/namerd-0.0.10-exec.

Docker

Each of these configurations may be used to build a docker image.

> ;linkerd/docker ;namerd/docker
...
[info] Tagging image 94ab0793addf with name: buoyantio/linkerd:0.0.10-SNAPSHOT

The produced image does not contain any configuration. It's expected that configuration is provided by another docker layer or volume. For example, if you have linkerd configuration in path/to/myapp/linkerd.yml, you could start linkerd in docker with the following command:

$ docker run -p 4140:4140 -p 9990:9990 -v /absolute/path/to/myapp:/myapp buoyantio/linkerd:0.0.10-SNAPSHOT /myapp/linkerd.yml

The list of image names may be changed with a command like:

> set imageNames in docker in (linkerd, Bundle) += ImageName("gcr.io/gce-project/linkerd:v"+version.value)
...
> show linkerd/bundle:docker::imageNames
[info] List(buoyantio/linkerd:0.0.10-SNAPSHOT, gcr.io/gce-project/linkerd:v0.0.10-SNAPSHOT)

DCOS

Namerd supports a DCOS-specific configuration. When used in conjunction with namerd's io.l5d.zk dtab storage, this configuration provides bootstrapping of the ZooKeeper pathPrefix, along with a default dtab.

Run locally

This executes only the namerd-dcos-bootstrap command, it does not boot namerd.

$ ./sbt "namerd/dcos:run-main io.buoyant.namerd.DcosBootstrap namerd/examples/zk.yaml"
Run assembly script locally

The assembly script executes two commands serially:

  1. runs namerd-dcos-bootstrap
  2. boots namerd
$ ./sbt namerd/dcos:assembly
$ namerd/target/scala-2.11/namerd-0.5.0-SNAPSHOT-dcos-exec namerd/examples/zk.yaml
Run assembly script in docker
$ ./sbt namerd/dcos:docker
$ docker run -p 2181:2181 -p 4180:4180 -v /path/to/repo:/myapp -w /myapp buoyantio/namerd:0.5.0-SNAPSHOT-dcos namerd/examples/zk.yaml

Contributing

See CONTRIBUTING.md for more details about how to contribute.

Style

We generally follow Effective Scala and the Scala Style Guide. When in doubt, we try to use Finagle's idioms.

License

Copyright 2016, Buoyant Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use these files except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

linkerd's People

Contributors

adleong avatar olix0r avatar siggy avatar esbie avatar klingerf avatar rmars avatar gtcampbell avatar wmorgan avatar tonyd3 avatar benley avatar obeattie avatar

Watchers

zhou avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.