-
Notifications
You must be signed in to change notification settings - Fork 442
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates to the apiserver swagger-ui (#1410)
Updates to the apiserver swagger-ui
- Loading branch information
Showing
22 changed files
with
381 additions
and
230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ Typing `make dev-tools` will download and install all of them. The `make clean-d | |
| kustomize | v3.8.7 | [install](https://kubectl.docs.kubernetes.io/installation/kustomize/) | | ||
| gofumpt | v0.3.1 | To install `go install mvdan.cc/[email protected]` | | ||
| goimports | latest | To install `go install golang.org/x/tools/cmd/goimports@latest` | | ||
| go-bindata | v4.0.2 | To install `github.com/kevinburke/go-bindata/v4/[email protected]` | | ||
|
||
## Purpose | ||
|
||
|
@@ -60,6 +61,52 @@ make build | |
make test | ||
``` | ||
|
||
#### Swagger UI updates | ||
|
||
To update the swagger ui files deployed with the Kuberay API server, you'll need to: | ||
|
||
* Manually run the [hack/update-swagger-ui.bash](hack/update-swagger-ui.bash) script. The script downloads the swagger ui release and copies the downloaded files | ||
to the [../third_party/swagger-ui](../third_party/swagger-ui/) directory. It copies the [swagger-initializer.js](../third_party/swagger-ui/swagger-initializer.js) | ||
to [swagger-initializer.js.backup](../third_party/swagger-ui/swagger-initializer.js.backup). | ||
* Update the contents of the [swagger-initializer.js](../third_party/swagger-ui/swagger-initializer.js) to set the URLs for for the individual swagger docs. The content of the file is show below: | ||
|
||
```javascript | ||
window.onload = function() { | ||
//<editor-fold desc="Changeable Configuration Block"> | ||
|
||
// the following lines will be replaced by docker/configurator, when it runs in a docker-container | ||
window.ui = SwaggerUIBundle({ | ||
spec: location.host, | ||
urls: [{"url":"http://"+location.host+"/swagger/serve.swagger.json","name":"RayServe Service"}, | ||
{"url":"http://"+location.host+"/swagger/error.swagger.json","name":"Errors API"}, | ||
{"url":"http://"+location.host+"/swagger/job.swagger.json","name":"RayJob Service"}, | ||
{"url":"http://"+location.host+"/swagger/config.swagger.json","name":"ComputeTemplate Service"}, | ||
{"url":"http://"+location.host+"/swagger/cluster.swagger.json","name":"Cluster Service"}], | ||
dom_id: '#swagger-ui', | ||
deepLinking: true, | ||
presets: [ | ||
SwaggerUIBundle.presets.apis, | ||
SwaggerUIStandalonePreset | ||
], | ||
plugins: [ | ||
SwaggerUIBundle.plugins.DownloadUrl | ||
], | ||
layout: "StandaloneLayout" | ||
}); | ||
|
||
//</editor-fold> | ||
}; | ||
``` | ||
|
||
* Execute `make build-swagger` target to update the contents of the [datafile.go](pkg/swagger/datafile.go) file. This will package the content of the [swagger-ui](../third_party/swagger-ui/) directory for serving by the api server (see [func serveSwaggerUI(mux *http.ServeMux)](https://github.com/ray-project/kuberay/blob/f1067378bc99987f3eba1e5b12b4cc797465336d/apiserver/cmd/main.go#L149) in [main.go](cmd/main.go)) | ||
|
||
The swagger ui is available at the following URLs: | ||
|
||
* [local service -- http://localhost:8888/swagger-ui/](http://localhost:8888/swagger-ui/) | ||
* [kind cluster -- http://localhost:31888/swagger-ui/](http://localhost:31888/swagger-ui/) | ||
|
||
Please note that for the local service the directory containing the `*.swagger.files` is specified using the `-localSwaggerPath` command line argument. The `make run` command sets the value correctly. | ||
|
||
#### Start Local Service | ||
|
||
This will start the api server on your development machine. The golang race detector is turned on when starting the api server this way. It will use Kubernetes configuration file located at `~/.kube/config`. The service will not start if you do not have a connection to a Kubernetes cluster. | ||
|
@@ -110,7 +157,7 @@ make uninstall | |
|
||
As a convenience for local development the following `make` targets are provided: | ||
|
||
* `make cluster` -- creates a local kind cluster, using the configuration from `hack/kind-cluster-config.yaml`. It creates a port mapping allowing for the service running in the kind cluster to be accessed on `localhost:318888` for HTTP and `localhost:318887` for RPC. | ||
* `make cluster` -- creates a local kind cluster, using the configuration from `hack/kind-cluster-config.yaml`. It creates a port mapping allowing for the service running in the kind cluster to be accessed on `localhost:31888` for HTTP and `localhost:31887` for RPC. | ||
* `make clean-cluster` -- deletes the local kind cluster created with `make cluster` | ||
* `load-image` -- loads the docker image defined by the `IMG` make variable into the kind cluster. The default value for variable is: `kuberay/apiserver:latest`. The name of the image can be changed by using `make load-image -e IMG=<your image name and tag>` | ||
* `operator-image` -- Build the operator image to be loaded in your kind cluster. The tag for the operator image is `kuberay/operator:latest`. This step is optional. | ||
|
@@ -130,4 +177,4 @@ make docker-image operator-image cluster load-image load-operator-image deploy d | |
|
||
#### Access API Server in the Cluster | ||
|
||
Access the service at `localhost:318888` for http and `locahost:318887` for the RPC port. | ||
Access the service at `localhost:31888` for http and `locahost:31887` for the RPC port. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
set -e | ||
set -x | ||
readonly REPO_ROOT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )"/../.. &> /dev/null && pwd) | ||
readonly TARGET_DIR="${REPO_ROOT_DIR}/third_party/swagger-ui" | ||
readonly SWAGGER_UI_VERSION=${1:-"5.4.1"} | ||
readonly SWAGGER_UI_TAR_URL="https://github.com/swagger-api/swagger-ui/archive/refs/tags/v${SWAGGER_UI_VERSION}.tar.gz" | ||
|
||
if [ -f ${TARGET_DIR}/swagger-initializer.js ];then | ||
cp -v ${TARGET_DIR}/swagger-initializer.js ${TARGET_DIR}/swagger-initializer.js.backup | ||
fi | ||
echo "Downloading '${SWAGGER_UI_TAR_URL}' to update ${TARGET_DIR}" | ||
tmp="$(mktemp -d)" | ||
#pushd . | ||
curl --output-dir ${tmp} --fail --silent --location --remote-header-name --remote-name ${SWAGGER_UI_TAR_URL} | ||
tar -xzvf ${tmp}/swagger-ui-${SWAGGER_UI_VERSION}.tar.gz -C ${tmp} | ||
#popd | ||
cp -rv "$tmp/swagger-ui-${SWAGGER_UI_VERSION}/dist/"* "${TARGET_DIR}" | ||
rm -rf "$tmp" | ||
|
Oops, something went wrong.