A simplistic Kubernetes dashboard implemented with 50 lines of Bash code.
____ ____ ____ |┻┳
||k |||1 |||s || __ |┳┻
||__|||__|||__|| The world's simplest Kubernetes dashboard (•.• |┻┳
|/__\|/__\|/__\| \⊃|┳┻
|┻┳
A minimalistic Kubernetes dashboard allowing you to observe Kubernetes resources of any type in any namespace (or across all namespaces) in real-time.
It's implemented as a Bash script with 50 lines of code.
k1s does not attempt to be a fully-featured production-grade Kubernetes dashboard (for such cases, it would be better to use a real programming language, such as Go).
Instead, it attempts to be as minimalistic as possible with the goal of being easy to install and use and adaptable to various use cases.
With a lot of highly condensed Bash scripting. This article explains how the code works.
brew install weibeld/core/k1s
Download the k1s
script, make it executable, and move it to any directory in your PATH
. For example:
{
wget https://raw.githubusercontent.com/weibeld/k1s/master/k1s
chmod +x k1s
mv k1s /usr/local/bin
}
The k1s
script depends on the following tools being installed on your system:
jq
# macOS brew install jq # Linux sudo apt-get install jq
watch
# macOS brew install watch # Linux (installed by default)
curl
# macOS (installed by default) # Linux sudo apt-get install curl
kubectl
# macOS brew install kubernetes-cli # Linux # See https://kubernetes.io/docs/tasks/tools/install-kubectl/
The k1s
script is run directly on your local machine. It has the following command-line interface:
k1s [namespace] [resource-type]
Both arguments are optional. The default values are:
namespace
: defaultresource-type
: pods
You can run multiple instances of the k1s
script simultaneously.
To exit the dashboard, type Ctrl-C.
Observe Pods in the default
namespace:
k1s
Observe Pods in the kube-system
namespace:
k1s kube-system
Observe Deployments in the default
namespace:
k1s "" deployments
Observe Deployments in the kube-system
namespace:
k1s kube-system deployments
Observe Deployments across all namespaces:
k1s - deployments
Observe ClusterRoles (non-namespaced resource):
k1s - clusterroles
You can specify the desired resource type in any of the name variants accepted by Kubernetes. In general, this includes:
- The plural form
- The singular form
- The shortname (if available)
Furthermore, the capitalisation of the plural and singular forms doesn't matter.
For example, all the following invocations are equivalent:
k1s default replicasets
k1s default replicaset
k1s default rs
k1s default ReplicaSets
k1s default ReplicaSet
You can find out the shortnames of all Kubernetes resources that have one with
kubectl api-resources
.
You can specify -
for the namespace
argument to list the specified resource type across all namespaces of the cluster.
For example, the following displays the Deployments from all the namespaces:
k1s - deployments
In the same way, you can list non-namespaced resources (such as Namespaces, ClusterRoles, PersistentVolumes, etc.).
For example:
k1s - persistentvolumes
You can find out all the non-namespaced resources with
kubectl api-resources --namespaced=false
.
An example usage scenario of k1s is using multiple instances of k1s for observing what's going on under the hood of scaling and rolling update operations on a Deployment:
Note how during the rolling update, you can observe how the replica count of the Deployment always stays within a certain range. You can influence this range with the
maxSurge
andmaxUnavailable
settings in the Deployment specification.
To recreate the above example, launch three instances of k1s in separate terminal windows (or in different tmux panes, as shown above):
k1s default deployments
k1s default replicasets
k1s default pods
Then, create a Deployment:
kubectl create deployment dep1 --image=nginx
Scale the Deployment:
kubectl scale deployment dep1 --replicas=10
Patch the Deployment with a new container image, which causes a rolling update:
kubectl patch deployment dep1 -p '{"spec":{"template":{"spec":{"containers":[{"name":"nginx","image":"nginx:1.19.0"}]}}}}'
You can also manually edit the Deployment with
kubectl edit deployment dep1
.
Finally, delete the Deployment:
kubectl delete deployment dep1
Here's a list of more advanced usage scenarios contributed by users of k1s:
- mjbright/k1s-scenarios by Mike Bright
If you want to have your work added, file an issue, or directly make a pull request with your link added to this list.