8000 GitHub - imjoseangel/powerline-k8sstatus at 21.1.2
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

imjoseangel/powerline-k8sstatus

Repository files navigation

Powerline K8S Status

CodeQL codecov Python package

A Powerline segment for showing the status of current Kubernetes context.

By imjoseangel

screenshot

It will show any or all of:

  • context name
  • namespace
  • username

You can also:

  • Toggle on or off the powerline-k8sstatus segment using an environment variable which can easily be mapped to a function in your ~/.profile file.

  • Define certain contexts to be colored differently for alerting purposes. For instance, you can have your production context showing up in bright red.

Requirements

The K8Sstatus segment requires kubectl. It can be installed following the instructions here.

Installation

Using pip

pip install powerline-k8sstatus

Configuration

The K8Sstatus segment uses a couple of custom highlight groups. You'll need to define those groups in your colorscheme, for example in .config/powerline/colorschemes/default.json:

{
  "groups": {
    "k8sstatus": {
      "fg": "brightestorange",
      "bg": "gray2",
      "attrs": []
    },
    "k8sstatus:alert": {
      "fg": "white",
      "bg": "solarized:red",
      "attrs": []
    },
    "k8sstatus_namespace": {
      "fg": "gray10",
      "bg": "darkestblue",
      "attrs": []
    },
    "k8sstatus_user": {
    "fg": "white",
    "bg": "green",
    "attrs": []
    },
    "k8sstatus:divider": {
      "fg": "white",
      "bg": "mediumorange",
      "attrs": []
    }
  }
}

Then you can activate the K8Sstatus segment by adding it to your segment configuration, for example in .config/powerline/themes/shell/default.json:

{
  "function": "powerline_k8sstatus.k8sstatus",
  "priority": 50,
  "args": {
    "show_namespace": true,
    "show_user": true,
    "alert_context": [
      "minikube",
      "production"
    ]
  }
},

Context names added to the alert_context arguments will be outlined in the segment by a different colour.

Reload powerline running powerline-daemon --replace to load the new settings.

By default powerline-k8sstatus will display the Kubernetes status segment context. It can be disabled temporarily if the environment variable POWERLINE_K8SSTATUS is set to 0. One way to do this would be with a simple function, such as putting this k8sstatus function in your ~/.bash_profile:

k8sstatus() {
    if [[ $POWERLINE_K8SSTATUS = "0" ]]; then
        unset POWERLINE_K8SSTATUS
    else
        export POWERLINE_K8SSTATUS=0
    fi
}

Toggle showing your Kubernetes segment in powerline by just typing k8sstatus in your terminal

License

Licensed under the MIT License.

0