Make sure you have the following dependencies to run NSM:
- A Kubernetes Cluster - good options include:
-
- kind - usually the easiest choice
-
- vagrant - useful if you need to debug at the Node Level
- kubectl
- helm
In addition, to build NSM you will need:
- Go 1.13 or later
- Docker
- GNU make
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
.
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
- 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
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
You can remove the effects of helm-install-% with:
make helm-delete-%
make k8s-integration-tests
or one by one using the test name. For example, to trigger TestExec
, run:
make k8s-integration-TestExec-test
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.
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.
If you need to add new dependencies, run:
go mod tidy
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
The .circleci/config.yml file is the canonical source of how to build Network Service Mesh in case this file becomes out of date.
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.
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