Skip to content
Back to search

kubernetes-zed-extension

Kubernetes support for Zed: kubectl explain on hover, apply/diff/delete/describe/logs code actions, server-side validation, resource outline, per-session cluster selection, and an MCP server so the Agent can browse your cluster.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/strongthedev--kubernetes-zed-extension/badge.svg)](/listings/strongthedev--kubernetes-zed-extension)

HTML

<a href="/listings/strongthedev--kubernetes-zed-extension"><img src="/api/listings/strongthedev--kubernetes-zed-extension/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

# 1. Native helper (needs kubectl on PATH)
cargo install --path kube-lsp

# 2. Zed: command palette → "zed: install dev extension" → pick this folder

Optional settings (`~/.config/zed/settings.json`, or `%APPDATA%\Zed\settings.json` on Windows):

{
  "lsp": {
    "kube-lsp": {
      // "binary": { "path": "C:/tools/kube-lsp.exe" },
      "initialization_options": {
        "validateOnSave": true,
        "context": "",          // empty = current-context
        "kubeconfig": ""
      }
    }
  },
  "context_servers": {
    "kubernetes": {
      "settings": { "read_only": false, "context": "" }
    }
  }
}

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 174 lines
  1. # Kubernetes for Zed
  2. Kubernetes tooling for [Zed](https://zed.dev), aiming at feature parity with the
  3. JetBrains Kubernetes plugin. It has two parts:
  4. | Part | Where | What it does |
  5. |---|---|---|
  6. | **Zed extension** (WASM) | repo root (`extension.toml`, `src/lib.rs`) | Registers a YAML language server and an MCP context server, and launches `kube-lsp` for both |
  7. | **`kube-lsp`** (native) | [`kube-lsp/`](kube-lsp) | One binary. `kube-lsp lsp` is the language server and `kube-lsp mcp` is the MCP server. Both talk to the cluster through your `kubectl` |
  8. ## What works today
  9. **In the editor (LSP), on any YAML file that contains Kubernetes objects:**
  10. - **Hover docs**: hover any field (e.g. `spec.template.spec.containers.image`) to see
  11. `kubectl explain` output for that exact path, from your cluster's own schema
  12. (CRDs included).
  13. - **Code actions** (`ctrl-.`), for the resource under the cursor:
  14. Apply · Dry-run (server) · Diff against cluster · Open live YAML · Describe ·
  15. Show events · Show logs (workloads) · Delete (asks first), plus Apply/Diff for
  16. every resource in the file.
  17. - **Validation on save**: a server-side `--dry-run=server --validate=strict`.
  18. An unknown or duplicate field is marked on its own line. It is skipped quietly
  19. when no cluster is reachable.
  20. - **Local checks**: missing `kind` / `apiVersion` / `metadata.name`.
  21. - **Completion** for `kind:` and `apiVersion:` from the cluster's discovery API,
  22. with a built-in list when you're offline.
  23. - **Outline**: each resource (`Deployment/web`, `Service/web`) appears in the
  24. outline panel and symbol search.
  25. - **Snippets**: not included. Install the community
  26. [kubernetes-snippets](https://github.com/zed-kubernetes/kubernetes-snippets)
  27. extension; the two work side by side.
  28. **In the Agent panel (MCP context server `kubernetes`):**
  29. `kubernetes_contexts`, `_api_resources`, `_get`, `_describe`, `_logs`, `_events`,
  30. `_explain`, `_top`, plus `_use_kubeconfig`, `_use_context` and
  31. `_reset_session` for choosing the cluster. These tools are always available. The ones that
  32. change the cluster are `_apply`, `_delete`, `_scale` and `_rollout_restart`.
  33. Set `read_only: true` to hide them.
  34. Every kubectl call uses your normal kubeconfig, auth plugins and shell
  35. environment. Actions report which context they ran against.
  36. ## Choosing a cluster (like JetBrains' "select / paste kubeconfig")
  37. By default the extension uses your default kubeconfig and its `current-context`.
  38. To work against another cluster for the session:
  39. | You want to… | Do this |
  40. |---|---|
  41. | **Pick a kubeconfig file from a dialog** | Command palette, `task: spawn`, then **Kubernetes: Select kubeconfig…**. The OS file picker opens in `~/.kube` and you choose the context in the terminal (setup below) |
  42. | **Use a kubeconfig file** | Open the file in Zed, press `ctrl-.` (`cmd-.`) anywhere in it, then **Kubernetes: Connect using this kubeconfig** |
  43. | **Paste a kubeconfig** | `ctrl-n`, paste, set the language to YAML, then save it anywhere and use the same action. If you connect without saving after an edit, the buffer contents are copied to a private file instead (see below) |
  44. | **Switch context** | `ctrl-.` in any manifest, then **Kubernetes: Switch cluster context…** to pick from the active kubeconfig's contexts |
  45. | **Go back to default** | `ctrl-.`, then **Kubernetes: Disconnect session, use default kubeconfig** |
  46. | **Ask the Agent** | *"connect to the staging context in ~/kube/staging.yaml"* runs the `kubernetes_use_kubeconfig` tool |
  47. If a kubeconfig has several contexts, Zed asks which one to use. The extension
  48. then checks the connection and reports the server version, or a warning if the
  49. cluster can't be reached.
  50. How it behaves:
  51. - **The editor and the Agent share one selection.** It's stored in
  52. `%LOCALAPPDATA%\kube-lsp\session.json` (`~/.local/state/kube-lsp/` on Linux and
  53. macOS), so code actions, hovers, validation and Agent tools all hit the same
  54. cluster.
  55. - **Your own kubeconfig is never modified.** The selection is passed as
  56. `--kubeconfig/--context` on every call, unlike `kubectl config use-context`.
  57. Your terminal keeps its own context.
  58. - **The selection outlives a Zed restart** and lasts until you disconnect. It
  59. takes precedence over the `kubeconfig`/`context` values in settings.
  60. - **Saved files are used in place**, so relative `certificate-authority:` paths
  61. keep working. Buffer contents that differ from disk are copied to
  62. `kube-lsp/kubeconfigs/` (mode 0600 on Unix), and that copy is deleted when
  63. you disconnect.
  64. - A kubeconfig named `config` with no extension isn't detected as YAML. Fix that
  65. with `"file_types": { "YAML": ["**/.kube/config"] }` in your settings.
  66. ### Command palette entries (Zed tasks)
  67. Zed extensions can't add their own command palette actions, so these are
  68. shipped as [tasks](https://zed.dev/docs/tasks) that run `kube-lsp` subcommands:
  69. 1. Command palette, `zed: open tasks`, then paste the entries from
  70. [`zed/tasks.json`](zed/tasks.json). Or put them in a project's
  71. `.zed/tasks.json`.
  72. 2. Optionally bind keys using [`zed/keymap.json`](zed/keymap.json)
  73. (`ctrl-alt-k` opens the picker).
  74. | Task | Runs | Does |
  75. |---|---|---|
  76. | Kubernetes: Select kubeconfig… | `kube-lsp select-kubeconfig` | Native file dialog (Windows Forms, macOS `osascript`, Linux `zenity`/`kdialog`; falls back to typing a path), then a numbered context menu |
  77. | Kubernetes: Switch context… | `kube-lsp switch-context` | Context menu for the active kubeconfig |
  78. | Kubernetes: Use default kubeconfig | `kube-lsp reset-session` | Clears the selection |
  79. | Kubernetes: Connection status | `kube-lsp status` | Shows the session, the active context and the server version |
  80. The same commands work from any terminal, e.g.
  81. `kube-lsp select-kubeconfig ~/.kube/staging.yaml --context staging`.
  82. For a fixed setup per project, put `kubeconfig`/`context` in the project's
  83. `.zed/settings.json` under `lsp.kube-lsp.initialization_options` and
  84. `context_servers.kubernetes.settings`.
  85. ## Install (development)
  86. ```sh
  87. # 1. Native helper (needs kubectl on PATH)
  88. cargo install --path kube-lsp
  89. # 2. Zed: command palette → "zed: install dev extension" → pick this folder
  90. ```
  91. Optional settings (`~/.config/zed/settings.json`, or `%APPDATA%\Zed\settings.json` on Windows):
  92. ```jsonc
  93. {
  94. "lsp": {
  95. "kube-lsp": {
  96. // "binary": { "path": "C:/tools/kube-lsp.exe" },
  97. "initialization_options": {
  98. "validateOnSave": true,
  99. "context": "", // empty = current-context
  100. "kubeconfig": ""
  101. }
  102. }
  103. },
  104. "context_servers": {
  105. "kubernetes": {
  106. "settings": { "read_only": false, "context": "" }
  107. }
  108. }
  109. }
  110. ```
  111. ## Parity roadmap vs. JetBrains Kubernetes plugin
  112. | JetBrains feature | Status |
  113. |---|---|
  114. | Field docs / quick documentation | ✅ hover (`kubectl explain`) |
  115. | Apply / delete / diff / dry-run from editor | ✅ code actions |
  116. | Describe, live YAML, events, logs | ✅ code actions → result buffer, ✅ MCP |
  117. | Schema validation incl. CRDs | ✅ server-side dry-run on save |
  118. | Resource structure view | ✅ outline |
  119. | Live templates | ➡️ use [kubernetes-snippets](https://github.com/zed-kubernetes/kubernetes-snippets) |
  120. | Select / paste kubeconfig, switch context | ✅ code actions + prompt, shared with Agent tools |
  121. | Default namespace per session | ⏳ |
  122. | Field completion (all fields, not just kind/apiVersion) | ⏳ next: build from cluster OpenAPI v3 |
  123. | Go-to-definition between resources (selector → labels, configMapRef → ConfigMap) | ⏳ |
  124. | Helm chart support (values navigation, `helm template` preview, lint) | ⏳ |
  125. | Kustomize (`kustomize build` preview, resource references) | ⏳ |
  126. | Cluster tree browser (Services tool window) | ❌ needs UI: companion GPUI app or Zed fork |
  127. | Interactive pod shell / port-forward manager | ⏳ via Zed tasks/terminal, then companion app |
  128. | Log streaming (follow) | ❌ needs UI |
  129. ## Layout
  130. ```
  131. extension.toml Zed manifest (language server, context server)
  132. src/lib.rs WASM extension: locates/launches kube-lsp
  133. kube-lsp/src/
  134. main.rs CLI entry: `lsp` | `mcp`
  135. lsp.rs Language server
  136. mcp.rs MCP server
  137. kubectl.rs kubectl wrapper (timeouts, no console window on Windows)
  138. session.rs Active cluster selection shared by LSP and MCP
  139. cli.rs select-kubeconfig / switch-context / reset-session / status
  140. zed/tasks.json Command palette entries (Zed tasks)
  141. zed/keymap.json Optional key bindings
  142. yaml.rs Position-preserving manifest analysis (+ tests)
  143. examples/demo.yaml Try hovers/actions here
  144. ```
  145. Run the tests with `cargo test --manifest-path kube-lsp/Cargo.toml`.

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.