Skip to content
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

Request kube apiserver directly from frontend #115

Merged

Conversation

momom-i
Copy link
Contributor

@momom-i momom-i commented Feb 21, 2022

What type of PR is this?

/kind feature

What this PR does / why we need it:

To request directry from frontend

Which issue(s) this PR fixes:

Fixes #95

Special notes for your reviewer:

@sanposhiho Thank you for answering my questions so many times.
After some discussion, we decided to fix the kube-apiserver URL and throw resource change requests directly to that URL.

I tried a few things and confirmed that it returned same results as previous implementation.
Please let me know if there is any part of the behavior that is different from the previous one.

Also I'd like to learn more so correcting my every little mistake is welcome!

/label tide/merge-method-squash

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 21, 2022
@k8s-ci-robot
Copy link
Contributor

Hi @momom-i. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 21, 2022
@sanposhiho
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 23, 2022
@sanposhiho
Copy link
Member

@momom-i Thanks for a great work. I'll review this in this weekend.

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Feb 24, 2022

CLA Signed

The committers are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. and removed cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Feb 24, 2022
@momom-i momom-i force-pushed the request-kube-apiserver-directly branch from f7af902 to d02f3d8 Compare February 24, 2022 12:43
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Feb 24, 2022
@momom-i momom-i force-pushed the request-kube-apiserver-directly branch from d02f3d8 to 567929a Compare February 24, 2022 16:46
@momom-i momom-i marked this pull request as draft February 26, 2022 12:33
@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 26, 2022
@momom-i momom-i marked this pull request as ready for review February 27, 2022 07:36
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 27, 2022
@sanposhiho
Copy link
Member

/assign

@momom-i momom-i force-pushed the request-kube-apiserver-directly branch from fcf5bc2 to 02b9633 Compare March 12, 2022 16:35
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 12, 2022
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Mar 14, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. and removed cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 14, 2022
@momom-i momom-i force-pushed the request-kube-apiserver-directly branch from 40f578e to 659a0ce Compare March 14, 2022 18:47
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Mar 14, 2022
@196Ikuchil
Copy link
Contributor

Thank you! I checked the ListViews on my PC and it looks good maybe.

Btw, I get a response 400 Bad request when I have tried to Apply button in WebUI.
If you understand the cause of the error, please fix it? (sorry I didn't check it in detail)

The following is an example of sending an apply request to update a Node's metadata.labels value.

Check in master branch

POST /api/v1/nodes HTTP/1.1
Host: localhost:1212
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:97.0) Gecko/20100101 Firefox/97.0
Accept: application/json, text/plain, */*
Accept-Language: ja,en-US;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
Content-Type: application/json;charset=utf-8
Content-Length: 866
Origin: http://localhost:3000
Connection: close
Referer: http://localhost:3000/
Cookie: _ga_F1R581XGNQ=GS1.1.1635005988.2.0.1635005988.0; _ga=GA1.1.1515817854.1635000707; __gads=ID=6aa81bf2479372d8-228a3956d9cc0053:T=1635000710:RT=1635000710:S=ALNI_MZd4pR1Dkc5FmAZmSASTvT9zXLx9g
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-site

{"metadata":{"name":"node2","uid":"0be1e7ac-0386-446d-bac2-ae277c4ce621","resourceVersion":"182","creationTimestamp":"2022-03-17T15:26:00Z","labels":{"test":"hoge-override"},"managedFields":[{"manager":"simulator","operation":"Apply","apiVersion":"v1","time":"2022-03-17T15:26:00Z","fieldsType":"FieldsV1","fieldsV1":{"f:metadata":{"f:labels":{"f:test":{}}},"f:spec":{}}}]},"spec":{},"status":{"capacity":{"cpu":"4","memory":"32Gi","pods":"110"},"allocatable":{"cpu":"4","memory":"32Gi","pods":"110"},"phase":"Running","conditions":[{"type":"Ready","status":"True","lastHeartbeatTime":null,"lastTransitionTime":null}],"daemonEndpoints":{"kubeletEndpoint":{"Port":0}},"nodeInfo":{"machineID":"","systemUUID":"","bootID":"","kernelVersion":"","osImage":"","containerRuntimeVersion":"","kubeletVersion":"","kubeProxyVersion":"","operatingSystem":"","architecture":""}}}


HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: http://localhost:3000
Content-Type: application/json; charset=UTF-8
Vary: Origin
Date: Thu, 17 Mar 2022 15:26:27 GMT
Content-Length: 867
Connection: close

{"metadata":{"name":"node2","uid":"0be1e7ac-0386-446d-bac2-ae277c4ce621","resourceVersion":"183","creationTimestamp":"2022-03-17T15:26:00Z","labels":{"test":"hoge-override"},"managedFields":[{"manager":"simulator","operation":"Apply","apiVersion":"v1","time":"2022-03-17T15:26:27Z","fieldsType":"FieldsV1","fieldsV1":{"f:metadata":{"f:labels":{"f:test":{}}},"f:spec":{}}}]},"spec":{},"status":{"capacity":{"cpu":"4","memory":"32Gi","pods":"110"},"allocatable":{"cpu":"4","memory":"32Gi","pods":"110"},"phase":"Running","conditions":[{"type":"Ready","status":"True","lastHeartbeatTime":null,"lastTransitionTime":null}],"daemonEndpoints":{"kubeletEndpoint":{"Port":0}},"nodeInfo":{"machineID":"","systemUUID":"","bootID":"","kernelVersion":"","osImage":"","containerRuntimeVersion":"","kubeletVersion":"","kubeProxyVersion":"","operatingSystem":"","architecture":""}}}

Check in this PR

PATCH /api/v1/nodes/node1?fieldManager=simulator HTTP/1.1
Host: localhost:3131
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:97.0) Gecko/20100101 Firefox/97.0
Accept: application/json, text/plain, */*
Accept-Language: ja,en-US;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
Content-Type: application/apply-patch+yaml
Content-Length: 898
Origin: http://localhost:3000
Connection: close
Referer: http://localhost:3000/
Cookie: _ga_F1R581XGNQ=GS1.1.1635005988.2.0.1635005988.0; _ga=GA1.1.1515817854.1635000707; __gads=ID=6aa81bf2479372d8-228a3956d9cc0053:T=1635000710:RT=1635000710:S=ALNI_MZd4pR1Dkc5FmAZmSASTvT9zXLx9g
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-site

{"kind":"Node","apiVersion":"v1","metadata":{"name":"node1","uid":"c0046bf6-ab5c-4b2e-b48b-7aae527c984f","resourceVersion":"178","creationTimestamp":"2022-03-17T15:30:42Z","labels":{"test":"hoge-override"},"managedFields":[{"manager":"simulator","operation":"Apply","apiVersion":"v1","time":"2022-03-17T15:30:42Z","fieldsType":"FieldsV1","fieldsV1":{"f:metadata":{"f:labels":{"f:test":{}}},"f:spec":{}}}]},"spec":{},"status":{"capacity":{"cpu":"4","memory":"32Gi","pods":"110"},"allocatable":{"cpu":"4","memory":"32Gi","pods":"110"},"phase":"Running","conditions":[{"type":"Ready","status":"True","lastHeartbeatTime":null,"lastTransitionTime":null}],"daemonEndpoints":{"kubeletEndpoint":{"Port":0}},"nodeInfo":{"machineID":"","systemUUID":"","bootID":"","kernelVersion":"","osImage":"","containerRuntimeVersion":"","kubeletVersion":"","kubeProxyVersion":"","operatingSystem":"","architecture":""}}}


HTTP/1.1 400 Bad Request
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, X-Requested-With, If-Modified-Since
Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE, PATCH
Access-Control-Allow-Origin: http://localhost:3000
Access-Control-Expose-Headers: Date
Audit-Id: eb725e0f-5e05-4890-8bf1-099864908b5e
Cache-Control: no-cache, private
Content-Type: application/json
X-Kubernetes-Pf-Flowschema-Uid: 1f59e016-5310-4ede-84f5-4dd66b67f6c1
X-Kubernetes-Pf-Prioritylevel-Uid: cbee2024-0a45-497f-b53b-cabceeaff462
Date: Thu, 17 Mar 2022 15:30:56 GMT
Content-Length: 185
Connection: close

{
  "kind": "Status",
  "apiVersion": "v1",
  "metadata": {
    
  },
  "status": "Failure",
  "message": "metadata.managedFields must be nil",
  "reason": "BadRequest",
  "code": 400
}

@momom-i
Copy link
Contributor Author

momom-i commented Mar 18, 2022

Thank you for your check, @196Ikuchil!
I've confirmed it occurred on my local too. It seems caused by changing to server-side apply.
I'll change to remove metadata.managedFields before updating resources later.

Copy link
Member

@sanposhiho sanposhiho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just one nits

web/components/ResourceBar/ResourceBar.vue Show resolved Hide resolved
momom-i and others added 2 commits March 19, 2022 22:33
@momom-i momom-i force-pushed the request-kube-apiserver-directly branch from 5673cbc to 37e0524 Compare March 19, 2022 13:42
Copy link
Member

@sanposhiho sanposhiho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for a great work!!!
/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 28, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: momom-i, sanposhiho

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 28, 2022
@k8s-ci-robot k8s-ci-robot merged commit ca8cf98 into kubernetes-sigs:master Mar 28, 2022
matthewygf pushed a commit to matthewygf/kube-scheduler-simulator that referenced this pull request Mar 28, 2022
* Request kube apiserver directly from frontend

* Show axios errors on page

* Add axios error judge

* Change default kubeAPIserver port

* Add simple cause err message, Fix typo

* Delete comments

* Fix err message

* change kube apiserver request header

* tmp

* Delete pods when delete node

* delete managed field before apply

* Update web/components/ResourceBar/ResourceBar.vue

Co-authored-by: Kensei Nakada <handbomusic@gmail.com>

Co-authored-by: Kensei Nakada <handbomusic@gmail.com>
matthewygf pushed a commit to matthewygf/kube-scheduler-simulator that referenced this pull request Mar 28, 2022
* Request kube apiserver directly from frontend

* Show axios errors on page

* Add axios error judge

* Change default kubeAPIserver port

* Add simple cause err message, Fix typo

* Delete comments

* Fix err message

* change kube apiserver request header

* tmp

* Delete pods when delete node

* delete managed field before apply

* Update web/components/ResourceBar/ResourceBar.vue

Co-authored-by: Kensei Nakada <handbomusic@gmail.com>

Co-authored-by: Kensei Nakada <handbomusic@gmail.com>
matthewygf pushed a commit to matthewygf/kube-scheduler-simulator that referenced this pull request Apr 18, 2022
* Request kube apiserver directly from frontend

* Show axios errors on page

* Add axios error judge

* Change default kubeAPIserver port

* Add simple cause err message, Fix typo

* Delete comments

* Fix err message

* change kube apiserver request header

* tmp

* Delete pods when delete node

* delete managed field before apply

* Update web/components/ResourceBar/ResourceBar.vue

Co-authored-by: Kensei Nakada <handbomusic@gmail.com>

Co-authored-by: Kensei Nakada <handbomusic@gmail.com>
k8s-ci-robot pushed a commit that referenced this pull request Apr 18, 2022
…in (#121)

* Able to configure API server and port, thus expose it is possible via compose

* linters

* update property name to be more descriptive

* change the parameter arg to be more descriptive

* WIP - use create server chain to start k8s api server.

* WIP - remove unecessary shutdown fn

* setup annoymoususer for insecure testing

* update go mod sum

* instead of building kube-api , only do openapi-gen

* add vendor files into repo and keep existing openapi gen

* forgot to add openapi

* remove not needed generated api

* refactor due to linters

* change makefile to what it was for github action

* refactor due to cyclomatic complexity

* use original dockerfile step

* unnecessary if

* remove openapi step before test

* disable admission plugins to for node taints and service account checks

* Added docs to describe our kube-apiserver creation process and env var

* add permission doc

* Import from existing cluster (#111)

* feat:add ignoreRestart Option to Import on ExportService

* add:impl ReplicateExistingClusterService

* add:ExternalKubeClientCfg to config

* add:impl interface of ReplicateExistingClusterService

* feat:impl replicate existing cluster's resources logic if ExternalImportEnabled is enabled

* test:add Import with ignoreRestart test

* refactor:add interface of ExportService

* add:create mock of ExportService(run go generate)

* Update config/config.go

Co-authored-by: Kensei Nakada <handbomusic@gmail.com>

* Update export/export.go

Co-authored-by: Kensei Nakada <handbomusic@gmail.com>

* Update export/export.go

Co-authored-by: Kensei Nakada <handbomusic@gmail.com>

* Update replicateexistingcluster/replicateexistingcluster.go

Co-authored-by: Kensei Nakada <handbomusic@gmail.com>

* Update replicateexistingcluster/replicateexistingcluster.go

Co-authored-by: Kensei Nakada <handbomusic@gmail.com>

* Update server/di/di.go

Co-authored-by: Kensei Nakada <handbomusic@gmail.com>

* Update server/di/di.go

Co-authored-by: Kensei Nakada <handbomusic@gmail.com>

* Update replicateexistingcluster/replicateexistingcluster.go

Co-authored-by: Kensei Nakada <handbomusic@gmail.com>

* Update replicateexistingcluster/replicateexistingcluster.go

Co-authored-by: Kensei Nakada <handbomusic@gmail.com>

* Update replicateexistingcluster/replicateexistingcluster.go

Co-authored-by: Kensei Nakada <handbomusic@gmail.com>

* refactor:rename IgnoreRestart option to IgnoreSchedulerConfiguration

* refactor:rename _exportService to exportService

* refactor:rename to replicateExistingClusterService

* refactor:change convert logic of resources

* refactor:move private functions to utils.go of export package

* test:export utils test

* test:add test for replicateexistingcluster

* fix:return value of ConvertToResourcesForImportFromResourcesForExport

* fix:get a context in arg of ImportFromExistingCluster

* fix:remove comment

* fix:rename to ConvertResourcesForImportToResourcesForExport

* fix:do import before API server starting

Co-authored-by: Kensei Nakada <handbomusic@gmail.com>

* support reset feature on web ui (#114)

* fix nil pointer reference

* update delete collection method to force delete

* fix conflict

* delete debug print

* fix lint

* fix

* update factory method

* add provider

* fix reset button

* fix format

* Rename simulatorPlugin to wrappedPlugin (#126)

* refactor:rename simulatorPlugin to wrappedPlugin

* fix:prefix word

* test:fix

* refactor:receiver name

* Implement table view on Web UI (#119)

* refactor:move resource view components to under the ResourceViews/List/ directory

* refactor:create ResourcesViewPanel component and replace it on index.vue

* add: ResourcesViewPanel & RadioButton to select view

* add:DataTable template

* fix:typo

* add:basic data tables for each resources

* fix:import PodList on UnscheduledPodList

* fix:change display columns

* fix:declare of Array type

* fix:remove debug comment

* fix:change show columns

* fix:change columns name

* typo:lang

* style:adjust search text field of tables

* feat:add ALPHA_TABLE_VIEWS env

* fix:show datatable if ALPHA_TABLE_VIEWS env val is "1"

* fix:column name

* refactor:separated into new component

* refactor:change label to title

* style:make it clear that each row on table is clickable

* Display the kind/apiVersion in the scheduler configuration yaml (#129)

* Display the kind/apiVersion in the scheduler configuration yaml

* Add kind/apiVersion to the yaml as you might expect
* For "APPLY" keep the profiles only so that ignored edits
  (e.g. apiVersion) are not displayed next time.
* The editor still allows unsupported/ignored edits, but at least
  it is clear what was set when you revisit.

Signed-off-by: Mark Sturdevant <mark.sturdevant@ibm.com>

* Ensure only profiles get updated in ApplySchedulerConfig

* Also don't yarn lint/format coverage directory

* WIP - remove unecessary shutdown fn

* fix rebase issue

* merge master

* Request kube apiserver directly from frontend (#115)

* Request kube apiserver directly from frontend

* Show axios errors on page

* Add axios error judge

* Change default kubeAPIserver port

* Add simple cause err message, Fix typo

* Delete comments

* Fix err message

* change kube apiserver request header

* tmp

* Delete pods when delete node

* delete managed field before apply

* Update web/components/ResourceBar/ResourceBar.vue

Co-authored-by: Kensei Nakada <handbomusic@gmail.com>

Co-authored-by: Kensei Nakada <handbomusic@gmail.com>

* Add deprecate description (#127)

* Add deprecate comment lines

* change some docs description

* fix indent and move not-deprecate APIs

* fix linter err

* setup annoymoususer for insecure testing

* Request kube apiserver directly from frontend (#115)

* Request kube apiserver directly from frontend

* Show axios errors on page

* Add axios error judge

* Change default kubeAPIserver port

* Add simple cause err message, Fix typo

* Delete comments

* Fix err message

* change kube apiserver request header

* tmp

* Delete pods when delete node

* delete managed field before apply

* Update web/components/ResourceBar/ResourceBar.vue

Co-authored-by: Kensei Nakada <handbomusic@gmail.com>

Co-authored-by: Kensei Nakada <handbomusic@gmail.com>

* Able to configure API server and port, thus expose it is possible via compose

* refactor due to linters

* remove unecessary error channel

* log the error return from prepared aggregator server

* add temp cert directory

* remote unnecessary changes.

* update md to reflect default api behavior

* remove unnecessary flag

* Enable Priority Plugin for admission

Co-authored-by: Kensei Nakada <handbomusic@gmail.com>

* Change the order of logging to ensure url is correct.

Co-authored-by: Kensei Nakada <handbomusic@gmail.com>

* pass cleanupFunc all the way to shutdown

* attemp to fix useragent issue

* Revert "attemp to fix useragent issue"

This reverts commit b06408a.

Co-authored-by: 196Ikuchil <22634362+196Ikuchil@users.noreply.github.com>
Co-authored-by: Kensei Nakada <handbomusic@gmail.com>
Co-authored-by: sivchari <shibuuuu5@gmail.com>
Co-authored-by: Mark Sturdevant <mark.sturdevant@ibm.com>
Co-authored-by: momom-i <51011095+momom-i@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

change frontend to request kube-apiserver directly to CRUD resources and deprecate all APIs for CRUD resources
4 participants