Skip to main content

k9s cheat sheet

k9s is an open-source terminal-based UI tool which can be used to manage Kubernetes clusters. This tool offers a user-friendly terminal UI for managing, monitoring, and troubleshooting Kubernetes resources. This tool also offers features like real-time updates, filtering, and keyboard shortcuts.

Here's an example of it

k9s

Commands

CommandDescriptionExample
:ctxSwitch between Kubernetes contexts.Type :ctx and select from the list.
:nsChange the current namespace or view resources in different namespaces.Type :ns and select a namespace.
:aliasView all available resource shortcuts like :po for pods.Type :alias to display a list of shortcuts.
:Jump directly to a specific Kubernetes resource.Type :po to quickly access the Pods view.
Ctrl-AAdd or create a new resource from a YAML configuration file.Press Ctrl-A, paste the YAML content.
dDescribe the currently selected resource, providing metadata, spec, and status.Navigate to a pod and press d for details.
eEdit the currently selected resource directly in the default editor.Select a deployment and press e to edit YAML.
xExamine a resource in detail.With a node selected, press x for details.
Ctrl-KDelete the selected resource, with a confirmation prompt.Highlight a service and press Ctrl-K to delete.
lView real-time logs for a selected pod or container.Select a pod and press l to view its logs.
sOpen an interactive shell session within a selected pod.Select a pod and press s to start a shell.
/Initiate a search within the current resource view.Press / and type part of a resource name.
Ctrl-FApply a filter to list resources that match specific criteria.Press Ctrl-F and type status=Running.
0-9Quick access keys to switch between preset views and custom resource definitions.Press 1 to access the first custom view.
h or ?Display the help menu with all commands and shortcuts.Press h to open the help menu.
Shift-RRefresh the current view to update with the latest cluster state.Press Shift-R if the display seems outdated.
Ctrl-CExit K9s.Press Ctrl-C anytime to quit the application.
k9s -c Start K9s and navigate directly to a specific resource type.Execute k9s -c deploy to open deployments view.
k9s infoDisplay information about the K9s installation and the Kubernetes configuration.Execute k9s info for detailed info.
k9s edit configEdit the K9s configuration file directly.Run k9s edit config to adjust settings.

Advanced Features

FeatureDescriptionExample
SnapshotsCapture snapshots of the current resource view.Use to save a current state for later troubleshooting.
BenchmarksPerform network and performance benchmarks on services within your cluster.Analyze service performance directly from K9s.
PluginsExtend K9s functionality with other tools and scripts.Integrate custom plugins to enhance capabilities.

reference

Every Bit of Support Helps!

If you have enjoyed this post, please consider buying me a coffee ☕ to help me keep writing!