Skip to content

Commit 376a4ec

Browse files
committed
Update README
1 parent fb39034 commit 376a4ec

File tree

1 file changed

+55
-6
lines changed

1 file changed

+55
-6
lines changed

README.md

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# kubernetes_client
1+
![Deno CI](https://github.com/danopia/deno-kubernetes_client/workflows/Deno%20CI/badge.svg?branch=main)
2+
3+
# `/x/kubernetes_client`
24

35
This module implements several ways of sending authenticated requests
46
to the Kubernetes API from deno scripts.
@@ -7,23 +9,70 @@ Kubernetes is a complex architechure which likes using sophisticated networking
79
while Deno is a relatively young runtime, so there's some mismatch in capabilities.
810
Therefor each included client has different notes and required flags in order to operate.
911

12+
This library is intended as a building block.
13+
If you are unsure how to issue a specific request from your own library/code,
14+
please feel free to file a Github Issue.
15+
1016
## Usage
1117

18+
Here's a basic request, listing all Pods in the `default` namespace.
19+
It uses the `autoDetectClient()` entrypoint which returns the first usable client.
20+
21+
```ts
22+
import { autoDetectClient } from 'https://deno.land/x/kubernetes_client/mod.ts';
23+
const kubernetes = await autoDetectClient();
24+
25+
const podList = await kubernetes.performRequest({
26+
method: 'GET',
27+
path: `/api/v1/namespaces/default/pods`,
28+
expectJson: true, // run JSON.parse on the response body
29+
});
30+
console.log(podList);
31+
32+
// see demo.ts for more request examples (streaming responses, etc)
33+
```
34+
1235
To get started on local development, the easiest method is to call out to your `kubectl`
1336
installation to make all the network calls.
14-
This only requires `--allow-run` using `via-kubectl-raw.ts`.
15-
For deploying code into a cluster, more flags are necesary; see `via-incluster.ts`.
37+
This only requires the `--allow-run` Deno flag.
38+
For deploying code into a cluster, more flags are necesary; see "Stable clients".
39+
40+
Check out `common.ts` to see the type/API contract.
1641

17-
`demo.ts` shows how to make different types of API requests with any client.
18-
It uses the `autoDetectClient()` entrypoint which returns the first working client.
42+
## Changelog
43+
44+
* `v0.1.0` on `2020-11-16`: Initial publication, with KubectlRaw and InCluster clients.
45+
Also includes ReadableStream transformers, useful for consuming watch streams.
46+
47+
# Stable clients
48+
49+
* `KubectlRawRestClient` invokes `kubectl --raw` for every HTTP call.
50+
Excellent for development, though some features are not possible to implement.
51+
Flags: `--allow-run`
52+
* `InClusterRestClient` uses a pod's ServiceAccount to automatically authenticate.
53+
This is what you'll use when you deploy your script to a cluster.
54+
Flags: `--allow-read --allow-net --cert=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt` (check )
55+
56+
Incomplete clients:
57+
58+
* `KubectlProxyRestClient` expects a `kubectl proxy` command to be running.
59+
This allows a full range-of-motion for development purposes.
1960

2061
## Unstable Clients
2162

2263
There are a few client strategies that currently require `--unstable`;
2364
they all live in an `unstable/` folder for now and will hopefully someday
2465
be able to get promoted out and fixed up at the same time.
2566

26-
## API Typings
67+
None of these are complete at this time.
68+
69+
* `InClusterUnstableRestClient`: like the stable version, but uses Deno APIs to set the CA trust explicitly.
70+
* `KubeConfigRestClient`: interprets the user's `~/.kube/config` and tries to talk to the cluster directly.
71+
This requires a lot of flags and unstable APIs at this time.
72+
* `PluginRestClient`: Just a thought at this point.
73+
Could use a proper Rust Kubernetes client and compile it into a Deno plugin.
74+
75+
## Related: API Typings
2776

2877
This module is only implementing the HTTP/transport part of talking to Kubernetes.
2978
You'll likely also want Typescript interfaces around actually working with Kubernetes resources.

0 commit comments

Comments
 (0)