chore(deps): bump k8s.io/apiextensions-apiserver from 0.35.1 to 0.35.2 (#3861)
Bumps k8s.io/apiextensions-apiserver from 0.35.1 to 0.35.2.
updated-dependencies:
- dependency-name: k8s.io/apiextensions-apiserver dependency-version: 0.35.2 dependency-type: direct:production update-type: version-update:semver-patch …
Signed-off-by: dependabot[bot] support@github.com Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9
京公网安备 11010802032778号
K9s - Kubernetes CLI To Manage Your Clusters In Style!
K9s provides a terminal UI to interact with your Kubernetes clusters. The aim of this project is to make it easier to navigate, observe and manage your applications in the wild. K9s continually watches Kubernetes for changes and offers subsequent commands to interact with your observed resources.
Note…
K9s is not pimped out by a big corporation with deep pockets. It is a complex OSS project that demands a lot of my time to maintain and support. K9s will always remain OSS and therefore free! That said, if you feel k9s makes your day to day Kubernetes journey a tad brighter, saves you time and makes you more productive, please consider sponsoring us! Your donations will go a long way in keeping our servers lights on and beers in our fridge!
Thank you!
Screenshots
Demo Videos/Recordings
Documentation
Please refer to our K9s documentation site for installation, usage, customization and tips.
Slack Channel
Wanna discuss K9s features with your fellow
K9sersor simply show your support for this tool?Installation
K9s is available on Linux, macOS and Windows platforms. Binaries for Linux, Windows and Mac are available as tarballs in the release page.
Via Homebrew for macOS or Linux
Via MacPorts
Via snap for Linux
On Arch Linux
On OpenSUSE Linux distribution
On FreeBSD
On Ubuntu
On Fedora (42+)
Via Winget for Windows
Via Scoop for Windows
Via Chocolatey for Windows
Via a GO install
Via Webi for Linux and macOS
Via pkgx for Linux and macOS
Via gah for Linux and macOS
Via Webi for Windows
As a Docker Desktop Extension (for the Docker Desktop built in Kubernetes Server)
Building From Source
K9s is currently using GO v1.23.X or above. In order to build K9s from source you must:
Clone the repo
Build and run the executable
Running with Docker
Running the official Docker image
You can run k9s as a Docker container by mounting your
KUBECONFIG:For default path it would be:
Building your own Docker image
You can build your own Docker image of k9s from the Dockerfile with the following:
You can get the latest stable
kubectlversion and pass it to thedocker buildcommand with the--build-argoption. You can use the--build-argoption to pass any validkubectlversion (likev1.18.0orv1.19.1).Run your container:
PreFlight Checks
K9s uses 256 colors terminal mode. On `Nix system make sure TERM is set accordingly.
In order to issue resource edit commands make sure your EDITOR and KUBE_EDITOR env vars are set.
K9s prefers recent kubernetes versions ie 1.28+
K8S Compatibility Matrix
The Command Line
Logs And Debug Logs
Given the nature of the ui k9s does produce logs to a specific location. To view the logs and turn on debug mode, use the following commands:
View K9s logs
Start K9s in debug mode
Customize logs destination
You can override the default log file destination either with the
--logFileargument:Or through the
K9S_LOGS_DIRenvironment variable:Key Bindings
K9s uses aliases to navigate most K8s resources.
?ctrl-a:quit,:q,ctrl-cesc:pod⏎:pod ns-x⏎:pod /fred⏎:pod app=fred,env=dev⏎:pod @ctx1⏎/filter⏎/! filter⏎/-l label-selector⏎/-f filter⏎<esc>:ctx⏎:ctx context-name⏎:ns⏎-[, forward:]:screendump or sd⏎ctrl-dctrl-k:pulses or pu⏎:xray RESOURCE [NAMESPACE]⏎:popeye or pop⏎spacectrl-spacectrl-\ctrl-sctrl-zctrl-wctrl-ectrl-gshift-left arrowshift-right arrowshift-oshift-nshift-ashift-pshift-scnylpsadefshift-fwshift-juubwtfctrl-rturrctrl-lzK9s Configuration
K9s keeps its configurations as YAML files inside of a
k9sdirectory and the location depends on your operating system. K9s leverages XDG to load its various configurations files. For information on the default locations for your OS please see this link. If you are still confused a quickk9s infowill reveal where k9s is loading its configurations from. Alternatively, you can setK9S_CONFIG_DIRto tell K9s the directory location to pull its configurations from.~/.config/k9s~/Library/Application Support/k9s%LOCALAPPDATA%\k9sYou can now override the context portForward default address configuration by setting an env variable that can override all clusters portForward local address using
K9S_DEFAULT_PF_ADDRESS=a.b.c.dPopeye Configuration
K9s has integration with Popeye, which is a Kubernetes cluster sanitizer. Popeye itself uses a configuration called
spinach.yml, but when integrating with K9s the cluster-specific file should be name$XDG_CONFIG_HOME/share/k9s/clusters/clusterX/contextY/spinach.yml. This allows you to have a different spinach config per cluster.Node Shell
By enabling the nodeShell feature gate on a given cluster, K9s allows you to shell into your cluster nodes. Once enabled, you will have a new
sforshellmenu option while in node view. K9s will launch a pod on the selected node using a special k9s_shell pod. Furthermore, you can refine your shell pod by using a custom docker image preloaded with the shell tools you love. By default k9s uses a BusyBox image, but you can configure it as follows:Alternatively, you can now override the context configuration by setting an env variable that can override all clusters node shell gate using
K9S_FEATURE_GATE_NODE_SHELL=true|falseThen in your cluster configuration file…
Customizing the Shell Pod
You can also customize the shell pod by adding a
hostPathVolumeto your shell pod. This allows you to mount a local directory or file into the shell pod. For example, if you want to mount the Docker socket into the shell pod, you can do so as follows:This will mount the Docker socket into the shell pod at
/var/run/docker.sockand make it read-only. You can also mount any other directory or file in a similar way.Command Aliases
In K9s, you can define your very own command aliases (shortnames) to access your resources. In your
$HOME/.config/k9sdefine a file calledaliases.yaml. A K9s alias defines pairs of alias:gvr. A gvr (Group/Version/Resource) represents a fully qualified Kubernetes resource identifier. Here is an example of an alias file:Using this aliases file, you can now type
:ppor:crbor:fredto activate their respective commands.HotKey Support
Entering the command mode and typing a resource name or alias, could be cumbersome for navigating thru often used resources. We’re introducing hotkeys that allow users to define their own key combination to activate their favorite resource views.
Additionally, you can define context specific hotkeys by add a context level configuration file in
$XDG_DATA_HOME/k9s/clusters/clusterX/contextY/hotkeys.yamlIn order to surface hotkeys globally please follow these steps:
Create a file named
$XDG_CONFIG_HOME/k9s/hotkeys.yamlAdd the following to your
hotkeys.yaml. You can use resource name/short name to specify a command ie same as typing it while in command mode.Not feeling so hot? Your custom hotkeys will be listed in the help view
?. Also your hotkeys file will be automatically reloaded so you can readily use your hotkeys as you define them.You can choose any keyboard shortcuts that make sense to you, provided they are not part of the standard K9s shortcuts list.
Similarly, referencing environment variables in hotkeys is also supported. The available environment variables can refer to the description in the Plugins section.
Port Forwarding over websockets
K9s follows
kubectlfeature flag environment variables to enable/disable port-forwarding over websockets. (default enabled in >1.30) To disable Websocket support, setKUBECTL_PORT_FORWARD_WEBSOCKETS=falseFastForwards
As of v0.25.0, you can leverage the
FastForwardsfeature to tell K9s how to default port-forwards. In situations where you are dealing with multiple containers or containers exposing multiple ports, it can be cumbersome to specify the desired port-forward from the dialog as in most cases, you already know which container/port tuple you desire. For these use cases, you can now annotate your manifests with the following annotations:@
k9scli.io/auto-port-forwardsactivates one or more port-forwards directly bypassing the port-forward dialog all together. @k9scli.io/port-forwardspre-selects one or more port-forwards when launching the port-forward dialog.The annotation value takes on the shape
container-name::[local-port:]container-portExample
The annotation value must specify a container to forward to as well as a local port and container port. The container port may be specified as either a port number or port name. If the local port is omitted then the local port will default to the container port number. Here are a few examples:
bozowith port name http. If http specifies port number 8080 then the local port will be 8080 as well.bozomapping local port 9090->http(8080)bozomapping local port 9090->8080Custom Views
SneakCast v0.17.0 on The Beach! - Yup! sound is sucking but what a setting!
You can change which columns shows up for a given resource via custom views. To surface this feature, you will need to create a new configuration file, namely
$XDG_CONFIG_HOME/k9s/views.yaml. This file leverages GVR (Group/Version/Resource) to configure the associated table view columns. If no GVR is found for a view the default rendering will take over (ie what we have now). Going wide will add all the remaining columns that are available on the given resource after your custom columns. To boot, you can edit your views config file and tune your resources views live!📢 🎉 As of
release v0.40.0you can specify json parse expressions to further customize your resources rendering.The new column syntax is as follows:
Where
:json_parse_expressionrepresents an expression to pull a specific snippet out of the resource manifest. Similar tokubectl -o custom-columnscommand. This expression is optional.Additionally, you can specify column attributes to further tailor the column rendering. To use this you will need to add a
|indicator followed by your rendering bits. You can have one or more of the following attributes:T-> time column indicatorN-> number column indicatorW-> turns on wide column aka only shows while in wide mode. Defaults to the standard resource definition when present.S-> Ensures a column is visible and not wide. Overrideswidestd resource definition if present.H-> Hides the columnL-> Left align (default)R-> Right alignHere is a sample views configuration that customize a pods and services views.
Plugins
K9s allows you to extend your command line and tooling by defining your very own cluster commands via plugins. Minimally we look at
$XDG_CONFIG_HOME/k9s/plugins.yamlto locate all available plugins. Additionally, K9s will scan the following directories for additional plugins:$XDG_CONFIG_HOME/k9s/plugins$XDG_DATA_HOME/k9s/plugins$XDG_DATA_DIRS/k9s/pluginsThe plugin file content can be either a single plugin snippet, a collections of snippets or a complete plugins definition (see examples below…).
A plugin is defined as follows:
allto provide this shortcut for all views.Plugin Inputs
Plugins can define input fields that prompt users for values before execution. This is useful when you need dynamic values like replica counts, environment variables, or profile selections. A maximum of 5 inputs per plugin is allowed.
Each input has the following properties:
name(required) – the input identifier used to reference the value in args as$INPUT_<NAME>(uppercase)label– the label shown to the user in the input dialogtype(required) – the input type:string,number,bool, ordropdownrequired– when true, the user must provide a value before the plugin can executedefault– a default value pre-filled in the input field (must be a valid option fordropdown,"true"/"false"forbool, or a valid number fornumber)options– fordropdowntype only, defines the list of available choicesInput values are available in plugin args using the format
$INPUT_<NAME>where<NAME>is the uppercase version of the input name.Input Types:
stringnumberbooldropdownExample:
K9s does provide additional environment variables for you to customize your plugins arguments. Currently, the available environment variables are as follows:
$RESOURCE_GROUP– the selected resource group$RESOURCE_VERSION– the selected resource api version$RESOURCE_NAME– the selected resource name$NAMESPACE– the selected resource namespace$NAME– the selected resource name$CONTAINER– the current container if applicable$FILTER– the current filter if any$KUBECONFIG– the KubeConfig location.$CLUSTERthe active cluster name$CONTEXTthe active context name$USERthe active user$GROUPSthe active groups$PODwhile in a container view$COL-<RESOURCE_COLUMN_NAME>use a given column name for a viewed resource. Must be prefixed byCOL-!Curly braces can be used to embed an environment variable inside another string, or if the column name contains special characters. (e.g.
${NAME}-exampleor${COL-%CPU/L})Plugin Examples
Define several plugins and host them in a single file. These can leave in the K9s root config so that they are available on any clusters. Additionally, you can define cluster/context specific plugins for your clusters of choice by adding clusterA/contextB/plugins.yaml file.
The following defines a plugin for viewing logs on a selected pod using
ctrl-las shortcut.Similarly you can define the plugin above in a directory using either a file per plugin or several plugins per files as follow…
The following defines two plugins namely fred and zorg.
Lastly you can define plugin snippets in their own file. The snippet will be named from the file name. In this case, we define a
bozoplugin using a plugin snippet.Benchmark Your Applications
K9s integrates Hey from the brilliant and super talented Jaana Dogan.
Heyis a CLI tool to benchmark HTTP endpoints similar to AB bench. This preliminary feature currently supports benchmarking port-forwards and services (Read the paint on this is way fresh!).To setup a port-forward, you will need to navigate to the PodView, select a pod and a container that exposes a given port. Using
SHIFT-Fa dialog comes up to allow you to specify a local port to forward. Once acknowledged, you can navigate to the PortForward view (aliaspf) listing out your active port-forwards. Selecting a port-forward and usingCTRL-Bwill run a benchmark on that HTTP endpoint. To view the results of your benchmark runs, go to the Benchmarks view (aliasbe). You should now be able to select a benchmark and view the run stats details by pressing<ENTER>. NOTE: Port-forwards only last for the duration of the K9s session and will be terminated upon exit.Initially, the benchmarks will run with the following defaults:
The PortForward view is backed by a new K9s config file namely:
$XDG_DATA_HOME/k9s/clusters/clusterX/contextY/benchmarks.yaml. Each cluster you connect to will have its own bench config file, containing the name of the K8s context for the cluster. Changes to this file should automatically update the PortForward view to indicate how you want to run your benchmarks.Benchmarks result reports are stored in
$XDG_STATE_HOME/k9s/clusters/clusterX/contextYHere is a sample benchmarks.yaml configuration. Please keep in mind this file will likely change in subsequent releases!
K9s RBAC FU
On RBAC enabled clusters, you would need to give your users/groups capabilities so that they can use K9s to explore their Kubernetes cluster. K9s needs minimally read privileges at both the cluster and namespace level to display resources and metrics.
These rules below are just suggestions. You will need to customize them based on your environment policies. If you need to edit/delete resources extra Fu will be necessary.
Cluster RBAC scope
Namespace RBAC scope
If your users are constrained to certain namespaces, K9s will need to following role to enable read access to namespaced resources.
Skins
Example: Dracula Skin ;)
You can style K9s based on your own sense of look and style. Skins are YAML files, that enable a user to change the K9s presentation layer. See this repo
skinsdirectory for examples. You can skin k9s by default by specifying a UI.skin attribute. You can also change K9s skins based on the context you are connecting too. In this case, you can specify a skin field on your cluster config akaskin: dracula(just the name of the skin file without the extension!) and copy this reposkins/dracula.yamlto$XDG_CONFIG_HOME/k9s/skins/directory. You can also change the skin by settingK9S_SKINin the environment, e.g.export K9S_SKIN="dracula".In the case where your cluster spans several contexts, you can add a skin context configuration to your context configuration. This is a collection of {context_name, skin} tuples (please see example below!)
Colors can be defined by name or using a hex representation. Of recent, we’ve added a color named
defaultto indicate a transparent background color to preserve your terminal background color settings if so desired.To skin a specific context and provided the file
in-the-navy.yamlis present in your skins directory.You can also specify a default skin for all contexts in the root k9s config file as so:
Contributors
Without the contributions from these fine folks, this project would be a total dud!
Known Issues
This is still work in progress! If something is broken or there’s a feature that you want, please file an issue and if so inclined submit a PR!
K9s will most likely blow up if…
ATTA Girls/Boys!
K9s sits on top of many open source projects and libraries. Our sincere appreciations to all the OSS contributors that work nights and weekends to make this project a reality!
Meet The Core Team!
If you have chops in GO and K8s and would like to offer your time to help maintain and enhance this project, please reach out to me.
We always enjoy hearing from folks who benefit from our work!
Contributions Guideline