在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):derailed/k9s开源软件地址(OpenSource Url):https://github.com/derailed/k9s开源编程语言(OpenSource Language):Go 99.7%开源软件介绍(OpenSource Introduction):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...As you may know 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, please consider sponsoring us or purchase a K9sAlpha license. Your donations will go a long way in keeping our servers lights on and beers in our fridge! Thank you! DocumentationPlease refer to our K9s documentation site for installation, usage, customization and tips. Slack ChannelWanna discuss K9s features with your fellow
InstallationK9s is available on Linux, macOS and Windows platforms.
Building From SourceK9s is currently using go v1.14 or above. In order to build K9s from source you must:
Running with DockerRunning the official Docker imageYou can run k9s as a Docker container by mounting your docker run --rm -it -v $KUBECONFIG:/root/.kube/config quay.io/derailed/k9s For default path it would be: docker run --rm -it -v ~/.kube/config:/root/.kube/config quay.io/derailed/k9s Building your own Docker imageYou can build your own Docker image of k9s from the Dockerfile with the following: docker build -t k9s-docker:0.1 . You can get the latest stable KUBECTL_VERSION=$(make kubectl-stable-version 2>/dev/null)
docker build --build-arg KUBECTL_VERSION=${KUBECTL_VERSION} -t k9s-docker:0.1 . Run your container: docker run --rm -it -v ~/.kube/config:/root/.kube/config k9s-docker:0.1 PreFlight Checks
The Command Line# List all available CLI options
k9s help
# To get info about K9s runtime (logs, configs, etc..)
k9s info
# To run K9s in a given namespace
k9s -n mycoolns
# Start K9s in an existing KubeConfig context
k9s --context coolCtx
# Start K9s in readonly mode - with all cluster modification commands disabled
k9s --readonly LogsGiven 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: k9s info
# Will produces something like this
# ____ __.________
# | |/ _/ __ \______
# | < \____ / ___/
# | | \ / /\___ \
# |____|__ \ /____//____ >
# \/ \/
#
# Configuration: ~/Library/Preferences/k9s/config.yml
# Logs: /var/folders/8c/hh6rqbgs5nx_c_8k9_17ghfh0000gn/T/k9s-fernand.log
# Screen Dumps: /var/folders/8c/hh6rqbgs5nx_c_8k9_17ghfh0000gn/T/k9s-screens-fernand
# To view k9s logs
tail -f /var/folders/8c/hh6rqbgs5nx_c_8k9_17ghfh0000gn/T/k9s-fernand.log
# Start K9s in debug mode
k9s -l debug Key BindingsK9s uses aliases to navigate most K8s resources.
ScreenshotsDemo Videos/Recordings
K9s ConfigurationK9s keeps its configurations inside of a
# $XDG_CONFIG_HOME/k9s/config.yml
k9s:
# Represents ui poll intervals. Default 2secs
refreshRate: 2
# Number of retries once the connection to the api-server is lost. Default 15.
maxConnRetry: 5
# Enable mouse support. Default false
enableMouse: true
# Set to true to hide K9s header. Default false
headless: false
# Set to true to hide K9s crumbs. Default false
crumbsless: false
# Indicates whether modification commands like delete/kill/edit are disabled. Default is false
readOnly: false
# Toggles icons display as not all terminal support these chars.
noIcons: false
# Logs configuration
logger:
# Defines the number of lines to return. Default 100
tail: 200
# Defines the total number of log lines to allow in the view. Default 1000
buffer: 500
# Represents how far to go back in the log timeline in seconds. Setting to -1 will show all available logs. Default is 5min.
sinceSeconds: 300
# Go full screen while displaying logs. Default false
fullScreenLogs: false
# Toggles log line wrap. Default false
textWrap: false
# Toggles log line timestamp info. Default false
showTime: false
# Indicates the current kube context. Defaults to current context
currentContext: minikube
# Indicates the current kube cluster. Defaults to current context cluster
currentCluster: minikube
# Persists per cluster preferences for favorite namespaces and view.
clusters:
coolio:
namespace:
active: coolio
# With this set, the favorites list won't be updated as you switch namespaces
lockFavorites: false
favorites:
- cassandra
- default
view:
active: po
featureGates:
# Toggles NodeShell support. Allow K9s to shell into nodes if needed. Default false.
nodeShell: false
# Provide shell pod customization of feature gate is enabled
shellPod:
# The shell pod image to use.
image: killerAdmin
# The namespace to launch to shell pod into.
namespace: fred
# The resource limit to set on the shell pod.
limits:
cpu: 100m
memory: 100Mi
# The IP Address to use when launching a port-forward.
portForwardAddress: 1.2.3.4
kind:
namespace:
active: all
favorites:
- all
- kube-system
- default
view:
active: dp
# The path to screen dump. Default: '%temp_dir%/k9s-screens-%username%' (k9s info)
screenDumpDir: /tmp Popeye ConfigurationK9s has integration with Popeye, which is a Kubernetes cluster sanitizer. Popeye itself uses a configuration called Node ShellBy 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 # $XDG_CONFIG_HOME/k9s/config.yml
k9s:
clusters:
# Configures node shell on cluster blee
blee:
featureGates:
# You must enable the nodeShell feature gate to enable shelling into nodes
nodeShell: true
# You can also further tune the shell pod specification
shellPod:
image: cool_kid_admin:42
namespace: blee
limits:
cpu: 100m
memory: 100Mi Command AliasesIn K9s, you can define your very own command aliases (shortnames) to access your resources. In your # $XDG_CONFIG_HOME/k9s/alias.yml
alias:
pp: v1/pods
crb: rbac.authorization.k8s.io/v1/clusterrolebindings Using this alias file, you can now type pp/crb to list pods or ClusterRoleBindings respectively. HotKey SupportEntering the command mode and typing a resource name or alias, could be cumbersome for navigating thru often used resources. We're introducing hotkeys that allows a user to define their own hotkeys to activate their favorite resource views. In order to enable hotkeys please follow these steps:
Not feeling so hot? Your custom hotkeys will be listed in the help view You can choose any keyboard shortcuts that make sense to you, provided they are not part of the standard K9s shortcuts list.
FastForwardsAs of v0.25.0, you can leverage the
The annotation value takes on the shape
Example# Pod fred
apiVersion: v1
kind: Pod
metadata:
name: fred
annotations:
k9scli.io/auto-portforwards: zorg::5556 # => will default to container zorg port 5556 and local port 5566. No port-forward dialog will be shown.
# Or...
k9scli.io/portforward: bozo::9090:p1 # => launches the port-forward dialog selecting default port-forward on container bozo port named p1(8081)
# mapping to local port 9090.
...
spec:
containers:
- name: zorg
ports:
- name: p1
containerPort: 5556
...
- name: bozo
ports:
- name: p1
containerPort: 8081
- name: p2
containerPort: 5555
... 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:
Resource Custom ColumnsSneakCast 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
Here is a sample views configuration that customize a pods and services views. # $XDG_CONFIG_HOME/k9s/views.yml
k9s:
views:
v1/pods:
columns:
- AGE
- NAMESPACE
- NAME
- IP
- NODE
- STATUS
- READY
v1/services:
columns:
- AGE
- NAMESPACE
- NAME
- TYPE
- CLUSTER-IP PluginsK9s allows you to extend your command line and tooling by defining your very own cluster commands via plugins. K9s will look at
K9s does provide additional environment variables for you to customize your plugins arguments. Currently, the available environment variables are as follows:
ExampleThis defines a plugin for viewing logs on a selected pod using # $XDG_CONFIG_HOME/k9s/plugin.yml
plugin:
# Defines a plugin to provide a `ctrl-l` shortcut to tail the logs while in pod view.
fred:
shortCut: Ctrl-L
confirm: false
description: Pod logs
scopes:
- pods
command: kubectl
background: false
args:
- logs
- -f
- $NAME
- -n
- $NAMESPACE
- --context
- $CONTEXT
Benchmark Your ApplicationsK9s integrates Hey from the brilliant and super talented Jaana Dogan. 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 Initially, the benchmarks will run with the following defaults:
The PortForward view is backed by a new K9s config file namely: |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论