Skip to content

Commit dbf2c8f

Browse files
committed
readme
1 parent bd0eb9c commit dbf2c8f

File tree

1 file changed

+83
-51
lines changed

1 file changed

+83
-51
lines changed

README.md

Lines changed: 83 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,46 @@
1313
</a>
1414
</p>
1515

16-
KubernetesJS is a **fully-typed**, zero-dependency TypeScript client for Kubernetes.
16+
KubernetesJS is a comprehensive TypeScript ecosystem for Kubernetes, providing **fully-typed**, zero-dependency clients and React hooks for building modern cloud-native applications.
1717

1818
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.
1919

2020
> No more brittle YAML. No more hidden chart logic. Just pure, type-safe Kubernetes from the language you already use.
2121
22+
## Packages
2223

23-
## Features
24+
### 📦 [`kubernetesjs`](./packages/kubernetesjs) - Core TypeScript Client
25+
The foundation package providing a fully-typed, zero-dependency TypeScript client for the entire Kubernetes API. Perfect for Node.js applications, CLI tools, operators, and automation scripts.
2426

25-
- **🔒 Fully Typed**: Complete TypeScript definitions for all functions and models for an enhanced development experience.
26-
- **🚀 Zero Dependencies**: Works out of the box without the need for additional installations.
27-
- **📡 Full Kubernetes API Coverage**: Supports all Kubernetes API endpoints with detailed TypeScript types.
28-
- **🌐 Cross-Platform**: Works with both Node.js and browser environments.
29-
30-
With KubernetesJS, you don’t shell out to `kubectl`, grep logs, or decode YAML trees. You write real code—typed, composable, inspectable.
27+
```bash
28+
npm install kubernetesjs
29+
```
3130

32-
## Installation
31+
[View kubernetesjs documentation →](./packages/kubernetesjs)
3332

34-
To install KubernetesJS, you can use npm or yarn:
33+
### ⚛️ [`@kubernetesjs/react`](./packages/react) - React Hooks for Kubernetes
34+
React hooks powered by TanStack Query for building reactive Kubernetes dashboards and management UIs. Includes intelligent caching, real-time updates, and optimistic mutations.
3535

3636
```bash
37-
npm install kubernetesjs
38-
# or
39-
yarn add kubernetesjs
40-
37+
npm install @kubernetesjs/react
4138
```
4239

43-
## Your Infrastructure, Like a Component
40+
[View @kubernetesjs/react documentation →](./packages/react)
4441

45-
This is what we mean by "*React for infrastructure*":
42+
## Features
43+
44+
- **🔒 Fully Typed**: Complete TypeScript definitions for all functions and models for an enhanced development experience.
45+
- **🚀 Zero Dependencies**: Core client works out of the box without additional installations.
46+
- **📡 Full Kubernetes API Coverage**: Supports all Kubernetes API endpoints with detailed TypeScript types.
47+
- **🌐 Cross-Platform**: Works with both Node.js and browser environments.
48+
- **⚛️ React Integration**: First-class React hooks with intelligent state management.
49+
- **🔄 Real-time Updates**: Built-in support for watching resources and automatic refetching.
50+
51+
With KubernetesJS, you don't shell out to `kubectl`, grep logs, or decode YAML trees. You write real code—typed, composable, inspectable.
52+
53+
## Quick Start
54+
55+
### Core Client Usage
4656

4757
```ts
4858
import { KubernetesClient } from "kubernetesjs";
@@ -51,6 +61,7 @@ const client = new KubernetesClient({
5161
restEndpoint: process.env.KUBERNETES_API_URL || 'http://127.0.0.1:8001'
5262
});
5363

64+
// Create a deployment
5465
await client.createAppsV1NamespacedDeployment({
5566
path: { namespace: 'default' },
5667
body: {
@@ -63,55 +74,57 @@ await client.createAppsV1NamespacedDeployment({
6374
template: {
6475
metadata: { labels: { app: 'hello-world' } },
6576
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-
]
77+
containers: [{
78+
name: 'app',
79+
image: 'node:18-alpine',
80+
command: ['node', '-e', 'require("http").createServer((_,res)=>res.end("ok")).listen(3000)'],
81+
ports: [{ containerPort: 3000 }]
82+
}]
7483
}
7584
}
7685
}
7786
}
7887
});
7988
```
8089

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({ ... });
90+
### React Hooks Usage
9391

94-
expect(deployment.metadata?.name).toBe(deploymentName);
95-
expect(service.metadata?.name).toBe(deploymentName);
92+
```tsx
93+
import { KubernetesProvider, useListCoreV1NamespacedPodQuery } from '@kubernetesjs/react';
9694

97-
const status = await client.readAppsV1NamespacedDeployment({
98-
path: { namespace, name: deploymentName }
99-
});
95+
function App() {
96+
return (
97+
<KubernetesProvider initialConfig={{ restEndpoint: 'http://127.0.0.1:8001' }}>
98+
<PodList namespace="default" />
99+
</KubernetesProvider>
100+
);
101+
}
100102

101-
expect(status.status?.readyReplicas).toBe(1);
103+
function PodList({ namespace }: { namespace: string }) {
104+
const { data, isLoading } = useListCoreV1NamespacedPodQuery({
105+
path: { namespace }
102106
});
103-
});
104-
```
105107

106-
> Type-safe Kubernetes. With `expect()`.
107-
108-
---
108+
if (isLoading) return <div>Loading...</div>;
109+
110+
return (
111+
<ul>
112+
{data?.items?.map(pod => (
113+
<li key={pod.metadata?.uid}>
114+
{pod.metadata?.name} - {pod.status?.phase}
115+
</li>
116+
))}
117+
</ul>
118+
);
119+
}
120+
```
109121

110-
## Declarative Loops, Composability, Reuse
122+
## Your Infrastructure, Like a Component
111123

112-
You can now treat infrastructure like reusable components or functions:
124+
This is what we mean by "*React for infrastructure*":
113125

114126
```ts
127+
// Reusable infrastructure components
115128
function createPostgresDeployment(name: string) {
116129
return client.createAppsV1NamespacedDeployment({
117130
path: { namespace: 'default' },
@@ -123,8 +136,27 @@ function createPostgresDeployment(name: string) {
123136
}
124137
});
125138
}
139+
140+
// Test your infrastructure
141+
describe('PostgreSQL Deployment', () => {
142+
it('creates a PostgreSQL deployment + service', async () => {
143+
const deployment = await createPostgresDeployment('postgres-test');
144+
const service = await createPostgresService('postgres-test');
145+
146+
expect(deployment.metadata?.name).toBe('postgres-test');
147+
expect(service.metadata?.name).toBe('postgres-test');
148+
149+
const status = await client.readAppsV1NamespacedDeployment({
150+
path: { namespace: 'default', name: 'postgres-test' }
151+
});
152+
153+
expect(status.status?.readyReplicas).toBe(1);
154+
});
155+
});
126156
```
127157

158+
> Type-safe Kubernetes. With `expect()`.
159+
128160
## Example: Inspect Init Containers in Running Pods
129161

130162
```ts
@@ -188,6 +220,6 @@ Checkout these related projects:
188220

189221
## Disclaimer
190222

191-
AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED AS IS, AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
223+
AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
192224

193-
No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.
225+
No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.

0 commit comments

Comments
 (0)