Skip to content

Commit ce3850a

Browse files
dandawghbelmiro
andauthored
docs(backend): improved backend README (kubeflow#11511)
* improved backend README Signed-off-by: Daniel Dowler <[email protected]> * Update backend/README.md Co-authored-by: Helber Belmiro <[email protected]> Signed-off-by: Daniel Dowler <[email protected]> * Update backend/README.md Co-authored-by: Helber Belmiro <[email protected]> Signed-off-by: Daniel Dowler <[email protected]> * Update backend/README.md Co-authored-by: Helber Belmiro <[email protected]> Signed-off-by: Daniel Dowler <[email protected]> * Update backend/README.md Co-authored-by: Helber Belmiro <[email protected]> Signed-off-by: Daniel Dowler <[email protected]> --------- Signed-off-by: Daniel Dowler <[email protected]> Co-authored-by: Helber Belmiro <[email protected]>
1 parent 37a7b4e commit ce3850a

File tree

1 file changed

+52
-42
lines changed

1 file changed

+52
-42
lines changed

backend/README.md

Lines changed: 52 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
1+
# Kubeflow Pipelines Backend
2+
3+
## Overview
4+
15
This directory contains code for the components that comprise the Kubeflow
26
Pipelines backend.
37

8+
This README will help you set up your coding environment in order to build and run the Kubeflow Pipelines backend. The KFP backend powers the core functionality of the KFP platform, handling API requests, workflow management, and data persistence.
9+
10+
## Prerequisites
11+
Before you begin, ensure you have:
12+
- Go programming language installed
13+
- [go-licenses tool](../hack/install-go-licenses.sh)
14+
- Docker or Podman installed (for building container images)
15+
16+
Note that you may need to restart your shell after installing these resources in order for the changes to take effect.
17+
418
## Building & Testing
519

620
To run all unittests for backend:
@@ -15,64 +29,46 @@ The API server itself can be built using:
1529
go build -o /tmp/apiserver backend/src/apiserver/*.go
1630
```
1731

18-
## Code Style
19-
20-
Backend codebase follows the [Google's Go Style Guide](https://google.github.io/styleguide/go/). Please, take time to get familiar with the [best practices](https://google.github.io/styleguide/go/best-practices). It is not intended to be exhaustive, but it often helps minimizing guesswork among developers and keep codebase uniform and consistent.
21-
22-
We use [golangci-lint](https://golangci-lint.run/) tool that can catch common mistakes locally (see detailed configuration [here](https://github.com/kubeflow/pipelines/blob/master/.golangci.yaml)). It can be [conveniently integrated](https://golangci-lint.run/usage/integrations/) with multiple popular IDEs such as VS Code or Vim.
23-
24-
Finally, it is advised to install [pre-commit](https://pre-commit.com/) in order to automate linter checks (see configuration [here](https://github.com/kubeflow/pipelines/blob/master/.pre-commit-config.yaml))
25-
26-
## Building APIServer image locally
27-
2832
The API server image can be built from the root folder of the repo using:
2933
```
3034
export API_SERVER_IMAGE=api_server
3135
docker build -f backend/Dockerfile . --tag $API_SERVER_IMAGE
3236
```
33-
## Deploy APIServer with the image you own build
37+
### Deploying the APIServer (from the image you built) on Kubernetes
3438

35-
Run
39+
First, push your image to a registry that is accessible from your Kubernetes cluster.
40+
41+
Then, run:
3642
```
3743
kubectl edit deployment.v1.apps/ml-pipeline -n kubeflow
3844
```
39-
You'll see the field reference the api server docker image.
45+
You'll see the field reference the api server container image (`spec.containers[0].image: gcr.io/ml-pipeline/api-server:<image-version>`).
4046
Change it to point to your own build, after saving and closing the file, apiserver will restart with your change.
4147

42-
## Building client library and swagger files
48+
### Building client library and swagger files
4349

4450
After making changes to proto files, the Go client libraries, Python client libraries and swagger files
4551
need to be regenerated and checked-in. Refer to [backend/api](./api/README.md) for details.
4652

47-
## Updating licenses info
48-
49-
1. [Install go-licenses tool](../hack/install-go-licenses.sh) and refer to [its documentation](https://github.com/google/go-licenses) for how to use it.
53+
### Updating licenses info
5054

55+
1. [Install go-licenses tool](../hack/install-go-licenses.sh) (if you haven't already) and refer to [its documentation](https://github.com/google/go-licenses) for how to use it.
5156

5257
2. Run the tool to update all licenses:
5358

5459
```bash
55-
make all
60+
make -C backend all
5661
```
5762

58-
## Updating python dependencies
59-
60-
[pip-tools](https://github.com/jazzband/pip-tools) is used to manage python
61-
dependencies. To update dependencies, edit [requirements.in](requirements.in)
62-
and run `./update_requirements.sh` to update and pin the transitive
63-
dependencies.
64-
65-
# Visualization Server Instructions
66-
67-
## Updating python dependencies
63+
### Updating python dependencies
6864

6965
[pip-tools](https://github.com/jazzband/pip-tools) is used to manage python
7066
dependencies. To update dependencies, edit [requirements.in](requirements.in)
7167
and run `./update_requirements.sh` to update and pin the transitive
7268
dependencies.
7369

7470

75-
## Building conformance tests (WIP)
71+
### Building conformance tests (WIP)
7672

7773
Run
7874
```
@@ -81,7 +77,7 @@ docker build . -f backend/Dockerfile.conformance -t <tag>
8177
8278
## API Server Development
8379
84-
### Run Locally With a Kind Cluster
80+
### Run the KFP Backend Locally With a Kind Cluster
8581
8682
This deploys a local Kubernetes cluster leveraging [kind](https://kind.sigs.k8s.io/), with all the components required
8783
to run the Kubeflow Pipelines API server. Note that the `ml-pipeline` `Deployment` (API server) has its replicas set to
@@ -99,6 +95,7 @@ pods on the cluster using the `ml-pipeline` `Service`.
9995
network interface through Docker/Podman Desktop. See
10096
[kind #1200](https://github.com/kubernetes-sigs/kind/issues/1200#issuecomment-1304855791) for an example manifest.
10197
* Optional: VSCode is installed to leverage a sample `launch.json` file.
98+
* This relies on dlv: (go install -v github.com/go-delve/delve/cmd/dlv@latest)
10299
103100
#### Provisioning the Cluster
104101
@@ -111,15 +108,9 @@ make -C backend dev-kind-cluster
111108
This may take several minutes since there are many pods. Note that many pods will be in "CrashLoopBackOff" status until
112109
all the pods have started.
113110

114-
#### Deleting the Cluster
115-
116-
Run the following to delete the cluster:
111+
Also, note that the config in the `make` command above sets the `ml-pipeline` `Deployment` (api server) to have 0 replicas. The intent is to replace it with a locally running API server for debugging and faster development. See the following steps to run the API server locally, and connect it to the KFP backend on your Kind cluster. Note that other backend components (for example, the persistence agent) may show errors until the API server is brought up and connected to the cluster.
117112

118-
```bash
119-
kind delete clusters dev-pipelines-api
120-
```
121-
122-
#### Launch the API Server With VSCode
113+
#### Launching the API Server With VSCode
123114

124115
After the cluster is provisioned, you may leverage the following sample `.vscode/launch.json` file to run the API
125116
server locally:
@@ -168,12 +159,12 @@ You can also directly connect to the MariaDB database server with:
168159
mysql -h 127.0.0.1 -u root
169160
```
170161

171-
## Remote Debug the Driver
162+
### Remote Debug the Driver
172163

173164
These instructions assume you are leveraging the Kind cluster in the
174165
[Run Locally With a Kind Cluster](#run-locally-with-a-kind-cluster) section.
175166

176-
### Build the Driver Image With Debug Prerequisites
167+
#### Build the Driver Image With Debug Prerequisites
177168

178169
Run the following to create the `backend/Dockerfile.driver-debug` file and build the container image
179170
tagged as `kfp-driver:debug`. This container image is based on `backend/Dockerfile.driver` but installs
@@ -197,7 +188,7 @@ Alternatively, you can use this Make target that does both.
197188
make -C kind-build-and-load-driver-debug
198189
```
199190

200-
### Run the API Server With Debug Configuration
191+
#### Run the API Server With Debug Configuration
201192

202193
You may use the following VS Code `launch.json` file to run the API server which overrides the Driver
203194
command to use Delve and the Driver image to use debug image built previously.
@@ -229,7 +220,7 @@ command to use Delve and the Driver image to use debug image built previously.
229220
}
230221
```
231222

232-
### Starting a Remote Debug Session
223+
#### Starting a Remote Debug Session
233224

234225
Start by launching a pipeline. This will eventually create a Driver pod that is waiting for a remote debug connection.
235226

@@ -273,3 +264,22 @@ For debugging a specific Driver pod, you'll need to continuously port forward an
273264
without a breakpoint so that Delve will continue execution until the Driver pod you are interested in starts up. At that
274265
point, you can set a break point, port forward, and connect to the remote debug session to debug that specific Driver
275266
pod.
267+
268+
### Deleting the Kind Cluster
269+
270+
Run the following to delete the cluster (once you are finished):
271+
272+
```bash
273+
kind delete clusters dev-pipelines-api
274+
```
275+
276+
## Contributing
277+
### Code Style
278+
279+
Backend codebase follows the [Google's Go Style Guide](https://google.github.io/styleguide/go/). Please, take time to get familiar with the [best practices](https://google.github.io/styleguide/go/best-practices). It is not intended to be exhaustive, but it often helps minimizing guesswork among developers and keep codebase uniform and consistent.
280+
281+
We use [golangci-lint](https://golangci-lint.run/) tool that can catch common mistakes locally (see detailed configuration [here](https://github.com/kubeflow/pipelines/blob/master/.golangci.yaml)). It can be [conveniently integrated](https://golangci-lint.run/usage/integrations/) with multiple popular IDEs such as VS Code or Vim.
282+
283+
Finally, it is advised to install [pre-commit](https://pre-commit.com/) in order to automate linter checks (see configuration [here](https://github.com/kubeflow/pipelines/blob/master/.pre-commit-config.yaml))
284+
285+

0 commit comments

Comments
 (0)