This document will explain how to run KubeSphere apiserver locally.
> Modules similar to KubeSphere apiserver are KubeSphere controller-manageer, Kubesphere iam (Aka 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 and the previous documentation can build KubeSphere Core modules.
## 1. Set up a k8s 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 need to run Kubesphere, you can choose to configure only the modules 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:
The KubeSphere Core module will read the `kubesphere.yaml` file in the current directory and the `kubesphere.yaml` file in the `/etc/kubesphere` directory to 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.