Giter Club home page Giter Club logo

k1s's Introduction

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:

OS Installation
macOS brew install jq
Linux sudo apt-get install jq
OS Installation
macOS brew install watch
Linux โ€” (installed by default)
OS Installation
macOS โ€” (installed by default)
Linux sudo apt-get install curl
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.

k1s's People

Contributors

matthewhembree avatar weibeld avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

k1s's Issues

`brew` causes ":unneeded is deprecated!" warning

I am seeing the following message when executing brew commands, like brew uninstall or brew uninstall

Warning: Calling bottle :unneeded is deprecated! There is no replacement.
Please report this issue to the weibeld/core tap (not Homebrew/brew or Homebrew/core):
  /usr/local/Homebrew/Library/Taps/weibeld/homebrew-core/Formula/k1s.rb:7

Not sure what's going on but opening an ticket here as recommended by brew.

Can support `context`?

hi ;
In sometimes , nead to monitoring some k8s cluster,
if k1s support context like--> k1s --context k8s-cluster

k1s script stopped updating pods output

So yesterday I installed the k1s script on one of my k3s nodes. Really great simple concept, and exactly what I wanted for my extra monitor attached to my cluster. I created a tmux session with 12 different windows, each with an instance of the k1s script running, displaying different resources.

It appeared to be working, but I hadn't yet tested a change to watch it update in real time. I left it over night and came back to it 12 hours later. I deployed an updated version of kured to my cluster, which updated the daemonset and pods. However, the tmux window that was displaying the kube-system pods did not reflect the change, and after waiting a few minutes, and verifying on another window that the kured pods had been replaced, i control+c out of k1s and reran the k1s kube-system pods command and it updated with the new pods names that had been replaced for the kured ds. I also tested making a further change by deleting one of the Daemon Set pods for kured and it shows the replacement in real time in the k1s output.

So, it's only been one instance of this issue, and i'm wondering if there's some time out or limit with the kubernetes api i'm not aware of. If not, any advice on what information to collect or how to troubleshoot this? I'm thinking about just modifying the bash script to add +x and some logging to a file, but thought i'd ask if you had any better ideas.

If I find the problem or solution, i'll be happy to submit a pull request.

jq: error (at <stdin>:1): Cannot index number with string "object"

Hello,

Thank you for usefull tool. I am having an issue when run your tool. Jq can't parse output from k1s. Which jq version are you using ?

My jq version: 1.6

The error message:

jq: error (at <stdin>:1): Cannot index number with string "object"
parse error: Invalid numeric literal at line 1, column 9

fails with MacOS sed

GNU sed works correctly when extracting the port number:

$ sed 's/.*:\([0-9]\+\)\b.*/\1/' <<<'Starting to serve on 127.0.0.1:56083'
56083

But the MacOS sed fails:

$ sed 's/.*:\([0-9]\+\)\b.*/\1/' <<<'Starting to serve on 127.0.0.1:56083'
Starting to serve on 127.0.0.1:56083

I have no idea why it fails. But it makes the tool unusable on MacOS at the moment.

Feature requests

  • Label filtering: allow filtering resources by label, similar to -l/--selector option of kubectl get.
  • Multiple resource types: allow specifying multiple resource types for the same k1s instance (see #4)
  • Additional output: add option for additional output, e.g. from -o wide option (see comment below)

๐Ÿ‘‡ Comment for adding more feature requests ๐Ÿ‘‡

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.