Setting up the Development Environment

Environment Setup

Prerequisites

Developing on Gloo Edge requires the following to be installed on your system:

To install all the requirements, run the following:

On macOS:

# install the Command Line Tools package if not already installed
xcode-select --install

# install protoc
curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v3.6.1/protoc-3.6.1-osx-x86_64.zip
unzip protoc-3.6.1-osx-x86_64.zip
sudo mv bin/protoc /usr/local/bin/
rm -rf bin include protoc-3.6.1-osx-x86_64.zip readme.txt

# install go
curl https://raw.githubusercontent.com/canha/golang-tools-install-script/master/goinstall.sh | bash

# install gogo-proto
go get -u github.com/gogo/protobuf/...

On Debian/Ubuntu linux:

# install make and unzip and build tools
sudo apt install make unzip build-essential -y

# install protoc
curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v3.6.1/protoc-3.6.1-linux-x86_64.zip
unzip protoc-3.6.1-linux-x86_64.zip
sudo mv bin/protoc /usr/local/bin/
rm -rf bin include protoc-3.6.1-linux-x86_64.zip readme.txt

# install go
curl https://raw.githubusercontent.com/canha/golang-tools-install-script/master/goinstall.sh | bash

# install gogo-proto
go get -u github.com/gogo/protobuf/...

Setting up the Solo-Kit and Gloo Edge Repositories

Next, we’ll clone the Gloo Edge and Solo-Kit source code. Solo-Kit is required for code generation in Gloo Edge.

Currently, Gloo Edge plugins must live inside the Gloo Edge repository itself.

Ensure you’ve installed go and have a your $GOPATH set. If unset, it will default to ${HOME}/go. The Gloo Edge repo should live in ${GOPATH}/src/github.com/solo-io/gloo.

To clone your fork of the repository:

mkdir -p ${GOPATH}/src/github.com/solo-io
cd ${GOPATH}/src/github.com/solo-io
git clone https://github.com/solo-io/gloo
# alternatively you can clone using your SSH key:
git clone git@github.com:solo-io/gloo.git

To run the main.go files locally in your system make sure to have a Kubernetes Cluster running.

You should now be able to run any main.go file in the Gloo Edge repository using:

go run <path-to-cmd>/main.go

For example:

# run gloo locally
go run projects/gloo/cmd/main.go
# run discovery locally
go run projects/discovery/cmd/main.go
# run gateway locally
go run projects/gateway/cmd/main.go

Awesome! You’re ready to start developing on Gloo Edge! Check out the Writing Upstream Plugins Guide to see how to add plugins to gloo.

Enabling Code Generation

To generate or re-generate code in Gloo Edge, some additional dependencies are required. Follow these steps if you are making changes to Gloo Edge’s Protobuf-based API.

Install Solo-Kit and required go packages:

cd ${GOPATH}/src/github.com/solo-io/gloo

# install required go packages
make install-go-tools

You can test that code generation works with Gloo Edge:

make -B generated-code
echo $?

The echo output should be 0 if everything worked correctly.