K1s Save Abandoned

The world's simplest Kubernetes dashboard (50 lines of Bash code)

Project README

k1s: The world's simplest Kubernetes dashboard

A minimalistic Kubernetes dashboard implemented with 50 lines of Bash code.

Screencast

Contents

  1. Introduction
  2. Installation
  3. Usage
  4. Examples

Introduction

What is it?

A minimalistic Kubernetes dashboard showing the current state of Kubernetes resources of a specific type in real-time. The entire tool consists merely of a Bash script with about 50 lines of code.

What is it not?

It's not a production-grade dashboard with many features. It's mainly intended for educational purposes.

How does it work?

With a lot of highly condensed Bash scripting. This article explains how it works in detail.

Installation

On macOS

brew install weibeld/tap/k1s

On other systems

Simply 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

Dependencies

The k1s script depends on the following tools:

jq

OS Installation
macOS brew install jq
Linux sudo apt-get install jq

watch

OS Installation
macOS brew install watch
Linux (installed by default)

curl

OS Installation
macOS (installed by default)
Linux sudo apt-get install curl

kubectl

OS Installation
macOS brew install kubernetes-cli
Linux See https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/

Usage

k1s runs directly on your local machine and it uses the usual kubeconfig configuration on your machine. That means, it connects to the same cluster that also kubectl connects to by default.

The command-line interface is as follows:

k1s [<namespace>] [<resource-type>]

Both arguments are optional. The default values are:

Argument Default value
<namespace> default
<resource-type> pods

The <namespace> argument may be set to any valid namespace in the cluster. In addition, <namespace> may be set to - to imply "all namespaces" for namespaced resource types and "no namespace" for non-namespaced resource types (e.g. ClusterRoles).

You can find out which resource types are namespaced or non-namespaced with kubectl api-resources --namespaced=true|false.

The <resource-type> argument may be set to any valid resource type name (including their singular, plural and short forms).

You can list all supported resource type names with kubectl api-resources.

To exit the dashboard, type Ctrl-C.

Examples

Below is an example usage scenario for k1s. It uses multiple instances of k1s for observing what's going on under the hood when scaling a Deployment:

Example application

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 and maxUnavailable 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

Advanced usage scenarios

Here's a list of more advanced usage scenarios contributed by users of k1s:

If you want to have your work added, file an issue, or directly make a pull request with your link added to this list.

Open Source Agenda is not affiliated with "K1s" Project. README Source: weibeld/k1s
Stars
232
Open Issues
2
Last Commit
1 year ago
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating