openk8s 0.0.1 → 1.0.1

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 (35) hide show
  1. package/README.md +187 -36
  2. package/bin/openk8s.js +2 -0
  3. package/package.json +52 -6
  4. package/src/app/app-state.ts +461 -0
  5. package/src/app/app.tsx +708 -0
  6. package/src/app/components/inspector.tsx +449 -0
  7. package/src/app/components/kind-rows.tsx +66 -0
  8. package/src/app/components/notification-tray.tsx +59 -0
  9. package/src/app/components/overlays/delete-confirm-overlay.tsx +79 -0
  10. package/src/app/components/overlays/helm-rollback-overlay.tsx +86 -0
  11. package/src/app/components/overlays/index.ts +12 -0
  12. package/src/app/components/overlays/logs-dialog.tsx +303 -0
  13. package/src/app/components/overlays/port-forward-overlay.tsx +184 -0
  14. package/src/app/components/overlays/scale-dialog.tsx +96 -0
  15. package/src/app/components/overlays/select-overlay.tsx +68 -0
  16. package/src/app/components/overlays/shared.tsx +18 -0
  17. package/src/app/components/port-forwards-tray.tsx +57 -0
  18. package/src/app/components/resource-rows.tsx +120 -0
  19. package/src/app/hooks/use-app-keyboard.ts +723 -0
  20. package/src/app/hooks/use-app-side-effects.ts +39 -0
  21. package/src/app/hooks/use-clipboard.ts +54 -0
  22. package/src/app/hooks/use-data-fetching.ts +366 -0
  23. package/src/app/hooks/use-log-stream.ts +113 -0
  24. package/src/app/hooks/use-port-forward.ts +149 -0
  25. package/src/app/persistence.ts +44 -0
  26. package/src/app/theme.ts +95 -0
  27. package/src/app/use-polling-tick.ts +27 -0
  28. package/src/app/utils.ts +274 -0
  29. package/src/index.tsx +8 -0
  30. package/src/lib/k8s/k8s-format.ts +42 -0
  31. package/src/lib/k8s/resource-detail-builder.ts +545 -0
  32. package/src/lib/k8s/resource-parser.ts +308 -0
  33. package/src/lib/k8s/types.ts +164 -0
  34. package/src/lib/kubectl/kubectl-service.ts +1116 -0
  35. package/src/lib/kubectl/spawn-utils.ts +81 -0
package/README.md CHANGED
@@ -1,45 +1,196 @@
1
1
  # openk8s
2
2
 
3
- ## ⚠️ IMPORTANT NOTICE ⚠️
3
+ A terminal UI for Kubernetes.
4
4
 
5
- **This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
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
6
 
7
- This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
7
+ ## What is this?
8
8
 
9
- ## Purpose
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
10
 
11
- This package exists to:
12
- 1. Configure OIDC trusted publishing for the package name `openk8s`
13
- 2. Enable secure, token-less publishing from CI/CD workflows
14
- 3. Establish provenance for packages published under this name
11
+ ## Prerequisites
15
12
 
16
- ## What is OIDC Trusted Publishing?
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/) | yes | Required at runtime to execute the app |
17
18
 
18
- OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
19
+ ## Installation
19
20
 
20
- ## Setup Instructions
21
-
22
- To properly configure OIDC trusted publishing for this package:
23
-
24
- 1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
25
- 2. Configure the trusted publisher (e.g., GitHub Actions)
26
- 3. Specify the repository and workflow that should be allowed to publish
27
- 4. Use the configured workflow to publish your actual package
28
-
29
- ## DO NOT USE THIS PACKAGE
30
-
31
- This package is a placeholder for OIDC configuration only. It:
32
- - Contains no executable code
33
- - Provides no functionality
34
- - Should not be installed as a dependency
35
- - Exists only for administrative purposes
36
-
37
- ## More Information
38
-
39
- For more details about npm's trusted publishing feature, see:
40
- - [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
41
- - [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
42
-
43
- ---
44
-
45
- **Maintained for OIDC setup purposes only**
21
+ ### npm (requires bun at runtime)
22
+
23
+ ```bash
24
+ npm install -g openk8s
25
+ openk8s
26
+ ```
27
+
28
+ ### bunx (no install needed)
29
+
30
+ ```bash
31
+ bunx openk8s
32
+ ```
33
+
34
+ ### From source
35
+
36
+ ```bash
37
+ git clone https://github.com/leon19/openk8s
38
+ cd openk8s
39
+ npm install
40
+ bun run dev
41
+ ```
42
+
43
+ ## Quick start
44
+
45
+ ```bash
46
+ openk8s
47
+ ```
48
+
49
+ The app scans your kubeconfig, picks your current context, and loads the cluster's resources. Use `c` to switch contexts, `n` to switch namespaces.
50
+
51
+ ## Layout
52
+
53
+ ```
54
+ ┌─────────────┬──────────────────────┬──────────────────┐
55
+ │ Kinds │ Resources │ Inspector │
56
+ │ │ │ │
57
+ │ pods ›│ nginx-7fb96c... ││ Summary tab │
58
+ │ services ›│ redis-5d4f8b... ││ Status: Ready │
59
+ │ configmaps│ api-6c9b8... ││ Age: 2h │
60
+ │ ... │ ... ││ ... │
61
+ │ │ │ │
62
+ │ [C] cluster │ / filter │ [s] [y] [v] [i] │
63
+ │ [N] ns │ │ │
64
+ └─────────────┴──────────────────────┴──────────────────┘
65
+ ```
66
+
67
+ 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.
68
+
69
+ ## Keybindings
70
+
71
+ ### Global
72
+
73
+ | Key | Action |
74
+ |-----|--------|
75
+ | `Tab` / `Shift+Tab` | Cycle pane focus right / left |
76
+ | `c` | Switch cluster context |
77
+ | `n` | Switch namespace |
78
+ | `r` | Refresh current view |
79
+ | `Escape` | Close overlay / exit filter mode |
80
+ | `Ctrl+C` | Quit |
81
+
82
+ ### Navigation
83
+
84
+ | Key | Action |
85
+ |-----|--------|
86
+ | `Up` / `k` | Move up in current pane |
87
+ | `Down` / `j` | Move down in current pane |
88
+ | `Left` / `h` | Move to previous pane |
89
+ | `Right` | Move to next pane / inspector tab |
90
+
91
+ ### Resource pane
92
+
93
+ | Key | Action |
94
+ |-----|--------|
95
+ | `/` | Enter filter mode (type to filter resources) |
96
+ | `Space` | Toggle multi-select on current resource |
97
+ | `l` | View streaming logs |
98
+ | `x` | Open interactive shell (`kubectl exec`) |
99
+ | `e` | Edit resource (`kubectl edit` / `helm upgrade --reuse-values`) |
100
+ | `d` | Delete resource (supports batch delete) |
101
+ | `f` | Port-forward overlay |
102
+ | `Shift+S` | Scale replicas |
103
+ | `Shift+R` | Rollout restart |
104
+ | `b` | Helm rollback (HelmReleases only) |
105
+ | `Shift+U` | Helm upgrade (HelmReleases only, interactive) |
106
+
107
+ ### Inspector pane
108
+
109
+ | Key | Action |
110
+ |-----|--------|
111
+ | `s` | Summary tab |
112
+ | `y` | YAML tab (press again to copy YAML) |
113
+ | `v` | Events tab |
114
+ | `i` | Describe tab |
115
+
116
+ ### Logs overlay
117
+
118
+ | Key | Action |
119
+ |-----|--------|
120
+ | `Up` / `Down` / `k` / `j` | Scroll by 3 lines |
121
+ | `c` | Pick container (multi-container pods) |
122
+ | `p` | Toggle previous logs |
123
+ | `t` | Set tail count |
124
+ | `s` | Set since duration (e.g. `1h`, `30m`) |
125
+ | `/` | Search within logs |
126
+ | `n` / `Shift+N` | Next / previous search match |
127
+ | `Escape` | Exit search → exit input → close overlay |
128
+ | `Enter` | Confirm input / search |
129
+
130
+ ### Port-forward overlay
131
+
132
+ | Key | Action |
133
+ |-----|--------|
134
+ | `Up` / `Down` / `k` / `j` | Navigate ports |
135
+ | `Enter` | Start forwarding on selected port |
136
+ | `x` | Stop active forward on selected port |
137
+ | `Escape` | Close overlay |
138
+
139
+ ### Scale dialog
140
+
141
+ | Key | Action |
142
+ |-----|--------|
143
+ | type | Enter replica count |
144
+ | `Enter` | Apply scale |
145
+ | `Escape` | Cancel |
146
+
147
+ ### Delete confirm overlay
148
+
149
+ | Key | Action |
150
+ |-----|--------|
151
+ | `Enter` | Confirm deletion |
152
+ | `Escape` | Cancel |
153
+
154
+ ## Features
155
+
156
+ - **Context & namespace switching** — browse any cluster in your kubeconfig, any namespace
157
+ - **Resource browsing** — auto-discovers API resource kinds and lists resources with status, age, and summary; curates a sensible default ordering
158
+ - **Log streaming** — `kubectl logs --follow` with search, container picker, tail count, since duration, and previous logs toggle; Deployments/StatefulSets use `--all-pods`
159
+ - **Shell** — drop into a container via `kubectl exec -it sh` (renderer suspends, resumes on exit)
160
+ - **Edit** — `kubectl edit` for resources, temp-file + `helm upgrade --reuse-values` for HelmReleases (opens `$EDITOR`)
161
+ - **Port-forward** — declare ports, start/stop forwards inline with live status
162
+ - **Scale** — set replica count for Deployments, StatefulSets, ReplicaSets
163
+ - **Rollout restart** — one-key restart for Deployments, StatefulSets, DaemonSets
164
+ - **Delete** — single or batch (via multi-select with `Space`), uses `kubectl delete` or `helm uninstall`
165
+ - **Secret reveal** — click `[reveal]` inline to decode secret values and `[copy]` to clipboard
166
+ - **YAML copy** — view full YAML in inspector, press `y` again to copy
167
+ - **Metrics** — pod and node CPU/memory usage when metrics-server is installed
168
+ - **Helm releases** — list, rollback, and upgrade Helm releases (injected as a resource kind when helm is available)
169
+ - **Multi-select** — select multiple resources for batch operations (delete)
170
+ - **Keyboard-first** — all actions accessible via keyboard; mouse also supported
171
+ - **Persistent state** — last active context and namespace saved to `~/.config/openk8s/state.json`
172
+
173
+ ## Clipboard
174
+
175
+ Copy actions (YAML, secret values) use:
176
+ - **Linux (Wayland):** `wl-copy`
177
+ - **Linux (X11):** `xclip -selection clipboard`
178
+ - **macOS:** `pbcopy`
179
+
180
+ A toast notification is shown on unsupported platforms.
181
+
182
+ ## Polling
183
+
184
+ The app auto-refreshes on three intervals:
185
+
186
+ | What | Interval |
187
+ |------|----------|
188
+ | Cluster state | 30s |
189
+ | Resource list & detail | 5s |
190
+ | Metrics | 15s |
191
+
192
+ Press `r` to force a manual refresh at any time.
193
+
194
+ ## License
195
+
196
+ MIT
package/bin/openk8s.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env bun
2
+ import "../src/index.tsx";
package/package.json CHANGED
@@ -1,10 +1,56 @@
1
1
  {
2
2
  "name": "openk8s",
3
- "version": "0.0.1",
4
- "description": "OIDC trusted publishing setup package for openk8s",
3
+ "version": "1.0.1",
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
- "oidc",
7
- "trusted-publishing",
8
- "setup"
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
  }