-
Notifications
You must be signed in to change notification settings - Fork 539
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
browser-side support #165
Comments
You would need to regenerate the client to use jquery or something else. It's a welcome contribution, but it requires working with the https://github.com/kubernetes-client/gen repository to change/update the code generator. |
Recent versions of However, things are not as simple. There's a bit of code ( Also, some code ( Anyway. Since I need browser-based access to the API soon'ish, I took the liberty to fork this repository and 'hack things in'. The resulting branch is published at https://github.com/scality/kubernetes-client-javascript/commits/browser I don't claim this is the 'right' way to achieve the goal (it's most certainly not), but does the trick (for now). The way it works: it uses Webpack's I also dropped the NodeJS Finally, because saw no way to implement the I also include a very bare-bones example in All of this only got some small amounts of manual testing. No guarantees everything works 'just fine', at all!. To consume the library, don't Finally, if a browser-friendly version of this library would be developed, I believe the API of the |
I figured one could adjust how However, things aren't as simple: with So, if this feature is to be retained, then we can't use |
I agree, this library makes heavy use of platform specific code. We should move the browser javascript to it's own repo. |
Goh... not entirely sure about that, to be honest. It should be possible to keep NodeJS and browser libraries in the same 'source tree'. The major pain-point is generated code, I guess. However, I bet we can work-around this, it's mostly a matter of writing API-compatible stubs and delegating to the 'right' one. For whatever using platform-specific code (e.g. the current Finally, when writing 'custom' code, e.g. to implement |
Maybe we can extract out the node or browser specific stuff into separate things that we could have users dynamically require/import? |
To some extent, yes. However:
Other approach would be to generate two One thing we could do, is to generate two However, since then we'd have a single module, we better publish things as an actual ES6 module, such that (especially in browser environments) tree-shaking can work. |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
/remove-lifecycle rotten |
any progress? |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
/remove-lifecycle rotten |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
/remove-lifecycle stale |
/lifecycle frozen |
I am actively exploring this. I am looking at it from the perspective of creating a new client, but reusing as much of what already exists as possible. The first question we need to address is how to approach authentication. Bearer token authentication in the browser is easy, however this is not how most commonly deployed Kubernetes clusters are configured to authenticate. Client certificate is also possible, the certificate would need to be imported into the users browser. The real issue is As far as I can tell there are only two options that would require minimal additional effort in order to authenticate.
Both of these methods delegate the authentication responsibility elsewhere. I feel this is necessary so that the library doesn't enforce a particular security strategy. The advantage of 1 is that it is a single command, already using what a k8s user would have installed. The advantage of 2 is that, at least for things like electron applications, the proxy client can be bundled with the application. I also plan on adding an Electron ipc interface so that the user of the library doesn't need to open up a port on their local machine to communicate with the cluster Any thoughts on this would be greatly appreciated, since it is this that will lay the foundation of how the client is built. |
I would prefer to disable exec authentication in the browser-based scenario. In general, browser based authentication to a Kubernetes cluster mostly doesn't work because most Kubernetes clusters use their own certificate authority rather than a well-known certificate authority. Unlike a client application, it is very, very hard (not to mention pretty insecure) to load a custom certificate authority into a browser, so I don't think we'd recommend that. Given that, the only real options are some sort of proxy, either via I don't think this client library should worry about any of that. We can document the problems and the potential workarounds, and just leave this library as is and expect that people will use some sort of proxy outside of this client library. Let me know if there are more questions. |
A mostly browser-compatible version would be appreciated to use in the Deno runtime server-side. |
On our end, we use OpenID that requests a token. I believe it isn't entirely uncommon to integrate something like google's OIDC with the kube-api server. I'd also like to voice the thought of at least including |
I'm updating my branch with current upstream as we speak. However, getting isomorphic support upstream, even if this is only for a part of the library/API, would help a lot and remove the somewhat tedious work to keep things in sync. In our application, we have a SPA which talks to K8s API using only CRUD APIs. Authentication is using bearer tokens (which the SPA retrieves from the IdP using the standard OIDC dance with a bunch of redirects). The K8s API access is TLS-terminated using a proxy running in the HTTP(S) server which also serves the SPA, so no need to accept any certificates on the client (except for the SPA server one). |
any progress? |
It sounds like there isn't much chance of this feature request advancing based on these issues:
Generally speaking, although all those issues above sound like they could be configured around, the workarounds are not standard or well-known configuration paths, would not be uniformly available across different providers, etc. Did I miss anything here? Has anyone developed a decent exemplar eg. VSCode extension that contacts the K8s API directly (or via proxy) without shell exec'ing more than absolutely necessary, to create the proxy for example... or is there a decent straw-man that gets us most of the way so that we can have a better chance at this, to start from something? We've based our work in Electron (vscode-gitops-tools from Weaveworks) on the official Kubernetes extension from Microsoft, which uses shell exec to get commands into the Kubernetes API via kubectl. We had our first (and second) CVE advisory reported and subsequently published not long ago, CVEs on vscode-gitops-tools which were arbitrary code execution vulns created because we took strings and passed them raw into shell execs. It's clear that this is risky behavior and as careful as you may be, the likelihood remains that some code hasn't escaped a user input properly. IMHO we should not be promoting this method (shell exec So what should we be recommending? How do JavaScript or TS clients*(in a browser context) perform K8s server-side apply operations today, synchronously, or maintain a persistent connection to get notified when some K8s event/resource subscriber gets tripped? |
For now, the client is implemented for server-side use with node using the request library.
Just curious. Aside from the use of the request library, are there any other major impediments to supporting direct browser usage?
Would this be a welcome/encouraged contribution?
The text was updated successfully, but these errors were encountered: