k9s

k9s

intro

  • cli 版的 k8s 介面 k9s
  • 簡單的操作
  • 查看不同資源
    • 看 pods
      • :pods
    • 檢視服務
      • :svc or :service
    • 檢視部署
      • :deploy
    • 檢視權限RBAC
      • :rb
    • 檢視命名空間
      • :namespace
    • 檢視排程
      • :cj
  • 搜尋
    • 假設你有 POD 在 k9s 清單中,你應該要怎麼搜尋呢?
    • 首先你只要在 POD list 的畫面,按下 /,就會如以下畫面
  • namespace 切換
    • k9s namespace 切換有兩種方式,一種是在進入 k9s 之前輸入
    • $ k9s -n {your_namespace}
    • 另一種方式就是進入後按下 : 並且輸入 namespace,按下 enter 就會出現如下圖
  • port-foward
    • 回到上面的 POD list 然後隨意進入任一個 POD 裡面,找到你想要 port-foward 的 container,按下 shift + f,就會出現如下了喔
  • 獲取幫助
    • K9s 自帶了許多快捷鍵,可以通過輸入 ? 獲取幫助。

shortcut

  • enter: 可以看到pod裡面的container資訊,要回到原本pod list畫面只要按esc就能回去
  • ctrl+c: 為結束k9s指令
  • l : logs,其實還有一個方法,一直按enter就可以看到log
Action Command Comment
Show active keyboard mnemonics and help ?
Show all available aliases and resources on the cluster ctrl-a or :alias
To bail out of K9s :q, ctrl-c
View a Kubernetes resource using singular/plural or short-name :po⏎ accepts singular, plural, short-name or alias ie pod or pods
View a Kubernetes resource in a given namespace :alias namespace⏎
Filter out a resource view given a filter /filter⏎ Regex2 supported ie `fred
Inverse regex filer /! filter⏎ Keep everything that doesn’t match. Not implemented for logs.
Filter resource view by labels /-l label-selector⏎
Fuzzy find a resource given a filter /-f filter⏎
Bails out of view/command/filter mode <esc>
Key mapping to describe, view, edit, view logs,… d,v, e, l,…
To view and switch to another Kubernetes context :ctx⏎
To view and switch to another Kubernetes context :ctx context-name⏎
To view and switch to another Kubernetes namespace :ns⏎
To view all saved resources :screendump or sd⏎
To delete a resource (TAB and ENTER to confirm) ctrl-d
To kill a resource (no confirmation dialog!) ctrl-k
Toggle Wide Columns ctrl-w Equivalent to kubectl ... -o wide
Toggle Error State ctrl-z View resources in error condition
Launch pulses view :pulses or pu⏎
Launch XRay view :xray RESOURCE [NAMESPACE]⏎ RESOURCE can be one of po, svc, dp, rs, sts, ds, NAMESPACE is optional
Launch Popeye view :popeye or pop⏎ See https://popeyecli.io

Reference