-
Notifications
You must be signed in to change notification settings - Fork 455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add REST API using grpc gateway #142
Conversation
@YujiOshima - is there any advantage of checking-in the vendor folder with Katib? Checking in gopkg.lock and gopkg.toml should be sufficient. The PRs will be easier to look at that way, and any needed vendor packages can be downloaded locally based on lock/toml and without needing the vendor folder checked-in. |
@mayankjuneja Thank you for the great contribution! I will take a look. Could you add some documents for REST? @vinaykakade There is no exactry answer. https://github.com/golang/dep/blob/master/docs/FAQ.md#should-i-commit-my-vendor-directory |
/ok-to-test |
/assign YujiOshima |
@YujiOshima sure, I will add some documentation/comments. |
@@ -1 +1,3 @@ | |||
docker run -it --rm -v $PWD:$(pwd) -w $(pwd) znly/protoc --python_out=plugins=grpc:./python --go_out=plugins=grpc:. -I. api.proto | |||
docker run -it --rm -v $PWD:$(pwd) -w $(pwd) znly/protoc --grpc-gateway_out=logtostderr=true:. -I. api.proto |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
building the grpc gateway and swagger stub files
scripts/build.sh
Outdated
@@ -28,6 +28,9 @@ cd ${SCRIPT_ROOT} | |||
echo "Building core image..." | |||
docker build -t ${PREFIX}/vizier-core -f ${CMD_PREFIX}/manager/Dockerfile . | |||
|
|||
echo "Building REST API for core image..." | |||
docker build -t ${PREFIX}/vizier-core-rest -f ${CMD_PREFIX}/manager_rest/Dockerfile . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
build the image for manager REST API. it will be a separate service running in kubernetes.
@YujiOshima I added some comments in the code and in this PR as well. Let me know if I should add more details. |
Thank you! |
Any update on this? Would be great to get it committed? |
@YujiOshima I did another pass and made the following changes:
Can you review these changes? Thanks! |
manifests/vizier/core-rest/rbac.yaml
Outdated
@@ -0,0 +1,37 @@ | |||
--- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since core-rest does not need to manage k8s resources, the rbac looks unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, thanks for catching this!
docs/rest-api.md
Outdated
For each RPC service, we define an equivalent HTTP REST API method using [grpc-gateway](https://github.com/grpc-ecosystem/grpc-gateway). The mapping between service and REST API method can be found in this [file](https://github.com/kubeflow/katib/blob/master/pkg/api/api.proto). The mapping includes the URL path, query parameters and request body. You can read more details on the supported methods and binding options at this [link](https://cloud.google.com/service-infrastructure/docs/service-management/reference/rpc/google.api#http) | ||
|
||
## Examples | ||
Assuming `{HOST}` as the ingress host for vizier-core-rest, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a way of using portforward.
kubectl v1.10~
$ kubectl -n katib port-forward svc/vizier-core-rest 8080:80
kubectl ~v1.9
& kubectl -n katib port-forward $(kubectl -n katib get pod -o=name | grep vizier-core-rest | sed -e "s@pods\/@@") 8080:80
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add this.
docs/rest-api.md
Outdated
Request: | ||
|
||
```shell | ||
curl -X POST {HOST}/api/Manager/CreateStudy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Write explicitly to use above json file.
curl -X POST {HOST}/api/Manager/CreateStudy -d @study_config.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, missed the argument here.
@mayankjuneja Thank for the great contribution! |
@YujiOshima thanks for the review! I added some changes based on your comments. Let me know if it looks good. |
@mayankjuneja Thanks! |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: YujiOshima The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest |
@mayankjuneja I think you need to remove |
@YujiOshima The tests passed now, can you please reapprove it? |
/lgtm |
🎉🎉🎉🎉🎉🎉🎉 |
Hi @YujiOshima, @jlewi,
We have been using Katib internally and one of the changes we have done is to expose core service as REST APIs (using grpc-gateway). I think this might be useful for others as well (issues #117, #118).
Side note - You might notice a lot of changes to vendor dir (these are mostly deletions). Doing a
dep ensure
cleaned up some of the unused packages. If there are other best practices around this, please let me know. I can also create a separate PR to clean up the unused packages.This change is