未验证 提交 86b91a56 编写于 作者: K KubeSphere CI Bot 提交者: GitHub

Merge pull request #1551 from runzexia/update-contribute-guide

contributing guide
# Development Guide
# Guide
This document walks you through how to get started developing KubeSphere and development workflow.
This [document](docs/en/guides/README.md) walks you through how to get started contributing KubeSphere.
## Preparing the environment
### Go
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 one up](http://golang.org/doc/code.html).
| Kubernetes | requires Go |
|----------------|-------------|
| 1.13+ | >= 1.12 |
> 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) for Mac OS.
### Docker
KubeSphere components are often deployed as containers in Kubernetes. If you need to rebuild the KubeSphere components in the Kubernetes cluster, you will need to [install Docker](https://docs.docker.com/install/).
### Dependency management
KubeSphere uses [Go Modules](https://github.com/golang/go/wiki/Modules) to manage dependencies in the `vendor/` tree.
#### Dependencies
[kubesphere/kubesphere](https://github.com/kubesphere/kubesphere) repository contains the source code . If you're looking for its dependent components, they live in their own repositories since they can be individual and universal.
- [Alert](https://github.com/kubesphere/alert): Alert is an enterprise-grade general-purpose high-performance alerting system.
- [Notification](https://github.com/openpitrix/notification): Notification is an enterprise-grade general-purpose high-performance notification system, it provides email notification service for KubeSphere currently.
- [OpenPitrix](https://github.com/openpitrix/openpitrix): Application management platform on multi-cloud environment, it provides application template and application management for KubeSphere currently.
- [SonarQube](https://github.com/SonarSource/sonarqube): Integrated in KubeSphere DevOps, it provides the capability to not only show health of an application but also to highlight issues newly introduced.
## Building KubeSphere on a local OS/shell environment
### For Quick Taste Binary
```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 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
```
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/
```
### Test
In the development process, it is 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.
## Development Workflow
![ks-workflow](docs/images/ks-workflow.png)
### 1 Fork in the cloud
1. Visit https://github.com/kubesphere/kubesphere
2. Click `Fork` button to establish a cloud-based fork.
### 2 Clone fork to local storage
Per Go's [workspace instructions](https://golang.org/doc/code.html#Workspaces), place KubeSphere' code on your `GOPATH` using the following cloning procedure.
1. Define a local working directory:
```bash
$ export working_dir=$GOPATH/src/kubesphere.io
$ export user={your github profile name}
```
2. Create your clone locally:
```bash
$ mkdir -p $working_dir
$ cd $working_dir
$ git clone https://github.com/$user/kubesphere.git
$ cd $working_dir/kubesphere
$ git remote add upstream https://github.com/kubesphere/kubesphere.git
# Never push to upstream master
$ git remote set-url --push upstream no_push
# Confirm that your remotes make sense:
$ git remote -v
```
### 3 Keep your branch in sync
```bash
git fetch upstream
git checkout master
git rebase upstream/master
```
### 4 Add new features or fix issues
Branch from it:
```bash
$ git checkout -b myfeature
```
Then edit code on the myfeature branch.
**Test and build**
Currently, make rules only contain simple checks such as vet, unit test, will add e2e tests soon.
**Using KubeBuilder**
- For Linux OS, you can download and execute this [KubeBuilder script](https://raw.githubusercontent.com/kubesphere/kubesphere/master/hack/install_kubebuilder.sh).
- For MacOS, you can install KubeBuilder by following this [guide](https://book.kubebuilder.io/quick-start.html).
**Run and test**
```bash
$ make all
# Run every unit test
$ make test
```
Run `make help` for additional information on these make targets.
### 5 Development in new branch
**Sync with upstream**
After the test is completed, suggest you to keep your local in sync with upstream which can avoid conflicts.
```
# Rebase your the master branch of your local repo.
$ git checkout master
$ git rebase upstream/master
# Then make your development branch in sync with master branch
git checkout new_feature
git rebase -i master
```
**Commit local changes**
```bash
$ git add <file>
$ git commit -s -m "add your description"
```
### 6 Push to your folk
When ready to review (or just to establish an offsite backup or your work), push your branch to your fork on github.com:
```
$ git push -f ${your_remote_name} myfeature
```
### 7 Create a PR
- Visit your fork at https://github.com/$user/kubesphere
- Click the` Compare & Pull Request` button next to your myfeature branch.
- Check out the [pull request process](pull-request.md) for more details and advice.
## CI/CD
KubeSphere uses [Travis CI](https://travis-ci.org/) as a CI/CD tool.
The components of KubeSphere need to be compiled and build include following:
`ks-apiserver, ks-controller-manager, ks-account, ks-apigateway, ks-devops`
After your PR is merged,Travis CI will compile the entire project and build the image, and push the image `kubespheredev/[component-name]:latest` to Dockerhub (e.g. `kubespheredev/ks-apiserver:latest`)
## API Reference
KubeSphere provides standard RESTFul API and detailed API documentations for developers, see [KubeSphere API Reference](https://docs.kubesphere.io/advanced-v2.0/zh-CN/api-reference/api-docs/) for more information.
## Code conventions
Please reference [Code conventions](https://github.com/kubernetes/community/blob/master/contributors/guide/coding-conventions.md) and follow with the rules.
**Note:**
> - All new packages and most new significant functionality must come with unit tests
> - Comment your code in English, see [Go's commenting conventions
](http://blog.golang.org/godoc-documenting-go-code)
......@@ -39,26 +39,26 @@ define ALL_HELP_INFO
# debugging tools like delve.
endef
.PHONY: all
all: hypersphere ks-apiserver ks-apigateway ks-iam controller-manager
all: test hypersphere ks-apiserver ks-apigateway ks-iam controller-manager
# Build ks-apiserver binary
ks-apiserver: test
ks-apiserver: fmt vet
hack/gobuild.sh cmd/ks-apiserver
# Build ks-apigateway binary
ks-apigateway: test
ks-apigateway: fmt vet
hack/gobuild.sh cmd/ks-apigateway
# Build ks-iam binary
ks-iam: test
ks-iam: fmt vet
hack/gobuild.sh cmd/ks-iam
# Build controller-manager binary
controller-manager: test
controller-manager: fmt vet
hack/gobuild.sh cmd/controller-manager
# Build hypersphere binary
hypersphere: test
hypersphere: fmt vet
hack/gobuild.sh cmd/hypersphere
# Run go fmt against code
......
......@@ -17,7 +17,7 @@
## Screenshots
> Note: See the [Screenshots](docs/screenshots.md) of KubeSphere to have a most intuitive understanding of KubeSphere dashboard and features.
> Note: See the [Screenshots](docs/en/guides/screenshots.md) of KubeSphere to have a most intuitive understanding of KubeSphere dashboard and features.
<table>
......@@ -178,6 +178,7 @@ Please submit any KubeSphere bugs, issues, and feature requests to [KubeSphere G
## Contributing to the project
All members of the KubeSphere community must abide by [Code of Conduct](docs/code-of-conduct.md). Only by respecting each other can we develop a productive, collaborative community.
This [document](docs/en/guides/README.md) walks you through how to get started contributing KubeSphere.
How to submit a pull request to KubeSphere? See [Pull Request Instruction](docs/pull-requests.md).
......@@ -18,7 +18,7 @@ KubeSphere 已大规模服务于社区用户,广泛地应用在以容器为中
> 说明:KubeSphere 目前最新的版本为高级版 2.0.2,并且所有版本 100% 开源,关于 KubeSphere 更详细的介绍与说明请参阅 [产品介绍](https://docs.kubesphere.io/advanced-v2.0/zh-CN/introduction/intro/)。
点击 [KubeSphere 快览](docs/screenshots.md) 快速查看 KubeSphere UI;
点击 [KubeSphere 快览](docs/en/guides/screenshots.md) 快速查看 KubeSphere UI;
<table>
<tr>
......
# Architecture
Basic idea is to decouple application repository and runtime environment. The runtime environment an application can run is by matching the labels of runtime environment and the selector of the repository where the application is from.
## Design key points:
// Copyright 2017 The OpenPitrix Authors. All rights reserved.
// Use of this source code is governed by a Apache license
// that can be found in the LICENSE file.
// dot -Tpng -o output.png input.dot
digraph G {
rankdir = LR;
subgraph clusterClient {
node [
fixedsize = true,
width = 1, height = 1,
]
WebUI [shape = doublecircle];
MobileApp [shape = doublecircle];
XClient [shape = doublecircle];
}
WebUI -> ApiGateway[
label = "rest api",
dir = both,
style = bold,
];
MobileApp -> ApiGateway[
label = "rest api",
dir = both,
style = bold,
];
XClient -> ApiGateway[
label = "rest api",
dir = both,
style = bold,
];
subgraph clusterOpenpitrix {
// rest api gateway
ApiGateway [shape = rect,
fixedsize = true,
width = 1.4, height = 6.2,
];
// microservice
subgraph clusterServices {
node [
shape=record,
fixedsize = true,
width = 2.6, height = 1.3,
];
Cluster [shape = Mrecord];
Runtime [shape = Mrecord,
label="Runtime |{ plugin |{k8s|QingCloud|Other} }"
];
App [shape = Mrecord];
Repo [shape = Mrecord];
}
// service database
subgraph clusterDB {
node [
fixedsize = true,
width = 2.6, height = 1.3,
];
RepoDB [shape = cylinder];
AppDB [shape = cylinder];
RuntimeDB [shape = cylinder];
ClusterDB [shape = cylinder];
}
// api gateway
ApiGateway -> Cluster [
label = "grpc",
dir = both,
style = bold,
];
ApiGateway -> Repo [
label = "grpc",
dir = both,
style = bold,
];
ApiGateway -> App [
label = "grpc",
dir = both,
style = bold,
];
ApiGateway -> Runtime [
label = "grpc",
dir = both,
style = bold,
];
Repo -> RepoDB [label="SQL"];
App -> AppDB [label="SQL"];
Runtime -> RuntimeDB [label="SQL"];
Cluster -> ClusterDB [label="SQL"];
}
}
# Concepts and Designs
Concepts and Designs help you to learn and understand the KubeSphere and the landscape.
## What is Kubesphere ?
- [Overview and Core concepts](overview.md). Provides a high-level description and introduction, including the problems the project solves.
- Project Goals. Provides the goals, which KubeSphere is trying to focus and provide features about them.
After you read the above documents, you should understand the KubeSphere basic goals. Now, you can choose which following parts you are interested, then dive in.
### KubeSphere Core
### KubeSphere Installer
### KubeSphere UI
TODO: UI opensource is on the way
### KubeSphere Application Management
TODO(@pengcong)
### KubeSphere Service Mesh
TODO(@zryfish)
## Porter
TODO(@magicsong)
### KubeSphere Networking
TODO
### KubeSphere DevOps
TODO(@runzexia)
### KubeSphere S2I/B2I
TODO(@soulseen)
### KubeSphere Monitoring
TODO(@huanggze)
### KubeSphere Logging
TODO(@huanggze)
### KubeSphere Altering
TODO
### KubeSphere Notification
TODO
# Overview
KubeSphere is a multi-tenant cluster management platform which is based on Kubernetes. KubeSphere provides easy-to-use UI to reduce your learning cost for employing the container management platform and make it easier to develop, test and maintain your daily work. It's aimed to resolve the problems relating to Kubernetes’ storage, network, security and its usability.
In addition, the platform has integrated and optimized a range of functional modules which are suitable for containers. KubeSphere provides enterprises with a complete solution for development, automation operation and maintenance, microservice governance, multi-tanency management. Besides, our platform is also able to manage workload, container cluster, service and network, application orchestration as well as database mirroring and storage.
<table>
<tr>
<td width="50%" align="center"><b>KubeSphere Dashboard</b></td>
<td width="50%" align="center"><b>Project Resources</b></td>
</tr>
<tr>
<td><img src="https://pek3b.qingstor.com/kubesphere-docs/png/20190925003707.png"/></td>
<td><img src="https://pek3b.qingstor.com/kubesphere-docs/png/20190925003504.png"/></td>
</tr>
<tr>
<td width="50%" align="center"><b>CI/CD Pipeline</b></td>
<td width="50%" align="center"><b>Application Template</b></td>
</tr>
<tr>
<td><img src="https://pek3b.qingstor.com/kubesphere-docs/png/20190925000712.png"/></td>
<td><img src="https://pek3b.qingstor.com/kubesphere-docs/png/20190925231623.png"/></td>
</tr>
</table>
## Architecture
KubeSphere adopts the separation of front and back ends, also realizes a cloud native design, the back ends' service components can communicate with external systems through the REST API, see [API documentation](https://kubesphere.io/docs/v2.0/api/kubesphere) for more details. All component are included in the architecture diagram below. KubeSphere can run anywhere from on-premise datacenter to any cloud to edge. In addition, it can be deployed on any Kubernetes distribution.
![](https://pek3b.qingstor.com/kubesphere-docs/png/20190810073322.png)
# Development Workflow
![ks-workflow](docs/images/ks-workflow.png)
## 1 Fork in the cloud
1. Visit https://github.com/kubesphere/kubesphere
2. Click `Fork` button to establish a cloud-based fork.
## 2 Clone fork to local storage
Per Go's [workspace instructions](https://golang.org/doc/code.html#Workspaces), place KubeSphere' code on your `GOPATH` using the following cloning procedure.
1. Define a local working directory:
```bash
$ export working_dir=$GOPATH/src/kubesphere.io
$ export user={your github profile name}
```
2. Create your clone locally:
```bash
$ mkdir -p $working_dir
$ cd $working_dir
$ git clone https://github.com/$user/kubesphere.git
$ cd $working_dir/kubesphere
$ git remote add upstream https://github.com/kubesphere/kubesphere.git
# Never push to upstream master
$ git remote set-url --push upstream no_push
# Confirm that your remotes make sense:
$ git remote -v
```
## 3 Keep your branch in sync
```bash
git fetch upstream
git checkout master
git rebase upstream/master
```
## 4 Add new features or fix issues
Branch from it:
```bash
$ git checkout -b myfeature
```
Then edit code on the myfeature branch.
**Test and build**
Currently, make rules only contain simple checks such as vet, unit test, will add e2e tests soon.
**Using KubeBuilder**
- For Linux OS, you can download and execute this [KubeBuilder script](https://raw.githubusercontent.com/kubesphere/kubesphere/master/hack/install_kubebuilder.sh).
- For MacOS, you can install KubeBuilder by following this [guide](https://book.kubebuilder.io/quick-start.html).
**Run and test**
```bash
$ make all
# Run every unit test
$ make test
```
Run `make help` for additional information on these make targets.
### 5 Development in new branch
**Sync with upstream**
After the test is completed, suggest you to keep your local in sync with upstream which can avoid conflicts.
```
# Rebase your the master branch of your local repo.
$ git checkout master
$ git rebase upstream/master
# Then make your development branch in sync with master branch
git checkout new_feature
git rebase -i master
```
**Commit local changes**
```bash
$ git add <file>
$ git commit -s -m "add your description"
```
### 6 Push to your folk
When ready to review (or just to establish an offsite backup or your work), push your branch to your fork on github.com:
```
$ git push -f ${your_remote_name} myfeature
```
### 7 Create a PR
- Visit your fork at https://github.com/$user/kubesphere
- Click the` Compare & Pull Request` button next to your myfeature branch.
- Check out the [pull request process](pull-request.md) for more details and advice.
# How to build KubeSphere?
This document walks you through how to get started with building KubeSphere in your local environment.
## Preparing the environment
### Go
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).
| Kubernetes | requires Go |
|----------------|-------------|
| 1.13+ | >= 1.12 |
> 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.
### Docker
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.
## Building Other Module of KubeSphere
Kubesphere has some pluggable modules such as ServiceMesh, DevOps, Logging, OpenPitrix ...
Some of these modules have their unique build methods, refer to the their documentation accordingly.
# Connect to remote service with telepresence
Telepresence is an open source tool that lets you run a single service locally, while connecting that service to a remote Kubernetes cluster.
We can use telepresence to help us running KubeSphere apiserver locally.
## 1. Install telepresence
You can read the [official installation documentation](https://www.telepresence.io/reference/install.html) to install telepresence.
## 2. Run telepresence
Open your command line and run the command `telepresence`, telepresence will help you to enter a bash connected to a remote Kubernetes cluster.
Test telepresence with KubeSphere apigateway:
```bash
@kubernetes-admin@cluster.local|bash-3.2$ curl http://ks-apigateway.kubesphere-system
401 Unauthorized
```
## 3. Run your module in bash
Now your module can easily connect to remote services.
```bash
go run cmd/ks-apiserver/apiserver.go
```
## 4. Further more
You can use telepresence to replace services in the cluster for debugging. For more information, please refer to the [official documentation](https://www.telepresence.io/discussion/overview).
# How to run KubeSphere core in local
This document will explain how to run KubeSphere apiserver locally.
> Modules similar to KubeSphere apiserver are KubeSphere controller-manageer, Kubesphere iam (also known as KubeSphere account), KubeSphere api-gateway.
> If you need to run these modules locally, you can refer to this document for configuration.
## Prepare: Build KubeSphere Core component
In the document [How-to-build](How-to-build.md) We learned how to build KubeSphere locally. Make sure you could build KubeSphere Core modules accordingly.
## 1. Set up a Kubernetes cluster with KubeSphere installed
KubeSphere relies on some external modules during development, and these modules are already included in the installed KubeSphere.
You can quickly install a KubeSphere cluster by referring to this [documentation] (https://kubesphere.io/en/install).
## 2. Use kubectl to access the development cluster locally
You can refer to this [document](https://kubernetes.io/docs/tasks/tools/install-kubectl/) to install and configure kubectl locally.
## 3. Understand KubeSphere Core's configuration
KubeSphere uses [viper](https://github.com/spf13/viper) to manage the configuration. KubeSphere supports setting up using command line arguments and configuration files.
> We recommend that you use a configuration file for configuration during local development.
KubeSphere apiserver needs to communicate with many modules. When you run Kubesphere, you can choose to configure the seperate modules only you care about.
During the development of KubeSphere apiserver, you must configure at least the relevant part of Kubernetes to ensure that KubeSphere apiserver can be started.
Below is a sample configuration of KubeSphere apiserver:
> Note: In the default configuration, we use Kubernetes service name to access the service.
> In a remote cluster, you may need to use external network exposure to connect to the cluster's internal services.
> Or you can refer to the [documentation](How-to-connect-remote-service.md) to use `telepresence` to connect to remote services
```yaml
kubernetes:
kubeconfig: "/Users/kubesphere/.kube/config"
master: https://192.168.0.8:6443
qps: 1e+06
burst: 1000000
ldap:
host: openldap.kubesphere-system.svc:389
managerDN: cn=admin,dc=kubesphere,dc=io
managerPassword: admin
userSearchBase: ou=Users,dc=kubesphere,dc=io
groupSearchBase: ou=Groups,dc=kubesphere,dc=io
redis:
host: redis.kubesphere-system.svc
port: 6379
password: ""
db: 0
s3:
endpoint: http://minio.kubesphere-system.svc:9000
region: us-east-1
disableSSL: true
forcePathStyle: true
accessKeyID: openpitrixminioaccesskey
secretAccessKey: openpitrixminiosecretkey
bucket: s2i-binaries
mysql:
host: mysql.kubesphere-system.svc:3306
username: root
password: password
maxIdleConnections: 100
maxOpenConnections: 100
maxConnectionLifeTime: 10s
devops:
host: http://ks-jenkins.kubesphere-devops-system.svc/
username: admin
password: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImFkbWluQGt1YmVzcGhlcmUuaW8iLCJleHAiOjE4MTYyMzkwMjIsInVzZXJuYW1lIjoiYWRtaW4ifQ.okmNepQvZkBRe1M8z2HAWRN0AVj9ooVu79IafHKCjZI
maxConnections: 100
sonarQube:
host: http://192.168.0.8:32297
token: 4e51de276f1fd0eb3a20b58e523d43ce76347302
openpitrix:
runtimeManagerEndpoint: "openpitrix-runtime-manager.openpitrix-system.svc:9103"
clusterManagerEndpoint: "openpitrix-cluster-manager.openpitrix-system.svc:9104"
repoManagerEndpoint: "openpitrix-repo-manager.openpitrix-system.svc:9101"
appManagerEndpoint: "openpitrix-app-manager.openpitrix-system.svc:9102"
categoryManagerEndpoint: "openpitrix-category-manager.openpitrix-system.svc:9113"
attachmentManagerEndpoint: "openpitrix-attachment-manager.openpitrix-system.svc:9122"
repoIndexerEndpoint: "openpitrix-repo-indexer.openpitrix-system.svc:9108"
monitoring:
endpoint: http://prometheus-k8s.kubesphere-monitoring-system.svc:9090
secondaryEndpoint: http://prometheus-k8s-system.kubesphere-monitoring-system.svc:9090
logging:
host: http://elasticsearch-logging-data.kubesphere-logging-system.svc.cluster.local:9200
indexPrefix: ks-logstash-log
alerting:
endpoint: http://alerting.kubesphere-alerting-system.svc
notification:
endpoint: http://notification.kubesphere-alerting-system.svc
```
## 4. Set Up KubeSphere Core's configuration
The KubeSphere Core module will read the `kubesphere.yaml` file in the current directory and the `kubesphere.yaml` file in the `/etc/kubesphere` directory, then load the configuration at startup.
You can choose a path to set your configuration locally.
## 5. Run KubeSphere apiserver
You can execute `go run cmd/ks-apiserver/apiserver.go` in the `$GOPATH/src/kubesphere.io/kubesphere` directory to start KubeSphere apiserver
> If you want to understand the specific meaning of each configuration, you can view it by `go run cmd/ks-apiserver/apiserver.go --help` or read the module's design and developer documentation.
# Guides
There are many ways that you can help the KubeSphere community.
- Go through our documents, point out or fix unclear things. Translate the documents to other languages.
- Install our [releases](https://kubesphere.io/en/install), try to manage your `kubernetes` cluster with `kubesphere`, and feedback to us about
what you think.
- Read our source codes, Ask questions for details.
- Find kubesphere bugs, [submit issue](https://github.com/kubesphere/kubesphere/issues), and try to fix it.
- Find kubesphere installer bugs, [submit issue](https://github.com/kubesphere/ks-installer/issues), and try to fix it.
- Find [help wanted issues](https://github.com/kubesphere/kubesphere/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22),
which are good for you to start.
- Submit issue or start discussion through [GitHub issue](https://github.com/kubesphere/kubesphere/issues/new).
- See all forum discussion through [website](https://kubesphere.io/forum/).
## Contact Us
All the following channels are open to the community, you could choose the way you like.
* Submit an [issue](https://github.com/kubesphere/kubesphere/issues)
* See all forum discussion through [website](https://kubesphere.io/forum/).
* Join us at [Slack Channel](https://join.slack.com/t/kubesphere/shared_invite/enQtNTE3MDIxNzUxNzQ0LTZkNTdkYWNiYTVkMTM5ZThhODY1MjAyZmVlYWEwZmQ3ODQ1NmM1MGVkNWEzZTRhNzk0MzM5MmY4NDc3ZWVhMjE).
## For code developer
1. Learn about kubesphere's Concepts And Designs and how to build kubesphere locally
For developers, first step, read [Concepts And Designs](../concepts-and-designs/README.md) and [Compiling Guide](How-to-build.md).
Concepts And Designs describes the role of each component in kubesphere and the relationship between them.
Compiling Guide teaches developer how to build the project in local and set up the environment.
2. Understand the workflow of kubesphere development.
Read [Development Workflow](Development-workflow.md).
3. Understand the best practices for submitting PR and our code of conduct
Read [best practices for submitting PR](pull-requests.md).
Read [code of conduct](code-of-conduct.md).
### KubeSphere Core developer
### KubeSphere Installer developer
### UI developer
TODO: UI opensource is on the way
### KubeSphere Application Management developer
TODO(@pengcong)
### KubeSphere Service Mesh developer
TODO(@zryfish)
### Porter developer
TODO(@magicsong)
### KubeSphere Networking developer
### KubeSphere DevOps developer
TODO(@runzexia)
### KubeSphere S2I/B2I developer
TODO(@soulseen)
### KubeSphere Monitoring developer
TODO(@huanggze)
### KubeSphere Logging developer
TODO(@huanggze)
### KubeSphere Altering developer
TODO
### KubeSphere Notification developer
TODO
# Developing for KubeSphere [deprecated]
This document is intended to be the canonical source of truth for things like
supported toolchain versions for building KubeSphere.
If you find a requirement that this doc does not capture, or if you find other
docs with references to requirements that are not simply links to this doc,
please [submit an issue](https://github.com/kubesphere/kubesphere/issues/new).
This document is intended to be relative to the branch in which it is found.
It is guaranteed that requirements will change over time for the development
branch, but release branches should not change.
- [Prerequisites](#prerequisites)
- [Setting up Go](#setting-up-go)
- [To start developing KubeSphere](#to-start-developing-kubesphere)
- [DevOps](#devops)
## Prerequisites
KubeSphere only has few external dependencies you need to setup before being
able to build and run the code.
### Setting up Go
KubeSphere written in the [Go](http://golang.org) programming language.
To build, you'll need a Go (version 1.9+) 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.
Set up your GOPATH and add a path entry for Go binaries to your PATH. Typically
added to your ~/.profile:
```shell
$ export GOPATH=~/go
$ export PATH=$PATH:$GOPATH/bin
```
## To start developing KubeSphere
There are two options to get KubeSphere source code and build the project:
**You have a working Go environment.**
```shell
$ go get -d kubesphere.io/kubesphere
$ cd $GOPATH/src/kubesphere.io/kubesphere
$ make all
```
**You have a working Docker environment.**
```shell
$ git clone https://github.com/kubesphere/kubesphere
$ cd kubesphere
$ make
```
Welcome to KubeSphere! (New Developer Guide)
============================================
_This document assumes that you know what KubeSphere does.
Introduction
------------
This
document will help you understand the organization of the KubeSphere project and
direct you to the best places to get started. By the end of this doc, you'll be
able to pick up issues, write code to fix them, and get your work reviewed and
merged.
If you have questions about the development process, feel free to jump into our
[Slack workspace](http://KubeSphere.slack.com/). If you join the
Slack workspace it is recommended to set your Slack display name to your GitHub
account handle.
Downloading, Building, and Testing KubeSphere
---------------------------------------------
This guide is non-technical, so it does not cover the technical details of
working KubeSphere. We have plenty of documentation available under
[docs.kubesphere.io](https://docs.kubesphere.io).
Pull-Request Process
--------------------
The pull-request process is documented in [pull-requests.md](pull-requests.md).
As described in that document, you must sign the CLA before
KubeSphere can accept your contribution.
Thanks for reading!
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册