Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add development guide #352

Merged
merged 4 commits into from
Jul 23, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
155 changes: 155 additions & 0 deletions docs/development/development.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
This document helps you get started using the Volcano code base.
If you follow this guide and find some problem, please take
a few minutes to update this file.

- [Building the code](#building-the-code)
- [Building docker images](#building-docker-images)
- [Building a specific docker image](#building-a-specific-docker-image)
- [Building the Volcano manifests](#building-the-volcano-manifests)
- [Cleaning outputs](#cleaning-outputs)
- [Running tests](#running-tests)
- [Auto-formatting source code](#auto-formatting-source-code)
- [Running the verification](#running-the-verification)
- [Adding dependencies](#adding-dependencies)
- [About testing](#about-testing)


## Cloning the code

You will need to clone the main `volcano` repo to `$GOPATH/src/volcano.sh/volcano` for
the below commands to work correctly.

## Building the code

To build volcano all components for your host architecture, go to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where can I find the output binaries?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

the source root and run:

```bash
make image_bins
```

To build a specific component for your host architecture, go to
the source root and run `make <component name>`:

```bash
make vc-scheduler
```


## Building docker images

Build the containers in your local docker cache:

```bash
make images
```

## Building a specific docker image

If you want to make a local change and test some component, say `vc-controllers`, you
could do:

Under volcano.sh/volcano repo

```bash
pwd
```
The path should be

```bash
.../src/volcano.sh/volcano
```

Set up environment variables HUB and TAG by
```bash
export HUB=docker.io/yourrepo
export TAG=citadel
```

Make some local change of the code, then build `vc-controllers`

```bash
make image.vc-controllers
```

## Building the Volcano manifests

Use the following command to build the deploy yaml files:

```bash
make generate-yaml
```

## Cleaning outputs

You can delete any build artifacts with:

```bash
make clean
```

## Running tests

### Running unit tests

You can run all the available unit tests with:

```bash
make unit-test
```

### Running e2e tests

You can run all the available e2e tests with:

```bash
make vcctl
make images
make e2e-test-kind
```

If you want to run e2e test in a existing cluster with volcano deployed, run the following:

```bash
KUBECONFIG=${KUBECONFIG} go test ./test/e2e
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need set the VK_BIN environment before running this go test command.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

```

## Auto-formatting source code

You can automatically format the source code to follow our conventions by going to the
top of the repo and entering:

```bash
./hack/update-gofmt.sh
```

## Running the verification

You can run all the verification we require on your local repo by going to the top of the repo and entering:

```bash
make verify
```

## Adding dependencies

Volcano uses [dep](https://github.com/golang/dep) to manage its dependencies.
If you want to add or update a dependency, running:

```bash
dep ensure -add dependency-name@version
```

## About testing

Before sending pull requests you should at least make sure your changes have
passed both unit and the verification. We only merge pull requests when
**all** tests are passing.

- Unit tests should be fully hermetic
- Only access resources in the test binary.
- All packages and any significant files require unit tests.
- Unit tests are written using the standard Go testing package.
- The preferred method of testing multiple scenarios or input is
[table driven testing](https://github.com/golang/go/wiki/TableDrivenTests)
- Concurrent unit test runs must pass.
56 changes: 56 additions & 0 deletions docs/development/perepare-for-development.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
This document helps you get started developing code for Volcano.
If you follow this guide and find some problem, please take
a few minutes to update this file.

Volcano components only have few external dependencies you
need to set up before being able to build and run the code.

- [Setting up Go](#setting-up-go)
- [Setting up Docker](#setting-up-docker)
- [Other dependencies](#other-dependencies)
- [Setting up Kubernetes](#setting-up-kubernetes)
- [Setting up personal access token](#setting-up-a-personal-access-token)

## Setting up Go

All Volcano components are written in the [Go](https://golang.org) programming language.
To build, you'll need a Go development environment. If you haven't set up a Go development
environment, please follow [these instructions](https://golang.org/doc/install)
to install the Go tools.

Volcano currently builds with Go 1.12

## Setting up Docker

Istio has a Docker build system for creating and publishing Docker images.
To leverage that you will need:

- **Docker platform:** To download and install Docker follow [these instructions](https://docs.docker.com/install/).

- **Docker Hub ID:** If you do not yet have a Docker ID account you can follow [these steps](https://docs.docker.com/docker-id/) to create one. This ID will be used in a later step when setting up the environment variables.


## Setting up Kubernetes

We require Kubernetes version 1.12 or higher.

// TODO: add some install ways, like minikube, kind, kubeadm, etc.
// Better links to some install guides


### Setting up a personal access token

This is only necessary for core contributors in order to push changes to the main repos.
You can make pull requests without two-factor authentication
but the additional security is recommended for everyone.

To be part of the Volcano organization, we require two-factor authentication, and
you must setup a personal access token to enable push via HTTPS. Please follow
[these instructions](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/)
for how to create a token.
Alternatively you can [add your SSH keys](https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/).

### What's next?

Once you've set up the prerequisites, continue with [Using the Code Base](./development.md)
for more details about how to build & test Volcano.