Skip to content

Commit

Permalink
Initial client
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Sobolev <[email protected]>
  • Loading branch information
haiodo committed Aug 18, 2020
1 parent 2659ce6 commit fb7d11d
Show file tree
Hide file tree
Showing 7 changed files with 873 additions and 13 deletions.
49 changes: 37 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
# Intro

This repo contains 'cmd-nsc' a client application for Network Service Mesh.

This README will provide directions for building, testing, and debugging that container.

# Usage

`cmd-nsc` accept following environment variables:

* NSM_NAME - A string value of network service client name (default "nsc")
* NSM_CONNECT_TO - A Network service Manager connectTo URL (default "unix:///var/lib/networkservicemesh/nsm.io.sock")
* NSM_MAX_TOKEN_LIFETIME - A token lifetime duration (default 24h)
* NSM_ROUTES - A comma separated list of routes.
* NSM_LABELS - A list of client labels with format key1=val1,key2=val2, will be used a primary list for network services
* NSM_MECHANISM - Default Mechanism to use, supported values "kernel","memif"
* NSM_NETWORK_SERVICES - A list of Network Service Requests URLs with inner format
- [{mechanism}]?:${nsName}[@domainName]?/${interfaceName/memIfSocketName}?${label1}=${value1}&${label2}=${value2}
- mechanism one of "kernel", "memif"
- nsName - a Network service name requested
- domainName - a interdomain service name
- interfaceName - a kernel interface name prefix, for kernel mechanism.
- memIfSocketName - a memif socket name to use for memif mechanism.
- labelX/valueX - a pairs of labels will be passed as part of request.

# Build

## Build cmd binary locally
## Build nsmgr binary locally

You can build the locally by executing

Expand All @@ -23,7 +48,7 @@ docker build .
Testing is run via a Docker container. To run testing run:

```bash
docker run --privileged --rm $(docker build -q --target test .)
docker run --rm $(docker build -q --target test .)
```

# Debugging
Expand All @@ -32,7 +57,7 @@ docker run --privileged --rm $(docker build -q --target test .)
If you wish to debug the test code itself, that can be acheived by running:

```bash
docker run --privileged --rm -p 40000:40000 $(docker build -q --target debug .)
docker run --rm -p 40000:40000 $(docker build -q --target debug .)
```

This will result in the tests running under dlv. Connecting your debugger to localhost:40000 will allow you to debug.
Expand All @@ -48,28 +73,28 @@ forwards port 40000 in the container to localhost:40000 where you can attach wit

Runs the debug target, which is just like the test target, but starts tests with dlv listening on port 40000 inside the container.

## Debugging the cmd
## Debugging

When you run 'cmd' you will see an early line of output that tells you:
When you run 'nsc' you will see an early line of output that tells you:

```Setting env variable DLV_LISTEN_FORWARDER to a valid dlv '--listen' value will cause the dlv debugger to execute this binary and listen as directed.```

If you follow those instructions when running the Docker container:
```bash
docker run --privileged -e DLV_LISTEN_FORWARDER=:50000 -p 50000:50000 --rm $(docker build -q --target test .)
docker run -e DLV_LISTEN_NSMGR=:50000 -p 50000:50000 --rm $(docker build -q --target test .)
```

```-e DLV_LISTEN_FORWARDER=:50000``` tells docker to set the environment variable DLV_LISTEN_FORWARDER to :50000 telling
```-e DLV_LISTEN_NSMGR=:50000``` tells docker to set the environment variable DLV_LISTEN_NSMGR to :50000 telling
dlv to listen on port 50000.

```-p 50000:50000``` tells docker to forward port 50000 in the container to port 50000 in the host. From there, you can
just connect dlv using your favorite IDE and debug cmd.
just connect dlv using your favorite IDE and debug nsc.

## Debugging the tests and the cmd
## Debugging the tests and the nsc

```bash
docker run --privileged -e DLV_LISTEN_FORWARDER=:50000 -p 40000:40000 -p 50000:50000 --rm $(docker build -q --target debug .)
docker run --rm -p 40000:40000 $(docker build -q --target debug .)
```

Please note, the tests **start** the cmd, so until you connect to port 40000 with your debugger and walk the tests
through to the point of running cmd, you will not be able to attach a debugger on port 50000 to the cmd.
Please note, the tests **start** the nsmgr, so until you connect to port 40000 with your debugger and walk the tests
through to the point of running nsmgr, you will not be able to attach a debugger on port 50000 to the nsmgr.
3 changes: 3 additions & 0 deletions code-of-conduct.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Code of Conduct

We follow the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md).
16 changes: 15 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
module github.com/networkservicemesh/cmd-template
module github.com/networkservicemesh/cmd-nsc

go 1.14

require (
github.com/antonfisher/nested-logrus-formatter v1.1.0
github.com/golang/protobuf v1.4.2
github.com/kelseyhightower/envconfig v1.4.0
github.com/networkservicemesh/api v0.0.0-20200813164503-9585b38e6772
github.com/networkservicemesh/sdk v0.0.0-20200813194707-0d4413ef1106
github.com/opentracing/opentracing-go v1.2.0
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.6.0
github.com/spiffe/go-spiffe/v2 v2.0.0-alpha.5
github.com/stretchr/testify v1.6.1
google.golang.org/grpc v1.31.0
)
Loading

0 comments on commit fb7d11d

Please sign in to comment.