Hello, and welcome! If you're thinking about contributing to Kuma's code base, you came to the right place. This document serves as guide/reference for technical contributors.
Consult the Table of Contents below, and jump to the desired section.
- Developer documentation
The following dependencies are all necessary. Please follow the installation instructions for any tools/libraries that you may be missing.
curlgitmakegoclang-format# normally included in system's clang package with some exceptions, please check with the following command:clang-format --version
For a quick start, use the official golang Docker image. It includes all the command line tools pre-installed, with exception for from clang-format.
docker run --name kuma-build -ti \
--volume `pwd`:/go/src/github.com/kumahq/kuma \
--workdir /go/src/github.com/kumahq/kuma \
--env GO111MODULE=on \
golang:1.16 \
bash -c 'apt update && apt install -y unzip && export PATH=$HOME/bin:$PATH && bash'If kuma-build container already exists, start it with
docker start --attach --interactive kuma-buildTo cleanup disk space, run
docker rm kuma-buildThroughout this guide, we will use the make utility to run pre-defined
tasks in the Makefile. Use the following command to list out all the possible commands:
make helpWe packaged the remaining dependencies into one command. This is one of many commands
that's listed if you run the make help command above. You can also install each tool
individually if you know what you are missing. Run:
make dev/toolsto install all of the following tools at $HOME/bin:
- Ginkgo (BDD-style Go testing framework)
- Kubebuilder (Kubernetes API extension framework, comes with
etcdandkube-apiserver) - kustomize (Customization of kubernetes YAML configurations)
- kubectl (Kubernetes API client)
- KIND (Kubernetes IN Docker)
- Minikube (Kubernetes in VM)
ATTENTION: By default, development tools will be installed at $HOME/bin. Remember to include this directory into your PATH,
e.g. by adding export PATH=$HOME/bin:$PATH line to the $HOME/.bashrc file.
We use Ginkgo as our testing framework. To run the existing test suite, you have several options:
For all tests, run:
make testFor integration tests, run:
make integrationAnd you can run tests that are specific to a part of Kuma by appending the app name as shown below:
make test/kumactlPlease make sure that all tests pass before submitting a pull request in the master branch. Thank you!
After you made some changes, you will need to re-build the binaries. You can build all binaries by running:
make buildAnd similar to make test, you can appending the app name to the build command to build the binary of a specific app. For example, here is how you would build the binary for only kumactl:
make build/kumactlThis could help expedite your development process if you only made changes to the kumactl files.
Universal setup does not require Kubernetes to be present. It can be run in two modes.
- Run
Control Planeon local machine:
make run/universal/memory- Run Postgres with initial schema using docker-compose.
It will run on port 15432 with username:
kuma, password:kumaand db name:kuma.
make start/postgres- Run
Control Planeon local machine.
make run/universal/postgres- Build a
kumactl
make build/kumactl
export PATH=`pwd`/build/artifacts-$(go env GOOS)-$(go env GOARCH)/kumactl:$PATH- Configure a
kumactlwith running Control Plane
Check current config
kumactl config control-planes list
ACTIVE NAME ADDRESS
* local http://localhost:5681If active control plane points to different address than http://localhost:5681, add a new one
kumactl config control-planes add --name universal --address http://localhost:5681- Apply a Dataplane descriptor
kumactl apply -f dev/examples/universal/dataplanes/example.yaml- Run a Dataplane (requires
envoybinary to be on yourPATH)
make run/example/envoy/universal- List
Dataplanesconnected to theControl Plane:
kumactl inspect dataplanes
MESH NAME TAGS STATUS LAST CONNECTED AGO LAST UPDATED AGO TOTAL UPDATES TOTAL ERRORS
default example env=production service=web version=2.0 Online 32s 32s 2 0- Dump effective
Envoyconfig:
make config_dump/example/envoyThe following instructions are for folks who want to run Control Plane on their local machine. Local development is a viable path for people who are familiar with Kubernetes and understands trade-offs of out-off cluster deployment. If you want to run the Control Plane on Kubernetes instead, jump to the Control Plane on Kubernetes section below.
- Run KIND (Kubernetes IN Docker):
make kind/start
# set KUBECONFIG for use by `kumactl` and `kubectl`
export KUBECONFIG="$(kind get kubeconfig-path --name=kuma)"- Run
Control Planeon local machine:
make run/k8s-
Run the instructions at "Pointing Envoy at Control Plane" section, so the Dataplane descriptor is available in the Control Plane.
-
Start
Envoyon local machine (requiresenvoybinary to be on yourPATH):
make run/example/envoy/k8s- Dump effective
Envoyconfig:
make config_dump/example/envoyTo run the Kuma Control Plane on Kubernetes, follow these steps:
- Run KIND (Kubernetes IN Docker):
make kind/start
# set KUBECONFIG for use by `kubectl`
export KUBECONFIG="$(kind get kubeconfig-path --name=kuma)"- Deploy
Control Planeto KIND (Kubernetes IN Docker):
make kind/deploy/kuma- Deploy the demo app (and get Kuma sidecar injected)
make kind/deploy/example-app- Build
kumactl
make build/kumactl
export PATH=`pwd`/build/artifacts/kumactl:$PATH- Forward the
Control Planeport tolocalhost:
kubectl port-forward -n kuma-system $(kubectl get pods -n kuma-system -l app=kuma-control-plane -o=jsonpath='{.items[0].metadata.name}') 15681:5681- Add
Control Planeto yourkumactlconfig:
kumactl config control-planes add --name k8s --address http://localhost:15681- Verify that
Control Planehas been added:
kumactl config control-planes list
NAME API SERVER
k8s http://localhost:15681- List
Dataplanesconnected to theControl Plane:
kumactl inspect dataplanes
MESH NAME TAGS STATUS LAST CONNECTED AGO LAST UPDATED AGO TOTAL UPDATES TOTAL ERRORS
default demo-app-7cbbd658d5-dj9l6 app=demo-app pod-template-hash=7cbbd658d5 service=demo-app_kuma-demo_svc_80 Online 42m28s 42m28s 8 0