Skip to content

Latest commit

 

History

History
188 lines (138 loc) · 5.8 KB

guide-build.md

File metadata and controls

188 lines (138 loc) · 5.8 KB

Network Service Mesh - Build Guide

Prerequisites

Make sure you have the following dependencies to run NSM:

In addition, to build NSM you will need:

Build

You can build all of the containers needed for NSM, including a bunch of handle Network Service Endpoints (NSEs) and NSCs (Network Service Clients) that are useful for testing, but not part of the core with:

make k8s-build

And if you are using the Kind machinery to run your K8s cluster (described a bit further down), you really want to use the following:

make k8s-save

because make k8s-save will build your containers and save them in scripts/vagrant/images where they can be loaded by the Kins K8s cluster.

You can also selectively rebuild any component, say the nsmd, with make k8s-nsmd-save

After installing you can verify it with helm version.

Install

Network Service Mesh provides a handy Kind setup for running a small K8s cluster. Once you've done make k8s-save, you can deploy to it with:

make k8s-save                                                # build and save the NSM docker containers
make kind-start                                              # start up an nsm cluster named kind
make k8s-load-images                                         # load NSM docker containers into kind
make helm-init                                               # initialize helm
make helm-install-nsm                                        # install the nsm infrastructure

Run

  • icmp-responder - A simple example that connects an App Pod Client to a Network Service.
make helm-install-endpoint helm-install-client
  • vpp-icmp-responder - A simple example that connects a vpp based Pod to a Network Service using memif.
make helm-install-vpp-icmp-responder
  • vpn - An example that simulates an App Pod Client connecting to a Network Service implemented as a chain simulating a VPN Use Case
make helm-install-vpn

Verify

There are set of checkers that allow to verify examples.

  • icmp-responder and vpp-icmp-responder
    make k8s-icmp-check
  • vpn
    make k8s-vpn-check

Uninstall

You can remove the effects of helm-install-% with:

make helm-delete-%

Integration Testing

make k8s-integration-tests

or one by one using the test name. For example, to trigger TestExec, run:

make k8s-integration-TestExec-test

Helpful Logging tools

In the course of developing NSM, you will often find yourself wanting to look at logs for various NSM components.

The following:

make k8s-nsmd-logs

will dump all the logs for all running nsmd Pods in the cluster (you are going to want to redirect these to a file).

This works for any component in the system.

Regenerating code

If you change types.go or any of the .proto files you will need to be able to run go generate ./... to regenerate the code.

For rerunning the code generation the required dependencies are retrieved with the script:

./scripts/prepare-generate.sh

To regenerate code:

go generate ./...

NOTE: The script scripts/install-protoc.sh will download a released version of protoc, however, at the time of this writing there are no protoc releases built with the grpc plugin functionality made use of by the networkservicemesh project. Specifically, the UnimplementedServer* method generation is missing.

Updating Deps

If you need to add new dependencies, run:

go mod tidy

Shellcheck

As part of our CI, we run shellcheck on all shell scripts in the repo. If you want to run it locally, you need to install shellcheck

Canonical source on how to build

The .circleci/config.yml file is the canonical source of how to build Network Service Mesh in case this file becomes out of date.

Code formatting

We use goimports tool since it formats the code in the same style as go fmt and organizes imports additionally.

To install it run:

make install-formatter

To do formatting run:

make format

It may be useful to have goimports -w -local github.com/networkservicemesh/networkservicemesh installed as on save hook in your editor. Go imports doc page may help you to achieve this.

Static analysis of code

Get code static analyzer tool:

make lint-install

Make sure that tools is installed and can be used from terminal:

golangci-lint --version

If the command above doesn't work make sure the tool exists in go/bin directory.

Checking changes:

make lint-check-diff

Checking changes with memory limitation:

GOGC=30 make lint-check-diff

Checking all code in the project:

make lint-check-all

If you have any unsolvable problem with a concrete linter then consider updating .golanci.yaml