kubernetesjs 0.7.0 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +102 -3
  2. package/index.d.ts +3 -3
  3. package/package.json +3 -3
package/README.md CHANGED
@@ -13,8 +13,12 @@
13
13
  </a>
14
14
  </p>
15
15
 
16
+ KubernetesJS is a **fully-typed**, zero-dependency TypeScript client for Kubernetes.
17
+
18
+ Write infrastructure like you write apps—modular, composable, and testable. KubernetesJS gives you direct, programmatic access to the entire Kubernetes API, with the developer experience of modern JavaScript tooling.
19
+
20
+ > No more brittle YAML. No more hidden chart logic. Just pure, type-safe Kubernetes from the language you already use.
16
21
 
17
- KubernetesJS is a **fully-typed**, zero-dependency TypeScript library designed to simplify interactions with Kubernetes APIs. With comprehensive TypeScript support, it provides a strongly-typed interface that makes managing Kubernetes resources clear and predictable, ideal for TypeScript developers looking to integrate Kubernetes management into their applications.
18
22
 
19
23
  ## Features
20
24
 
@@ -23,6 +27,8 @@ KubernetesJS is a **fully-typed**, zero-dependency TypeScript library designed t
23
27
  - **📡 Full Kubernetes API Coverage**: Supports all Kubernetes API endpoints with detailed TypeScript types.
24
28
  - **🌐 Cross-Platform**: Works with both Node.js and browser environments.
25
29
 
30
+ With KubernetesJS, you don’t shell out to `kubectl`, grep logs, or decode YAML trees. You write real code—typed, composable, inspectable.
31
+
26
32
  ## Installation
27
33
 
28
34
  To install KubernetesJS, you can use npm or yarn:
@@ -34,9 +40,94 @@ yarn add kubernetesjs
34
40
 
35
41
  ```
36
42
 
37
- ## Example
43
+ ## Your Infrastructure, Like a Component
44
+
45
+ This is what we mean by "*React for infrastructure*":
46
+
47
+ ```ts
48
+ import { KubernetesClient } from "kubernetesjs";
49
+
50
+ const client = new KubernetesClient({
51
+ restEndpoint: process.env.KUBERNETES_API_URL || 'http://127.0.0.1:8001'
52
+ });
53
+
54
+ await client.createAppsV1NamespacedDeployment({
55
+ path: { namespace: 'default' },
56
+ body: {
57
+ apiVersion: 'apps/v1',
58
+ kind: 'Deployment',
59
+ metadata: { name: 'hello-world' },
60
+ spec: {
61
+ replicas: 1,
62
+ selector: { matchLabels: { app: 'hello-world' } },
63
+ template: {
64
+ metadata: { labels: { app: 'hello-world' } },
65
+ spec: {
66
+ containers: [
67
+ {
68
+ name: 'app',
69
+ image: 'node:18-alpine',
70
+ command: ['node', '-e', 'require("http").createServer((_,res)=>res.end("ok")).listen(3000)'],
71
+ ports: [{ containerPort: 3000 }]
72
+ }
73
+ ]
74
+ }
75
+ }
76
+ }
77
+ }
78
+ });
79
+ ```
80
+
81
+ ## Test Your Cluster Like You Test Code
82
+
83
+ Run infrastructure as part of your test suite, with assertions.
84
+
85
+ ```ts
86
+ describe('PostgreSQL Deployment', () => {
87
+ const namespace = 'default';
88
+ const deploymentName = 'postgres-pgvector';
89
+
90
+ it('creates a PostgreSQL deployment + service', async () => {
91
+ const deployment = await client.createAppsV1NamespacedDeployment({ ... });
92
+ const service = await client.createCoreV1NamespacedService({ ... });
93
+
94
+ expect(deployment.metadata?.name).toBe(deploymentName);
95
+ expect(service.metadata?.name).toBe(deploymentName);
96
+
97
+ const status = await client.readAppsV1NamespacedDeployment({
98
+ path: { namespace, name: deploymentName }
99
+ });
100
+
101
+ expect(status.status?.readyReplicas).toBe(1);
102
+ });
103
+ });
104
+ ```
105
+
106
+ > Type-safe Kubernetes. With `expect()`.
107
+
108
+ ---
109
+
110
+ ## Declarative Loops, Composability, Reuse
111
+
112
+ You can now treat infrastructure like reusable components or functions:
113
+
114
+ ```ts
115
+ function createPostgresDeployment(name: string) {
116
+ return client.createAppsV1NamespacedDeployment({
117
+ path: { namespace: 'default' },
118
+ body: {
119
+ apiVersion: 'apps/v1',
120
+ kind: 'Deployment',
121
+ metadata: { name },
122
+ spec: { /* ... */ }
123
+ }
124
+ });
125
+ }
126
+ ```
127
+
128
+ ## Example: Inspect Init Containers in Running Pods
38
129
 
39
- ```js
130
+ ```ts
40
131
  import { KubernetesClient } from "kubernetesjs";
41
132
 
42
133
  const client = new KubernetesClient({
@@ -71,6 +162,14 @@ if (result.items && result.items.length) {
71
162
  }
72
163
  ```
73
164
 
165
+ ## Development
166
+
167
+ Start the Kubernetes API proxy to allow local access:
168
+
169
+ ```bash
170
+ kubectl proxy --port=8001 --accept-hosts='^.*$' --address='0.0.0.0'
171
+ ```
172
+
74
173
  ## Related
75
174
 
76
175
  Checkout these related projects:
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { APIClient, APIClientRequestOpts } from "./client";
1
+ import { APIClient, APIClientOptions, APIClientRequestOpts } from "./client";
2
2
  export interface MutatingWebhook {
3
3
  admissionReviewVersions: string[];
4
4
  clientConfig: WebhookClientConfig;
@@ -2732,7 +2732,7 @@ export interface WatchEvent {
2732
2732
  export type RawExtension = {
2733
2733
  [key: string]: unknown;
2734
2734
  };
2735
- export type IntOrString = string;
2735
+ export type IntOrString = string | number;
2736
2736
  export interface Info {
2737
2737
  buildDate: string;
2738
2738
  compiler: string;
@@ -10680,7 +10680,7 @@ export interface GetServiceAccountIssuerOpenIDKeysetRequest {
10680
10680
  export interface GetCodeVersionRequest {
10681
10681
  }
10682
10682
  export declare class KubernetesClient extends APIClient {
10683
- constructor(options: any);
10683
+ constructor(options: APIClientOptions);
10684
10684
  getSwaggerJSON(): Promise<unknown>;
10685
10685
  getServiceAccountIssuerOpenIDConfiguration(params: GetServiceAccountIssuerOpenIDConfigurationRequest, opts?: APIClientRequestOpts): Promise<string>;
10686
10686
  getCoreAPIVersions(params: GetCoreAPIVersionsRequest, opts?: APIClientRequestOpts): Promise<APIVersions>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kubernetesjs",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "author": "Dan Lynch <pyramation@gmail.com>",
5
5
  "description": "Fully Typed Kubernetes",
6
6
  "keywords": [
@@ -50,7 +50,7 @@
50
50
  "test:deploy": "ts-node scripts/deploy.ts"
51
51
  },
52
52
  "devDependencies": {
53
- "schema-sdk": "^0.11.3"
53
+ "schema-sdk": "^0.12.0"
54
54
  },
55
- "gitHead": "58b4ffddde2d9d12304448452449b828ee8aa4c5"
55
+ "gitHead": "bd0eb9c325a9e3f18687882294b4eaba0c1c5b93"
56
56
  }