Skip to content

Commit 84fe725

Browse files
committed
add fetch migration docs
1 parent 6131bae commit 84fe725

File tree

2 files changed

+96
-25
lines changed

2 files changed

+96
-25
lines changed

FETCH_MIGRATION.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Fetch migration
2+
3+
Request is fully deprecated requiring us to switch libraries (see [#414](https://github.com/kubernetes-client/javascript/issues/414) for more information). There were a few [different options](https://github.com/kubernetes-client/javascript/issues/414#issuecomment-978031677) for how this swap should be implemented but moving to a new open-api-generator option was chosen since this project will acquire the advantages of an up-to-date open-api-generator version.
4+
5+
Fetch was selected as the new HTTP request library for this project due to its widespread adoption across the JavaScript ecosystem. Additonally, potential future updates to this project could allow this client to be available with browser JavaScript since fetch is native to the browser ([#165](https://github.com/kubernetes-client/javascript/issues/165)).
6+
7+
[Node-fetch](https://www.npmjs.com/package/node-fetch) is our specific fetch package since it is the largest Node.js compatable implementation. Fetch is not implemented by default in Node.
8+
9+
For more details see the initial discussion ([#754](https://github.com/kubernetes-client/javascript/issues/754)).
10+
11+
## Release cycle
12+
13+
The fetch generator will create breaking changes to this project's API. Consumers will have to make small modifications to their code to upgrade.
14+
15+
We will continue to support the request version of this project for three Kubernetes API versions (~9 months) to give users time to migrate.
16+
17+
Versioning will follow [npm semantic versioning](https://docs.npmjs.com/about-semantic-versioning).
18+
19+
### Old generator (request)
20+
21+
Code will be on the `release-0.x` branch.
22+
23+
- `0.17.x` == old generator, Kubernetes 1.23 API
24+
- `0.18.x` == old generator, Kubernetes 1.24 API
25+
- `0.19.x` == old generator, Kubernetes 1.25 API
26+
27+
Support for old generator stops after 1.25
28+
29+
### New generator (fetch)
30+
31+
Code will be on the `master` branch.
32+
33+
- `1.0.x` == new generator, Kubernetes 1.23 API
34+
- `1.1.x` == new generator, Kubernetes 1.24 API
35+
- `1.2.x` == new generator, Kubernetes 1.25 API
36+
Support for subsequent kubernetes versions continues with the new generator.
37+
38+
## Implementation steps
39+
40+
### Other repositories
41+
42+
- [x] Update [kubernetes-client/gen](https://github.com/kubernetes-client/gen)'s typescript-fetch files to let us pass in the `typescriptThreePlus` config option <sup>[1](https://github.com/OpenAPITools/openapi-generator/issues/9973) [2](https://github.com/OpenAPITools/openapi-generator/issues/3869#issuecomment-584152932)</sub>
43+
- [ ] Update [openapi-generator](https://github.com/OpenAPITools/openapi-generator)'s typescript-fetch flavor to mark parameters as optional if all parameters are optional <sup>[3](https://github.com/OpenAPITools/openapi-generator/issues/6440)</sup>
44+
45+
### Kubernetes-client repository
46+
47+
- [ ] Increment `OPENAPI_GENERATOR_COMMIT` to be [version 5.3.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v5.3.0) (with the optional parameters addition)
48+
- [ ] `npm install node-fetch` to install node-fetch
49+
- [ ] Switch generate-client script to use typescript-fetch
50+
- [ ] Import and inject node-fetch in `src/api.ts` with the following
51+
52+
```typescript
53+
import fetch from 'node-fetch';
54+
55+
// inject node-fetch
56+
if (!globalThis.fetch) {
57+
// @ts-ignore
58+
globalThis.fetch = fetch;
59+
globalThis.Headers = Headers;
60+
globalThis.Request = Request;
61+
globalThis.Response = Response;
62+
}
63+
```
64+
65+
- [ ] Generate api with `npm run generate`
66+
- [ ] Match src/gen/api.ts to new generated layout (it changes slightly)
67+
- [ ] Fix errors in /src folder (due to new api)
68+
- [ ] Fix errors in test (due to new api)
69+
- [ ] Test all features
70+
- [ ] Fix examples (due to new api)
71+
- [ ] Update docs
72+
- [ ] Document breaking changes for users
73+
- [ ] Release initial version (1.0.0)

README.md

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,9 @@
77

88
The Javascript clients for Kubernetes is implemented in
99
[typescript](https://typescriptlang.org), but can be called from either
10-
Javascript or Typescript.
10+
Javascript or Typescript. The client is implemented for server-side use with Node.
1111

12-
For now, the client is implemented for server-side use with node
13-
using the `request` library.
14-
15-
There are future plans to also build a jQuery compatible library but
16-
for now, all of the examples and instructions assume the node client.
12+
The `request` library is currently being swapped to `fetch`. See the [fetch migration docs](./FETCH_MIGRATION.md) for more information and progress.
1713

1814
# Installation
1915

@@ -70,6 +66,7 @@ k8sApi.createNamespace(namespace).then(
7066
```
7167

7268
## Create a cluster configuration programatically
69+
7370
```javascript
7471
const k8s = require('@kubernetes/client-node');
7572

@@ -118,30 +115,31 @@ release, we will increment the minor version whenever we update the minor Kubern
118115
Generally speaking newer clients will work with older Kubernetes, but compatability isn't 100% guaranteed.
119116

120117
| client version | older versions | 1.18 | 1.19 | 1.20 | 1.21 | 1.22 |
121-
|----------------|----------------|------|------|------|------|------|
122-
| 0.12.x | - | | x | x | x | x |
123-
| 0.13.x | - | + | | x | x | x |
124-
| 0.14.x | - | + | + | | x | x |
125-
| 0.15.x | - | + | + | + | | x |
126-
| 0.16.x | - | + | + | + | + | |
118+
| -------------- | -------------- | ---- | ---- | ---- | ---- | ---- |
119+
| 0.12.x | - | | x | x | x | x |
120+
| 0.13.x | - | + | | x | x | x |
121+
| 0.14.x | - | + | + | | x | x |
122+
| 0.15.x | - | + | + | + | | x |
123+
| 0.16.x | - | + | + | + | + | |
127124

128125
Key:
129126

130-
* `` Exactly the same features / API objects in both javascript-client and the Kubernetes
131-
version.
132-
* `+` javascript-client has features or api objects that may not be present in the
133-
Kubernetes cluster, but everything they have in common will work.
134-
* `-` The Kubernetes cluster has features the javascript-client library can't use
135-
(additional API objects, etc).
136-
* `x` The Kubernetes cluster has no guarantees to support the API client of
137-
this version, as it only promises _n_-2 version support. It is not tested,
138-
and operations using API versions that have been deprecated and removed in
139-
later server versions won't function correctly.
127+
- `` Exactly the same features / API objects in both javascript-client and the Kubernetes
128+
version.
129+
- `+` javascript-client has features or api objects that may not be present in the
130+
Kubernetes cluster, but everything they have in common will work.
131+
- `-` The Kubernetes cluster has features the javascript-client library can't use
132+
(additional API objects, etc).
133+
- `x` The Kubernetes cluster has no guarantees to support the API client of
134+
this version, as it only promises _n_-2 version support. It is not tested,
135+
and operations using API versions that have been deprecated and removed in
136+
later server versions won't function correctly.
140137

141138
# Known Issues
142-
* Multiple kubeconfigs are not completely supported.
143-
Credentials are cached based on the kubeconfig username and these can collide across configs.
144-
Here is the related [issue](https://github.com/kubernetes-client/javascript/issues/592).
139+
140+
- Multiple kubeconfigs are not completely supported.
141+
Credentials are cached based on the kubeconfig username and these can collide across configs.
142+
Here is the related [issue](https://github.com/kubernetes-client/javascript/issues/592).
145143

146144
# Development
147145

0 commit comments

Comments
 (0)