Ramilito / kubectl.nvim

Apache License 2.0
158 stars 4 forks source link
neovim-plugin

kubectl.nvim

Processes kubectl outputs to enable vim-like navigation in a buffer for your cluster.

✨ Features

Navigate your cluster in a buffer, using hierarchy where possible (backspace for up, enter for down) e.g. root -> deplyoment -> pod -> container
Colored output and smart highlighting
Floating windows for contextual stuff such as logs, description, containers..
Run custom commands e.g :Kubectl get configmaps -A
Change context using cmd :Kubectx context-name
Exec into containers In the pod view, select a pod by pressing <cr> and then again <cr> on the container you want to exec into
Sort by headers By moving the cursor to a column and pressing s
Tail logs
Diff view: :Kubectl diff (path)
Port forward
Aliases (fallback view) A fallback view that directs custom resources

⚡️ Required Dependencies

⚡️ Optional Dependencies

📦 Installation

Install the plugin with your preferred package manager:

lazy.nvim

return {
  {
    "ramilito/kubectl.nvim",
    config = function()
      require("kubectl").setup()
    end,
  },
}

⌨️ Keymaps

We expose open, close and toggle to bind against:

Toggle

vim.keymap.set("n", "<leader>k", '<cmd>lua require("kubectl").toggle()<cr>', { noremap = true, silent = true })

⚙️ Configuration

Setup

{
  auto_refresh = {
    enabled = true,
    interval = 3000, -- milliseconds
  },
  diff = {
    bin = "kubediff" -- or any other binary
  },
  namespace = "All",
  namespace_fallback = {}, -- If you have limited access you can list all the namespaces here
  notifications = {
    enabled = true,
    verbose = false,
    blend = 100,
  },
  hints = true,
  context = true,
  float_size = {
    -- Almost fullscreen:
    -- width = 1.0,
    -- height = 0.95, -- Setting it to 1 will cause bottom to be cutoff by statuscolumn

    -- For more context aware size:
    width = 0.9,
    height = 0.8,

    -- Might need to tweak these to get it centered when float is smaller
    col = 10,
    row = 5,
  },
  obj_fresh = 0, -- highlight if creation newer than number (in minutes)
}

Performance

Startup

The setup function only adds ~1ms to startup. We use kubectl proxy and curl to reduce latency.

Versioning

[!WARNING] As we have not yet reached v1.0.0, we may have some breaking changes in cases where it is deemed necessary.

Motivation

This plugins main purpose is to browse the kubernetes state using vim like navigation and keys, similar to oil.nvim for file browsing.