Skip to content

Commit

Permalink
Merge pull request #2 from kubesphere/master
Browse files Browse the repository at this point in the history
update
  • Loading branch information
mvpzhangkai authored Nov 17, 2020
2 parents 3eff068 + ae1fc2d commit e29758d
Show file tree
Hide file tree
Showing 16 changed files with 653 additions and 284 deletions.
109 changes: 7 additions & 102 deletions developer-guide/development/README.md
Original file line number Diff line number Diff line change
@@ -1,111 +1,16 @@
# How to build KubeSphere
# Development Guide

This document walks you through how to get started with building KubeSphere in your local environment.

## Preparing the environment
## QuickStart

### Go
See [quickstart](quickstart.md)

KubeSphere development is based on [Kubernetes](https://github.com/kubernetes/kubernetes). Both of them are written in [Go](http://golang.org/). If you don't have a Go development environment, please [set it up](http://golang.org/doc/code.html) first.
## Development Workflow

| Kubernetes | requires Go |
|----------------|-------------|
| 1.13+ | >= 1.12 |
See [development-workflow](development-workflow.md)

> Tips:
>
> - Ensure your GOPATH and PATH have been configured in accordance with the Go
environment instructions.
> - It's recommended to install [macOS GNU tools](https://www.topbug.net/blog/2013/04/14/install-and-use-gnu-command-line-tools-in-mac-os-x) when using MacOS for development.
## Pull Requests

### Docker
See [pull-requests](pull-requests.md)

KubeSphere components are often deployed as containers in Kubernetes. If you need to rebuild the KubeSphere components in the Kubernetes cluster, you'll need to [install Docker](https://docs.docker.com/install/) in advance.

### Dependency Management

KubeSphere uses [Go Modules](https://github.com/golang/go/wiki/Modules) to manage dependencies in the `vendor/` tree.

> Note: KubeSphere uses `go module` to manage dependencies, but the development process still relies on `GOPATH`
> In the CRD development process, you need to use tools to automatically generate code. The tools used by KubeSphere still need to rely on `GOPATH`.
> For Chinese contributors who are going to pull the go module, we recommend you to use [goproxy.cn](https://goproxy.cn) as the proxy.
## Building KubeSphere Core on a Local OS/shell Environment

### For Quick Taste Binary

When you go get KubeSphere, you can choose the version you want to get: `go get kubesphere.io/kubesphere@version-you-want`

For modules stored in source control repositories, the version suffix can also be a commit hash, branch identifier, or other syntax known to the source control system, as in 'go get golang.org/x/text@master'. The version suffix @latest explicitly requests the default behavior described above.

> Note: Before getting KubeSphere, you need to synchronize the contents of the `replace` section of the go.mod file of the KubeSphere you want to version.
```bash
mkdir ks-tmp
cd ks-tmp
echo 'module kubesphere' > go.mod
echo 'replace (
github.com/Sirupsen/logrus v1.4.1 => github.com/sirupsen/logrus v1.4.1
github.com/kiali/kiali => github.com/kubesphere/kiali v0.15.1-0.20190407071308-6b5b818211c3
github.com/kubernetes-sigs/application => github.com/kubesphere/application v0.0.0-20190518133311-b9d9eb0b5cf7
)' >> go.mod

GO111MODULE=on go get kubesphere.io/kubesphere@d649e3d0bbc64bfba18816c904819e4850d021e0
GO111MODULE=on go build -o ks-apiserver kubesphere.io/kubesphere/cmd/ks-apiserver # build ks-apiserver
GO111MODULE=on go build -o ks-apigateway kubesphere.io/kubesphere/cmd/ks-apigateway # build ks-apigateway
GO111MODULE=on go build -o ks-controller-manager kubesphere.io/kubesphere/cmd/controller-manager # build ks-controller-manager
GO111MODULE=on go build -o ks-iam kubesphere.io/kubesphere/cmd/ks-iam # build ks-iam
```

### For Building KubeSphere Core Images

KubeSphere components are often deployed as a container in a Kubernetes cluster, you may need to build a Docker image locally.

1. Clone repo to local.

```bash
git clone https://github.com/kubesphere/kubesphere.git
cd kubesphere
```

2. Run Docker command to build image.

```bash
# $REPO is the docker registry to push to
# $Tag is the tag name of the docker image
# The full go build process will be executed in the Dockerfile, so you may need to set GOPROXY in it.
docker build -f build/ks-apigateway/Dockerfile -t $REPO/ks-apigateway:$TAG .
docker build -f build/ks-apiserver/Dockerfile -t $REPO/ks-apiserver:$TAG .
docker build -f build/ks-iam/Dockerfile -t $REPO/ks-account:$TAG .
docker build -f build/ks-controller-manager/Dockerfile -t $REPO/ks-controller-manager:$TAG .
docker build -f ./pkg/db/Dockerfile -t $REPO/ks-devops:flyway-$TAG ./pkg/db/
```

### For KubeSphere Core Local Development Building

1. Create a `kubesphere` work directory under `GOPATH` and clone the source code.

```bash
mkdir -p $GOPATH/src/kubesphere.io/
cd $GOPATH/src/kubesphere.io/
git clone https://github.com/kubesphere/kubesphere
```

2. Use command `make` to build binary

```bash
make ks-apiserver # Build ks-apiserver binary
make ks-iam # Build ks-iam binary
make controller-manager # Build ks-controller-manager binary
make ks-apigateway # Build ks-apigateway binary
```

If you need to build a docker image, you can refer to the previous section.

### Test

It‘s recommended to use local Kubernetes clusters, such as [minikube](https://kubernetes.io/docs/tasks/tools/install-minikube/), or to install an single-node [all-in-one](https://github.com/kubesphere/kubesphere#all-in-one) environment (Kubernetes-based) for quick testing.

> Tip: It also supports to use Docker for Desktop ships with Kubernetes as the test environment.
See [How to run KubeSphere apiserver](how-to-run-kubesphere-core.md)
2 changes: 1 addition & 1 deletion developer-guide/development/development-workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Create a branch from master:
git checkout -b myfeature
```

Then edit code on the `myfeature` branch.
Then edit code on the `myfeature` branch. You can refer to [effective_go](https://golang.org/doc/effective_go.html) while writing code.

### Test and build

Expand Down
5 changes: 2 additions & 3 deletions developer-guide/development/how-to-connect-remote-service.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[Telepresence](https://www.telepresence.io/) is an open source tool that lets you run a single service locally, while connecting the service to a remote Kubernetes cluster.

We can use Telepresence to help us running KubeSphere apiserver locally.

Make sure you have installed `socat` on all of your nodes or you will get some error while starting telepresence.
## 1. Install Telepresence

You can read the [official installation documentation](https://www.telepresence.io/reference/install.html) to install Telepresence.
Expand All @@ -15,8 +15,7 @@ Open your command line and run the command `telepresence`. Telepresence will hel
Test Telepresence with KubeSphere apigateway:

```bash
$ curl http://ks-apigateway.kubesphere-system

$ curl http://ks-apiserver.kubesphere-system
401 Unauthorized
```

Expand Down
112 changes: 0 additions & 112 deletions developer-guide/development/how-to-run-kubesphere-core.md

This file was deleted.

2 changes: 1 addition & 1 deletion developer-guide/development/pull-requests.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This document explains the process and best practices for submitting a PR to the

## Before You Submit a PR

This guide is for contributors who already have a PR to submit. If you're looking for information on setting up your developer environment and writing code to contribute to KubeSphere, see the [development guide](/developer-guide/development/development-workflow.md).
This guide is for contributors who already have a PR to submit. If you're looking for information on setting up your developer environment and writing code to contribute to KubeSphere, see the [development guide](development-workflow.md).

**Make sure your PR adheres to our best practices. These include following project conventions, making small PRs, and commenting thoroughly. Please read the more detailed section on [Best Practices for Faster Reviews](#best-practices-for-faster-reviews) at the end of this document.**

Expand Down
Loading

0 comments on commit e29758d

Please sign in to comment.