dsh-kube 0.0.0-stage → 1.3.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/LICENSE +201 -0
- package/README.en.md +141 -0
- package/README.md +151 -2
- package/assets/LICENSE.xterm +19 -0
- package/assets/addon-fit.js +2 -0
- package/assets/xterm.css +218 -0
- package/assets/xterm.js +2 -0
- package/client.js +4444 -0
- package/cordis.patch.yml +4 -0
- package/docs/DETAIL.md +91 -0
- package/icon.svg +10 -0
- package/index.js +3160 -0
- package/lib/js-yaml.cjs +2 -0
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +58 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.en.md
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# dsh-kube
|
|
2
|
+
|
|
3
|
+
> 🌐 [中文](README.md) | **English**
|
|
4
|
+
|
|
5
|
+
A Kubernetes workbench plugin for DeepSeek Harness — browse clusters and resources, operate on workloads, open in-container terminals, and expose a set of kubectl-backed tools the agent can call.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Contents
|
|
10
|
+
|
|
11
|
+
- [Architecture](#architecture)
|
|
12
|
+
- [Features](#features)
|
|
13
|
+
- [Dependencies](#dependencies)
|
|
14
|
+
- [Installation](#installation)
|
|
15
|
+
- [Usage](#usage)
|
|
16
|
+
- [Configuration](#configuration)
|
|
17
|
+
- [Caveats](#caveats)
|
|
18
|
+
- [Publishing](#publishing)
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Architecture
|
|
23
|
+
|
|
24
|
+
The plugin is a standard DSH bundle with a **host** half and a **client** half — no build step, loaded directly by DSH.
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
dsh-kube/
|
|
28
|
+
├── index.js # Host (Node/Cordis): kubectl execution, HTTP routes, agent tools
|
|
29
|
+
├── client.js # Client (browser): resource panel, terminal, drawer detail UI
|
|
30
|
+
├── cordis.patch.yml # Bundle patch: inserts the plugin row into the profile composition
|
|
31
|
+
├── locale/{zh,en}.json # UI strings (Chinese / English)
|
|
32
|
+
├── lib/js-yaml.cjs # Vendored js-yaml (clean YAML re-serialization for editing)
|
|
33
|
+
├── assets/ # Vendored xterm.js terminal static assets
|
|
34
|
+
├── icon.svg
|
|
35
|
+
└── docs/DETAIL.md # Plugin detail-page doc
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
- **Host `index.js`**: every `kubectl` call happens here through the local kubectl binary. It registers HTTP routes (`/dsh-kube/*`, used by the panel) and agent tools (`kube_contexts`, `kube_get`, `kube_crds`, `kube_describe`, `kube_logs`, `kube_apply`, `kube_scale`, `kube_rollout`, `kube_delete`, `kube_login`). The in-container terminal is started by the backend via `node-pty` (ships with DSH) as a real PTY running `kubectl exec -it -- bash -i`.
|
|
39
|
+
- **Client `client.js`**: the DSH web UI side — sidebar entry, cluster/resource panel, right drawer (YAML / Describe / Pod logs), in-container shell tab, and a rules-matrix tab. The terminal renders with a vendored xterm.js.
|
|
40
|
+
- **`cordis.patch.yml`**: inserts the `{id: kube, name: 'dsh-kube'}` row into the profile's plugin composition so DSH instantiates it.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Features
|
|
45
|
+
|
|
46
|
+
### Resource browsing
|
|
47
|
+
|
|
48
|
+
List/filter across Pods, Deployments, StatefulSets, DaemonSets, Jobs, CronJobs, HPAs, VPAs, Services, Ingress, ConfigMaps, Secrets, PVC, Events, Nodes, Namespaces, ServiceAccounts, Roles, RoleBindings, ClusterRoles, ClusterRoleBindings, Users/Groups, and CRDs. The resource-type box is **searchable** (by Chinese label or kind; ↑/↓ to select, Enter to confirm, Esc to close). Clicking a row opens a right drawer with YAML / Describe / Pod logs.
|
|
49
|
+
|
|
50
|
+
### CRD
|
|
51
|
+
|
|
52
|
+
The dropdown lists only built-in types; the `CRDs` entry shows installed CustomResourceDefinitions. Clicking a Kind drills into its instances (rendered with `additionalPrinterColumns`), with a banner showing the current group/kind and a one-click back. Large CRD instance lists are fetched as a `custom-columns` projection (a 24 MB JSON list drops to ~70 KB), so they stay well under the output limit; if a CRD has no printer columns (or kubectl rejects the expression) the plugin transparently falls back to the full JSON path.
|
|
53
|
+
|
|
54
|
+
### In-container terminal
|
|
55
|
+
|
|
56
|
+
The container sub-table has a terminal icon. The backend probes `bash` (falling back to `sh`) and launches a real PTY through `kubectl exec -it -- bash -i`, so you get a genuine tty (prompt, echo, colors, line editing, Ctrl-C, `top`/`vim`). The client renders it with the vendored xterm.js and syncs `stty size` on resize. Closing the tab kills the kubectl process.
|
|
57
|
+
|
|
58
|
+
### YAML editing
|
|
59
|
+
|
|
60
|
+
Any resource's YAML tab has an **Edit** button; saving warns it will be applied to the cluster, runs `kubectl apply -f -`, surfaces kubectl errors verbatim, and on success re-reads the object and refreshes the list. Read and edit share one surface (a highlight layer under a transparent-text textarea with a green caret), so layout/line-wraps/scroll stay identical; Esc cancels. The draft is a clean re-serialization via js-yaml (nested objects/arrays render correctly); **Secret `data` is shown in plaintext while editing and moved into `stringData` on save**, so the API server does the base64 encoding. Users/Groups are aggregated pseudo-resources and cannot be edited.
|
|
61
|
+
|
|
62
|
+
### Actions column
|
|
63
|
+
|
|
64
|
+
**Every** resource kind has an **Actions** dropdown with at least **Delete**; workloads additionally get rollout-restart / rollback / scale. Rollback reads `kubectl rollout history` and defaults to the previous revision (optionally `--to-revision=N`). Scale asks for the target replicas. Delete runs `kubectl delete --wait=false` (namespaced with `-n`, cluster-scoped without; does not wait for drain). The panel shows kubectl's output or raw error. Users/Groups have no actions.
|
|
65
|
+
|
|
66
|
+
### Nodes
|
|
67
|
+
|
|
68
|
+
The Nodes list replaces the old spec column with **CPU** and **Memory** as `request/capacity` (e.g. `1.75/8`, `1.4Gi/32Gi`): requests are summed across containers, **capacity comes from `status.capacity` rounded to the nearest power of two** (7.9 cores shows `8`, 30.6Gi shows `32Gi`), and memory units are **always binary** (K/M/G and Ki/Mi/Gi all ×1024). The **Pods** column becomes `running/capacity` (e.g. `12/110`). There are also **Type** and **Zone** columns. **Status** reflects the Ready condition and appends `SchedulingDisabled` when a node is cordoned; comma-separated states render as separate badges. Node actions add **cordon / uncordon / drain**.
|
|
69
|
+
|
|
70
|
+
### Sorting & filtering
|
|
71
|
+
|
|
72
|
+
**All** resource kinds support sorting on **name / age** (and **namespace** when the column is shown): click a header to cycle ascending → descending → off. **Pods** additionally sort on namespace, status and IP, and let you multi-select filters on **status** and **node**; **Nodes** sort on CPU / memory / pod count / arch / type / zone / age with multi-select filters on **arch / type / zone**. Filters are a funnel icon in the header (shows the selected count, stays out of the row height) opening a searchable checkbox panel; sorting uses the real numbers underneath (age parses kubectl's `3y323d`-style text, so it orders correctly even though the displayed value is human-readable).
|
|
73
|
+
|
|
74
|
+
### RBAC & rules matrix
|
|
75
|
+
|
|
76
|
+
ServiceAccounts show secret counts, Roles/ClusterRoles show rule counts, bindings show roleRef and subjects. Users/Groups are aggregated from binding subjects. The **rule count** is a clickable link that opens a K9S-style **verb matrix** in the right sidebar with columns `资源 | API 组 | GET | LIST | WATCH | CREATE | PATCH | UPDATE | DELETE | DEL-LIST`; each rule is expanded per (API group × resource) row, verbs are unioned, granted verbs show a **green ✓** and denied a **red ✗**.
|
|
77
|
+
|
|
78
|
+
### Clusters & login
|
|
79
|
+
|
|
80
|
+
Each context shows its auth method, probe status, and a login button. Login reuses the kubeconfig `exec` credential providers (`oidc-login`, `aws eks get-token`, …); DSH only hands the authorization URL to the browser and the code back into the process — **you approve in person**. The login badge reflects live observation and updates immediately on cluster switch.
|
|
81
|
+
|
|
82
|
+
### Cluster read/write mode
|
|
83
|
+
|
|
84
|
+
Each cluster can be set to **read-write** (the default) or **read-only** via a dropdown in cluster management (the choice persists in `dsh-kube-state.json`). In read-only mode the **Actions column disappears** from every resource list, the detail drawer's **Edit** button is hidden, and the agent's **write tools** (`kube_apply`, `kube_scale`, `kube_rollout`, `kube_delete`) refuse to run with a clear error; reads and login still work.
|
|
85
|
+
|
|
86
|
+
In the resource-browsing session page the cluster selector is a **searchable combobox** (open it and type to filter clusters; ↑/↓ to move, Enter to pick, Esc to close), next to it a **read-write / read-only dropdown** — this is a **session-only temporary override**, distinct from the global setting: the change lives in memory only (it is not written to `dsh-kube-state.json`), takes effect immediately (Actions column hidden/restored, Edit button hidden/shown), and **drops on a page refresh or a dsh restart**, reverting to the persisted global setting; switching away and back within the same session keeps the override. The global safety boundary is unchanged: the backend write tools always judge by the persisted setting, so a session-page readwrite override cannot bypass them.
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Dependencies
|
|
91
|
+
|
|
92
|
+
- **DSH**: `engines.dsh` requires `0.2.0-rc.2 || >=0.2.1-rc.1 <0.3.0-0`; Node `>=22`.
|
|
93
|
+
- A local **`kubectl`** in `$PATH` (all reads/writes go through it).
|
|
94
|
+
- **OIDC login** (for kubeconfigs whose `exec` command is `oidc-login`): install the [kubelogin](https://github.com/int128/kubelogin) kubectl plugin (`oidc-login`) and ensure it is on `$PATH`. See its [installation guide](https://github.com/int128/kubelogin#installation).
|
|
95
|
+
- **`node-pty`** (ships with DSH) for the container terminal.
|
|
96
|
+
- js-yaml and xterm.js are vendored — no network or extra deps.
|
|
97
|
+
- On Windows, browser bridging needs WSL's `/mnt/c/Windows/System32/cmd.exe`; without it you must copy the authorization link manually.
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Installation
|
|
102
|
+
|
|
103
|
+
Install from a plugin-market index (git source): under Plugins → experimental plugins → custom plugin index, add the index URL, then install. After installing, **restart** dsh web (e.g. `systemctl --user restart deepseek-harness-web.service`, or the restart entry in the Web UI) so the host half loads; client-only changes just need a page refresh.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Usage
|
|
108
|
+
|
|
109
|
+
1. Enter the **Kubernetes** workbench from the sidebar.
|
|
110
|
+
2. Under **cluster management**, **paste a kubeconfig** to add a cluster (same-name overwrites), or remove one. You provide the kubeconfig; the plugin does not read the system `~/.kube/config`.
|
|
111
|
+
3. Select a cluster and complete OIDC auth via **Login** (you approve in your browser).
|
|
112
|
+
4. Pick namespace/resource type, filter, click rows for detail / YAML edit / logs / terminal; use **Actions** for restart/rollback/scale/delete.
|
|
113
|
+
5. Agent write tools return a “needs confirmation” note until called with an explicit `confirm: true`.
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## Configuration
|
|
118
|
+
|
|
119
|
+
Config lives under the DSH home directory (not your real home):
|
|
120
|
+
|
|
121
|
+
- `~/.kube/dsh/configs/*.yaml` — per-cluster kubeconfig copies (written only via the plugin UI or agent);
|
|
122
|
+
- `~/.kube/dsh/config` — the flattened current config kubectl actually reads;
|
|
123
|
+
- `~/.kube/dsh/dsh-kube-state.json` — the currently selected cluster.
|
|
124
|
+
|
|
125
|
+
Every kubectl call passes `--kubeconfig`; token/oidc-login caches land in the DSH home.
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Caveats
|
|
130
|
+
|
|
131
|
+
- **Destructive operations** (node cordon/uncordon/drain, delete, scale, rollback) affect scheduling and running workloads; drain deletes `emptyDir` data. Test on a non-production cluster first.
|
|
132
|
+
- When **`dsh web` restarts**, systemd kills the whole cgroup, so an in-flight kubectl is signal-terminated (exit code −1). That only means the request was interrupted, not a cluster problem; the panel retries silently instead of erroring.
|
|
133
|
+
- Resources are not cached — every read is a live kubectl call (can be slow on large clusters).
|
|
134
|
+
- Requires a local kubectl and the kubeconfig `exec` credential providers.
|
|
135
|
+
- Does not read the system `~/.kube/config`; cluster configs are pasted by you in the panel.
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Publishing
|
|
140
|
+
|
|
141
|
+
This repo ships a GitHub Action (`.github/workflows/release.yml`). On a `v*` tag it validates the version, `npm pack`s the bundle, **`npm publish --provenance`es to the npm registry** (using npm **Trusted Publishing** / OIDC — no token needed; first publish must be done by hand to establish the package, then point the package's Trusted Publishing on npmjs.com at `maplewf/dsh-kube`), generates the DSH plugin-market `site/index.json` (git source pinned to that commit) via `scripts/generate-index.mjs`, deploys it to GitHub Pages, and creates a GitHub Release with the `.tgz`. Enable **Settings → Pages → Source: GitHub Actions**; the index URL is `https://<owner>.github.io/<repo>/index.json`.
|
package/README.md
CHANGED
|
@@ -1,3 +1,152 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-kube
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> 🌐 **中文** | [English](README.en.md)
|
|
4
|
+
|
|
5
|
+
给 DeepSeek Harness 的 Kubernetes 工作台插件 —— 在 DSH 里浏览集群、操作资源、打开容器终端,并提供一组可被智能体调用的 kubectl 工具。
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 目录
|
|
10
|
+
|
|
11
|
+
- [架构](#架构)
|
|
12
|
+
- [功能](#功能)
|
|
13
|
+
- [安装依赖](#安装依赖)
|
|
14
|
+
- [安装](#安装)
|
|
15
|
+
- [使用方法](#使用方法)
|
|
16
|
+
- [配置目录](#配置目录)
|
|
17
|
+
- [注意事项](#注意事项)
|
|
18
|
+
- [发布](#发布)
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 架构
|
|
23
|
+
|
|
24
|
+
插件是典型的 DSH bundle:一个**主机端**(host)加一个**浏览器端**(client),无构建步骤,直接由 DSH 加载。
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
dsh-kube/
|
|
28
|
+
├── index.js # 主机端(Node/Cordis):kubectl 执行、HTTP 路由、agent 工具
|
|
29
|
+
├── client.js # 浏览器端:资源面板、终端、抽屉详情 UI
|
|
30
|
+
├── cordis.patch.yml # bundle patch:把插件行插入 profile 组合
|
|
31
|
+
├── locale/{zh,en}.json # 界面文案(中英)
|
|
32
|
+
├── lib/js-yaml.cjs # 内嵌 js-yaml(YAML 编辑的干净清单/重排)
|
|
33
|
+
├── assets/ # 内嵌 xterm.js 终端静态资源
|
|
34
|
+
├── icon.svg
|
|
35
|
+
└── docs/DETAIL.md # 插件详情页文档
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
- **主机端 `index.js`**:所有 `kubectl` 调用都发生在这里,走本机 kubectl 二进制。它注册了一组 HTTP 路由(`/dsh-kube/*`,供面板调用)和一组 agent 工具(`kube_contexts`、`kube_get`、`kube_crds`、`kube_describe`、`kube_logs`、`kube_apply`、`kube_scale`、`kube_rollout`、`kube_delete`、`kube_login`)。容器终端由后端用 `node-pty`(随 DSH 安装)启动一个真实 PTY,跑 `kubectl exec -it -- bash -i`。
|
|
39
|
+
- **浏览器端 `client.js`**:DSH 的 web UI 侧。注册左侧导航入口、集群/资源面板、右侧抽屉(YAML/Describe/Pod 日志)、容器 shell 标签页、规则矩阵标签页。终端用内置的 xterm.js 渲染。
|
|
40
|
+
- **`cordis.patch.yml`**:把 `{id: kube, name: 'dsh-kube'}` 这一行插入 profile 的插件组合,从而被 DSH 实例化。
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 功能
|
|
45
|
+
|
|
46
|
+
### 资源浏览
|
|
47
|
+
|
|
48
|
+
支持按类型列出并过滤:Pods、Deployments、StatefulSets、DaemonSets、Jobs、CronJobs、HPAs、VPAs、Services、Ingress、ConfigMaps、Secrets、PVC、Events、Nodes、Namespaces、ServiceAccounts、Roles、RoleBindings、ClusterRoles、ClusterRoleBindings、Users/Groups、CRDs。资源类型是一个**可搜索的组合框**(中文名或 kind 都能搜,↑/↓ 选择、Enter 确认、Esc 关闭)。点一行在右侧抽屉看 YAML、Describe、Pod 日志。
|
|
49
|
+
|
|
50
|
+
### CRD
|
|
51
|
+
|
|
52
|
+
资源类型下拉只列内置类型;`CRDs` 项展示集群已安装的 CustomResourceDefinition(Kind/Group/Scope/版本)。点击某行的 Kind 即进入该类型实例列表,顶部横幅以黄底 badge 提示当前显示的 group/kind,可一键返回。实例按 CRD 的 `additionalPrinterColumns` 展示;**大列表走 `custom-columns` 投影**(24MB 的 JSON 实例列表可缩到 ~70KB),不会触到输出上限;若该 CRD 没有 printer 列或 kubectl 拒绝表达式,会自动回退完整 JSON 路径。
|
|
53
|
+
|
|
54
|
+
### 容器终端
|
|
55
|
+
|
|
56
|
+
展开 Pod 行后,容器子表「登录」列有终端图标。后端在容器里探测 `bash`(没有则退到 `sh`),用 PTY 启动 `kubectl exec -it -- bash -i`,因此是**真实 tty**(提示符、回显、颜色、行编辑、Ctrl-C、`top`/`vim` 全可用);前端用内置 xterm.js 渲染,面板尺寸变化会同步 `stty size`。关闭标签页会杀掉对应 kubectl 进程。
|
|
57
|
+
|
|
58
|
+
### YAML 编辑
|
|
59
|
+
|
|
60
|
+
任意资源详情的 YAML 标签页都有「编辑」按钮;保存前弹窗提醒会应用到集群,确认后 `kubectl apply -f -`,失败原样显示 kubectl 报错,成功则重读该资源并刷新列表。**只读与编辑是同一个视图**(高亮层 + 文字透明的 textarea,光标绿色),编辑时排版、换行、滚动位置都不变,Esc 取消。编辑起点是后端用 js-yaml 从 `-o json` 重排的干净清单,嵌套对象/数组正确展开;**Secret 的 `data` 编辑时显示明文,保存时搬进 `stringData` 由 API server 负责 base64 编码**。Users/Groups 是聚合伪资源,不提供编辑。
|
|
61
|
+
|
|
62
|
+
### 操作列
|
|
63
|
+
|
|
64
|
+
**所有**资源类型都带一列「操作」(弹出菜单),每类至少包含「删除」;工作负载(Deployment/StatefulSet/DaemonSet)另有滚动重启/回滚/扩缩副本。回滚会先读 `kubectl rollout history` 列出版本,默认选中上一个版本,可任选一个版本 `--to-revision=N`。扩缩填目标副本数。删除统一 `kubectl delete --wait=false`(命名空间类带 `-n`,集群级如命名空间/节点/CRD 不带;不等待 Pod 排空)。面板直接显示 kubectl 输出或原始报错。Users/Groups 没有操作列。
|
|
65
|
+
|
|
66
|
+
### 节点
|
|
67
|
+
|
|
68
|
+
节点列表没有「规格」列,改为 **CPU** 与 **内存** 两列,值都是 `请求/容量`(如 `1.75/8`、`1.4Gi/32Gi`):请求按容器聚合,**容量取 `status.capacity` 并取最近 2 的幂**(真实 `7.9` 核显示 `8`、`30.6Gi` 显示 `32Gi`),内存单位**一律二进制**(K/M/G 与 Ki/Mi/Gi 都按 1024,`32G`→`32Gi`)。**Pod 数列**变成 `已运行/可容纳`(如 `12/110`)。另有**类型**(`node.kubernetes.io/instance-type`)与**区域**(`topology.kubernetes.io/zone`)列。**状态**反映 Ready 条件;节点被 `kubectl cordon` 封锁时追加 `SchedulingDisabled`,状态逗号分隔后每个状态显示成独立徽标(Ready 绿 / SchedulingDisabled 黄 / 其它红)。节点操作新增**封锁/解封/排空**:`kubectl cordon|uncordon` 与 `kubectl drain --ignore-daemonsets --delete-emptydir-data`。
|
|
69
|
+
|
|
70
|
+
### 排序与过滤
|
|
71
|
+
|
|
72
|
+
**所有**资源类型都支持按**名称/存在时长**排序(有命名空间列时也支持命名空间):点表头循环 升序 → 降序 → 取消。**Pod 列表**额外支持命名空间、状态、Pod IP 排序,并可对**状态**与**所在节点**做多选过滤;**节点列表**支持 CPU/内存/Pod 数/架构/类型/区域/存在时长排序,并可对**架构/类型/区域**做多选过滤。过滤入口是表头里的**漏斗图标**(显示已选数量,不占行高),点开是可搜索的复选框面板;排序用的是底层真实数值(存在时长能解析 kubectl 的 `3y323d` 这类人类文本,所以即使显示值是文字也能正确排序)。
|
|
73
|
+
|
|
74
|
+
### RBAC 与规则矩阵
|
|
75
|
+
|
|
76
|
+
ServiceAccounts 显示密钥数,Roles/ClusterRoles 显示规则数,Bindings 显示 roleRef 与 subjects。Users/Groups 由所有绑定 subjects 聚合。Roles/ClusterRoles 的**规则数**是可点击链接,在右侧栏打开 **verb 矩阵**:表头 `资源 | API 组 | GET | LIST | WATCH | CREATE | PATCH | UPDATE | DELETE | DEL-LIST`,每个 rule 按 (API 组 × 资源) 展开一行(空用 `*`),同组同资源的动词取并集;有权限打**绿勾 ✓**,否则**红叉 ✗**。
|
|
77
|
+
|
|
78
|
+
### 集群与登录
|
|
79
|
+
|
|
80
|
+
每个 context 显示认证方式(OIDC / AWS IAM / Azure / Token / 证书)、探测状态与登录按钮。登录复用 kubeconfig 的 `exec` 凭据插件(`oidc-login`、`aws eks get-token` 等),DSH 只把授权 URL 送到浏览器、把授权码送进进程,**用户亲自点同意**;登录状态徽标取自实时观测,切换集群后立即更新。
|
|
81
|
+
|
|
82
|
+
### 集群读写模式
|
|
83
|
+
|
|
84
|
+
集群管理里每个集群可用下拉框设置**读写**(默认)或**只读**(选择持久化到 `dsh-kube-state.json`)。只读模式下:所有资源列表的**操作列消失**、详情抽屉的**编辑按钮隐藏**、智能体**写工具**(`kube_apply`/`kube_scale`/`kube_rollout`/`kube_delete`)拒绝执行并返回明确错误;读操作与登录不受影响。
|
|
85
|
+
|
|
86
|
+
会话页(资源浏览)里集群选择器是**可搜索组合框**(点开后输入关键字过滤集群,↑/↓ 选择、Enter 确认、Esc 关闭),旁边并排一个**读写 / 只读下拉框**——这是**会话内临时覆盖**,与全局设置不同:改动只写进内存(不写 `dsh-kube-state.json`),立刻生效(操作列隐藏/恢复、编辑按钮消失/出现),**页面刷新或 dsh 重启后临时覆盖被丢弃**,重新读取全局持久化设置;同一会话内切走再切回仍保留。全局安全边界不变:后端写工具始终按持久化设置判定,会话页临时改为读写不会绕过它。
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## 安装依赖
|
|
91
|
+
|
|
92
|
+
运行插件需要:
|
|
93
|
+
|
|
94
|
+
- **DSH**:`engines.dsh` 要求 `0.2.0-rc.2 || >=0.2.1-rc.1 <0.3.0-0`;Node `>=22`。
|
|
95
|
+
- **本机 `kubectl`** 可执行(在 `$PATH` 中)。所有读写都通过它完成。
|
|
96
|
+
- **OIDC 登录**(kubeconfig 的 `exec` 命令为 `oidc-login` 时):需要安装 kubectl 插件 [kubelogin](https://github.com/int128/kubelogin)(命令名 `oidc-login`)并确保其在 `$PATH`。安装方法见其[安装文档](https://github.com/int128/kubelogin#installation)。
|
|
97
|
+
- **`node-pty`**:随 DSH 一起安装,容器终端依赖它(不需要单独装)。
|
|
98
|
+
- js-yaml 与 xterm.js 已内嵌在插件内,**无需外网或额外依赖**。
|
|
99
|
+
- Windows 下浏览器桥接依赖 WSL 的 `/mnt/c/Windows/System32/cmd.exe`;没有它时只能复制授权链接手动打开。
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## 安装
|
|
104
|
+
|
|
105
|
+
从插件市场索引安装(git source):在 DSH Web 里 Plugins → 实验性插件 → 自定义插件索引 → 添加索引 URL → 发现里安装 dsh-kube。装完后**重启** dsh web(`systemctl --user restart deepseek-harness-web.service`,或 Web 里的重启入口)以加载主机端;浏览器端改动只需刷新页面。
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## 使用方法
|
|
110
|
+
|
|
111
|
+
1. 左侧导航进入 **Kubernetes** 工作台。
|
|
112
|
+
2. 在「集群管理」里**粘贴 kubeconfig** 新增集群(同名覆盖更新),或移除集群。kubeconfig 由你提供,插件不会读取系统默认 `~/.kube/config`。
|
|
113
|
+
3. 选中集群,按需点「登录」完成 OIDC 认证(授权在你浏览器里点同意)。
|
|
114
|
+
4. 选命名空间与资源类型,搜索/过滤,点行看详情、编辑 YAML、看日志、开终端;用「操作」列做重启/回滚/扩缩/删除。
|
|
115
|
+
5. 智能体工具(写操作)默认只返回「需要确认」,需显式带 `confirm: true` 才执行。
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## 配置目录
|
|
120
|
+
|
|
121
|
+
配置存放在 DSH 主目录下(不在真实用户主目录):
|
|
122
|
+
|
|
123
|
+
- `~/.kube/dsh/configs/*.yaml`:各集群的 kubeconfig 副本(只能由插件 UI 或智能体写入);
|
|
124
|
+
- `~/.kube/dsh/config`:把 `configs/` 用 `kubectl config view --flatten` 合并成的当前配置(kubectl 实际读取);
|
|
125
|
+
- `~/.kube/dsh/dsh-kube-state.json`:当前选中集群。
|
|
126
|
+
|
|
127
|
+
所有 kubectl 调用都带 `--kubeconfig`(每次读对应集群文件),token/oidc-login 缓存落在 DSH 主目录内。
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## 注意事项
|
|
132
|
+
|
|
133
|
+
- **破坏性操作**(节点封锁/解封/排空、删除、扩缩、回滚)会影响调度与运行负载。排空会删除 `emptyDir` 数据。请在非生产集群上先演练。
|
|
134
|
+
- **`dsh web` 重启**时 systemd 会同 cgroup 一起杀掉进程,正在跑的 kubectl 被信号终止(退出码 -1)。这只代表“请求被打断”,不是集群问题;面板会静默重试而非报错。
|
|
135
|
+
- 资源不缓存,每次读取都是实时 kubectl 调用(可能较慢,取决于集群规模)。
|
|
136
|
+
- 依赖本机 kubectl 与 kubeconfig 的 `exec` 凭据插件。
|
|
137
|
+
- 不读取系统默认 `~/.kube/config`;集群配置只能由你在面板中粘贴。
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## 发布
|
|
142
|
+
|
|
143
|
+
仓库自带 GitHub Action(`.github/workflows/release.yml`),打 `v*` tag 时自动:
|
|
144
|
+
|
|
145
|
+
1. 校验 tag 版本与 `package.json` 一致;
|
|
146
|
+
2. `npm pack` 打包;
|
|
147
|
+
3. **`npm publish --provenance` 发布到 npm**(采用 npm **Trusted Publishing**(OIDC),不需要任何 token;首次发布需先在 npm 官网把 `dsh-kube` 包的 Trusted Publishing 指向本仓库 `maplewf/dsh-kube`,首个版本需手动发布一次建立信任);
|
|
148
|
+
4. 用 `scripts/generate-index.mjs` 生成 DSH 插件市场索引 `site/index.json`(git source,固定到该 commit);
|
|
149
|
+
5. 把索引部署到 GitHub Pages;
|
|
150
|
+
6. 创建 GitHub Release 并附上 `.tgz`。
|
|
151
|
+
|
|
152
|
+
仓库需在 Settings → Pages 把 Source 选为 **GitHub Actions**。索引地址即 `https://<owner>.github.io/<repo>/index.json`。
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2019, The xterm.js authors (https://github.com/xtermjs/xterm.js)
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
|
11
|
+
all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.FitAddon=t():e.FitAddon=t()}(self,(()=>(()=>{"use strict";var e={};return(()=>{var t=e;Object.defineProperty(t,"__esModule",{value:!0}),t.FitAddon=void 0,t.FitAddon=class{activate(e){this._terminal=e}dispose(){}fit(){const e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;const t=this._terminal._core;this._terminal.rows===e.rows&&this._terminal.cols===e.cols||(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal)return;if(!this._terminal.element||!this._terminal.element.parentElement)return;const e=this._terminal._core,t=e._renderService.dimensions;if(0===t.css.cell.width||0===t.css.cell.height)return;const r=0===this._terminal.options.scrollback?0:e.viewport.scrollBarWidth,i=window.getComputedStyle(this._terminal.element.parentElement),o=parseInt(i.getPropertyValue("height")),s=Math.max(0,parseInt(i.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),l=o-(parseInt(n.getPropertyValue("padding-top"))+parseInt(n.getPropertyValue("padding-bottom"))),a=s-(parseInt(n.getPropertyValue("padding-right"))+parseInt(n.getPropertyValue("padding-left")))-r;return{cols:Math.max(2,Math.floor(a/t.css.cell.width)),rows:Math.max(1,Math.floor(l/t.css.cell.height))}}}})(),e})()));
|
|
2
|
+
//# sourceMappingURL=addon-fit.js.map
|