openk8s 0.0.1 → 1.0.0
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.
- package/README.md +194 -40
- package/bin/openk8s.js +2 -0
- package/package.json +52 -6
- package/src/app/app-state.ts +461 -0
- package/src/app/app.tsx +708 -0
- package/src/app/components/inspector.tsx +449 -0
- package/src/app/components/kind-rows.tsx +66 -0
- package/src/app/components/notification-tray.tsx +59 -0
- package/src/app/components/overlays/delete-confirm-overlay.tsx +79 -0
- package/src/app/components/overlays/helm-rollback-overlay.tsx +86 -0
- package/src/app/components/overlays/index.ts +12 -0
- package/src/app/components/overlays/logs-dialog.tsx +303 -0
- package/src/app/components/overlays/port-forward-overlay.tsx +184 -0
- package/src/app/components/overlays/scale-dialog.tsx +96 -0
- package/src/app/components/overlays/select-overlay.tsx +68 -0
- package/src/app/components/overlays/shared.tsx +18 -0
- package/src/app/components/port-forwards-tray.tsx +57 -0
- package/src/app/components/resource-rows.tsx +120 -0
- package/src/app/hooks/use-app-keyboard.ts +723 -0
- package/src/app/hooks/use-app-side-effects.ts +39 -0
- package/src/app/hooks/use-clipboard.ts +54 -0
- package/src/app/hooks/use-data-fetching.ts +366 -0
- package/src/app/hooks/use-log-stream.ts +113 -0
- package/src/app/hooks/use-port-forward.ts +149 -0
- package/src/app/persistence.ts +44 -0
- package/src/app/theme.ts +95 -0
- package/src/app/use-polling-tick.ts +27 -0
- package/src/app/utils.ts +274 -0
- package/src/index.tsx +8 -0
- package/src/lib/k8s/k8s-format.ts +42 -0
- package/src/lib/k8s/resource-detail-builder.ts +545 -0
- package/src/lib/k8s/resource-parser.ts +308 -0
- package/src/lib/k8s/types.ts +164 -0
- package/src/lib/kubectl/kubectl-service.ts +1116 -0
- package/src/lib/kubectl/spawn-utils.ts +81 -0
package/README.md
CHANGED
|
@@ -1,45 +1,199 @@
|
|
|
1
1
|
# openk8s
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A terminal UI for Kubernetes.
|
|
4
4
|
|
|
5
|
-
**This
|
|
5
|
+
**This project is vibe-coded and untested.** No guarantees it works. Built as an exercise to see how far AI-assisted development can go for a k9s-like terminal UI. Use at your own risk.
|
|
6
|
+
|
|
7
|
+
## What is this?
|
|
8
|
+
|
|
9
|
+
openk8s is a keyboard-driven TUI for browsing and managing Kubernetes clusters, inspired by [k9s](https://k9scli.io/). It aims to be a simpler, opinionated alternative — three panes, no mouse dependency (though clickable), and direct access to the most common kubectl operations without leaving the terminal.
|
|
10
|
+
|
|
11
|
+
## Prerequisites
|
|
6
12
|
|
|
7
|
-
|
|
13
|
+
| Tool | Required | Notes |
|
|
14
|
+
|------|----------|-------|
|
|
15
|
+
| [kubectl](https://kubernetes.io/docs/tasks/tools/) | yes | Must be configured with a valid kubeconfig |
|
|
16
|
+
| [helm](https://helm.sh/) | no | Enables HelmRelease management |
|
|
17
|
+
| [bun](https://bun.sh/) | dev-only | Only needed for source install / npm install |
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
8
20
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
21
|
+
### Standalone binary (no runtime needed)
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Download the latest release from the releases page, or build yourself:
|
|
25
|
+
bun run build
|
|
26
|
+
./dist/openk8s
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### npm / bunx
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm install -g openk8s
|
|
33
|
+
# or
|
|
34
|
+
bunx openk8s
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### From source
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
git clone https://github.com/anomalyco/openk8s
|
|
41
|
+
cd openk8s
|
|
42
|
+
bun install
|
|
43
|
+
bun run dev
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Quick start
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
openk8s
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The app scans your kubeconfig, picks your current context, and loads the cluster's resources. Use `c` to switch contexts, `n` to switch namespaces.
|
|
53
|
+
|
|
54
|
+
## Layout
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
┌─────────────┬──────────────────────┬──────────────────┐
|
|
58
|
+
│ Kinds │ Resources │ Inspector │
|
|
59
|
+
│ │ │ │
|
|
60
|
+
│ pods ›│ nginx-7fb96c... ││ Summary tab │
|
|
61
|
+
│ services ›│ redis-5d4f8b... ││ Status: Ready │
|
|
62
|
+
│ configmaps│ api-6c9b8... ││ Age: 2h │
|
|
63
|
+
│ ... │ ... ││ ... │
|
|
64
|
+
│ │ │ │
|
|
65
|
+
│ [C] cluster │ / filter │ [s] [y] [v] [i] │
|
|
66
|
+
│ [N] ns │ │ │
|
|
67
|
+
└─────────────┴──────────────────────┴──────────────────┘
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Three resizable panes: resource kinds (left), resources (center), inspector (right, hidden when width < 110). Tab/Shift+Tab cycles focus. Inspector has four tabs: Summary, YAML, Events, Describe.
|
|
71
|
+
|
|
72
|
+
## Keybindings
|
|
73
|
+
|
|
74
|
+
### Global
|
|
75
|
+
|
|
76
|
+
| Key | Action |
|
|
77
|
+
|-----|--------|
|
|
78
|
+
| `Tab` / `Shift+Tab` | Cycle pane focus right / left |
|
|
79
|
+
| `c` | Switch cluster context |
|
|
80
|
+
| `n` | Switch namespace |
|
|
81
|
+
| `r` | Refresh current view |
|
|
82
|
+
| `Escape` | Close overlay / exit filter mode |
|
|
83
|
+
| `Ctrl+C` | Quit |
|
|
84
|
+
|
|
85
|
+
### Navigation
|
|
86
|
+
|
|
87
|
+
| Key | Action |
|
|
88
|
+
|-----|--------|
|
|
89
|
+
| `Up` / `k` | Move up in current pane |
|
|
90
|
+
| `Down` / `j` | Move down in current pane |
|
|
91
|
+
| `Left` / `h` | Move to previous pane |
|
|
92
|
+
| `Right` | Move to next pane / inspector tab |
|
|
93
|
+
|
|
94
|
+
### Resource pane
|
|
95
|
+
|
|
96
|
+
| Key | Action |
|
|
97
|
+
|-----|--------|
|
|
98
|
+
| `/` | Enter filter mode (type to filter resources) |
|
|
99
|
+
| `Space` | Toggle multi-select on current resource |
|
|
100
|
+
| `l` | View streaming logs |
|
|
101
|
+
| `x` | Open interactive shell (`kubectl exec`) |
|
|
102
|
+
| `e` | Edit resource (`kubectl edit` / `helm upgrade --reuse-values`) |
|
|
103
|
+
| `d` | Delete resource (supports batch delete) |
|
|
104
|
+
| `f` | Port-forward overlay |
|
|
105
|
+
| `Shift+S` | Scale replicas |
|
|
106
|
+
| `Shift+R` | Rollout restart |
|
|
107
|
+
| `b` | Helm rollback (HelmReleases only) |
|
|
108
|
+
| `Shift+U` | Helm upgrade (HelmReleases only, interactive) |
|
|
109
|
+
|
|
110
|
+
### Inspector pane
|
|
111
|
+
|
|
112
|
+
| Key | Action |
|
|
113
|
+
|-----|--------|
|
|
114
|
+
| `s` | Summary tab |
|
|
115
|
+
| `y` | YAML tab (press again to copy YAML) |
|
|
116
|
+
| `v` | Events tab |
|
|
117
|
+
| `i` | Describe tab |
|
|
118
|
+
|
|
119
|
+
### Logs overlay
|
|
120
|
+
|
|
121
|
+
| Key | Action |
|
|
122
|
+
|-----|--------|
|
|
123
|
+
| `Up` / `Down` / `k` / `j` | Scroll by 3 lines |
|
|
124
|
+
| `c` | Pick container (multi-container pods) |
|
|
125
|
+
| `p` | Toggle previous logs |
|
|
126
|
+
| `t` | Set tail count |
|
|
127
|
+
| `s` | Set since duration (e.g. `1h`, `30m`) |
|
|
128
|
+
| `/` | Search within logs |
|
|
129
|
+
| `n` / `Shift+N` | Next / previous search match |
|
|
130
|
+
| `Escape` | Exit search → exit input → close overlay |
|
|
131
|
+
| `Enter` | Confirm input / search |
|
|
132
|
+
|
|
133
|
+
### Port-forward overlay
|
|
134
|
+
|
|
135
|
+
| Key | Action |
|
|
136
|
+
|-----|--------|
|
|
137
|
+
| `Up` / `Down` / `k` / `j` | Navigate ports |
|
|
138
|
+
| `Enter` | Start forwarding on selected port |
|
|
139
|
+
| `x` | Stop active forward on selected port |
|
|
140
|
+
| `Escape` | Close overlay |
|
|
141
|
+
|
|
142
|
+
### Scale dialog
|
|
143
|
+
|
|
144
|
+
| Key | Action |
|
|
145
|
+
|-----|--------|
|
|
146
|
+
| type | Enter replica count |
|
|
147
|
+
| `Enter` | Apply scale |
|
|
148
|
+
| `Escape` | Cancel |
|
|
149
|
+
|
|
150
|
+
### Delete confirm overlay
|
|
151
|
+
|
|
152
|
+
| Key | Action |
|
|
153
|
+
|-----|--------|
|
|
154
|
+
| `Enter` | Confirm deletion |
|
|
155
|
+
| `Escape` | Cancel |
|
|
156
|
+
|
|
157
|
+
## Features
|
|
158
|
+
|
|
159
|
+
- **Context & namespace switching** — browse any cluster in your kubeconfig, any namespace
|
|
160
|
+
- **Resource browsing** — auto-discovers API resource kinds and lists resources with status, age, and summary; curates a sensible default ordering
|
|
161
|
+
- **Log streaming** — `kubectl logs --follow` with search, container picker, tail count, since duration, and previous logs toggle; Deployments/StatefulSets use `--all-pods`
|
|
162
|
+
- **Shell** — drop into a container via `kubectl exec -it sh` (renderer suspends, resumes on exit)
|
|
163
|
+
- **Edit** — `kubectl edit` for resources, temp-file + `helm upgrade --reuse-values` for HelmReleases (opens `$EDITOR`)
|
|
164
|
+
- **Port-forward** — declare ports, start/stop forwards inline with live status
|
|
165
|
+
- **Scale** — set replica count for Deployments, StatefulSets, ReplicaSets
|
|
166
|
+
- **Rollout restart** — one-key restart for Deployments, StatefulSets, DaemonSets
|
|
167
|
+
- **Delete** — single or batch (via multi-select with `Space`), uses `kubectl delete` or `helm uninstall`
|
|
168
|
+
- **Secret reveal** — click `[reveal]` inline to decode secret values and `[copy]` to clipboard
|
|
169
|
+
- **YAML copy** — view full YAML in inspector, press `y` again to copy
|
|
170
|
+
- **Metrics** — pod and node CPU/memory usage when metrics-server is installed
|
|
171
|
+
- **Helm releases** — list, rollback, and upgrade Helm releases (injected as a resource kind when helm is available)
|
|
172
|
+
- **Multi-select** — select multiple resources for batch operations (delete)
|
|
173
|
+
- **Keyboard-first** — all actions accessible via keyboard; mouse also supported
|
|
174
|
+
- **Persistent state** — last active context and namespace saved to `~/.config/openk8s/state.json`
|
|
175
|
+
|
|
176
|
+
## Clipboard
|
|
177
|
+
|
|
178
|
+
Copy actions (YAML, secret values) use:
|
|
179
|
+
- **Linux (Wayland):** `wl-copy`
|
|
180
|
+
- **Linux (X11):** `xclip -selection clipboard`
|
|
181
|
+
- **macOS:** `pbcopy`
|
|
182
|
+
|
|
183
|
+
A toast notification is shown on unsupported platforms.
|
|
184
|
+
|
|
185
|
+
## Polling
|
|
186
|
+
|
|
187
|
+
The app auto-refreshes on three intervals:
|
|
188
|
+
|
|
189
|
+
| What | Interval |
|
|
190
|
+
|------|----------|
|
|
191
|
+
| Cluster state | 30s |
|
|
192
|
+
| Resource list & detail | 5s |
|
|
193
|
+
| Metrics | 15s |
|
|
194
|
+
|
|
195
|
+
Press `r` to force a manual refresh at any time.
|
|
196
|
+
|
|
197
|
+
## License
|
|
198
|
+
|
|
199
|
+
MIT
|
package/bin/openk8s.js
ADDED
package/package.json
CHANGED
|
@@ -1,10 +1,56 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openk8s",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A terminal UI for Kubernetes",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"openk8s": "./bin/openk8s.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"bin/",
|
|
12
|
+
"src/",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
15
|
+
"engines": {
|
|
16
|
+
"bun": ">=1.0"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/leon19/openk8s.git"
|
|
21
|
+
},
|
|
22
|
+
"author": {
|
|
23
|
+
"name": "Lorens León",
|
|
24
|
+
"email": "lorensleon@gmail.com"
|
|
25
|
+
},
|
|
5
26
|
"keywords": [
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
27
|
+
"kubernetes",
|
|
28
|
+
"tui",
|
|
29
|
+
"k9s",
|
|
30
|
+
"terminal",
|
|
31
|
+
"kubectl"
|
|
32
|
+
],
|
|
33
|
+
"scripts": {
|
|
34
|
+
"dev": "bun run --watch src/index.tsx",
|
|
35
|
+
"prepare": "husky || exit 0"
|
|
36
|
+
},
|
|
37
|
+
"release": {
|
|
38
|
+
"branches": [
|
|
39
|
+
"main"
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@commitlint/cli": "^21.0.1",
|
|
44
|
+
"@commitlint/config-conventional": "^21.0.1",
|
|
45
|
+
"@types/bun": "latest",
|
|
46
|
+
"@types/react": "^19.2.14",
|
|
47
|
+
"husky": "^9.1.7",
|
|
48
|
+
"semantic-release": "^25.0.3",
|
|
49
|
+
"typescript": "^6.0.3"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@opentui/core": "^0.2.12",
|
|
53
|
+
"@opentui/react": "^0.2.12",
|
|
54
|
+
"react": "^19.2.6"
|
|
55
|
+
}
|
|
10
56
|
}
|