This topic is intended to help developers who are new to MOSN projects quickly set up a development environment for building, testing, packaging, and running the sample code.
Prepare the running environment
- If you want to run MOSN with docker, install docker first.
- If you are using a local machine, set up a Unix-like environment.
- Install the compilation environment of Go.
Obtain the code
Code for MOSN projects is hosted at Github. Run the following command to obtain the code.
go get -u mosn.io/mosn
If the go get command fails, manually create a project.
# Access the src directory under GOPATH. cd $GOPATH/src # Create the mosn.io directory. mkdir -p mosn.io cd mosn.io # Clone MOSN code. git clone firstname.lastname@example.org:mosn/mosn.git cd mosn
The MOSN source code is finally saved to
Import the MOSN source code into the IDE
$GOPATH/src/mosn.io/mosn into your preferred Go IDE (Goland is recommended).
Compile the code
In the project’s root directory, compile the binary file of MOSN by running the following commands, depending on your machine type and the environment in which you want to execute the binary file.
Istio version switch
MOSN support xDS v2 and xDS v3, which are represented by Istio 1.5.2 and Istio 1.10.6 respectively. It can be switched between different versions according to needs. The default version is 1.10.6.
Switch to Istio 1.5.2 (xDS v2)
Switch to Istio 1.10.6 (xDS v3)
Compilation with a docker image
make build // Compile a Linux 64-bit executable binary file.
Run the following command to compile a local executable binary file.
Find the compiled binary file in
Run the following command in the project’s root directory to start the unit test.
Run the following command in the project’s root directory to start the integration test (which takes some time).
make integrate make integrate-new
Start MOSN from the configuration file
Run the following command to start MOSN from the configuration file.
./mosn start -c '$CONFIG_FILE'
Run MOSN samples
Refer to the example projects in the
examples directory to run samples.
Build the Service Mesh platform with MOSN
For more information, see the Istio integration.