Skip to content

Commit

Permalink
kubernetes: add current context and namespace for kubernetes
Browse files Browse the repository at this point in the history
  • Loading branch information
dbenque-1a authored and kb100 committed Jan 5, 2018
1 parent 972880e commit 54082a7
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
17 changes: 17 additions & 0 deletions kubernetes/README.md
@@ -0,0 +1,17 @@
# kubernetes

Show the kubernetes current context and namespace in use. This is usefull when you are operating multiple kube clusters and/or namespaces.

![](kubernetes.png)

# Dependencies

*kubectl* must be install and accessible under your *$PATH*

# Config

```
[kubernetes]
command=$SCRIPT_DIR/kubernetes
interval=10
```
3 changes: 3 additions & 0 deletions kubernetes/i3blocks.conf
@@ -0,0 +1,3 @@
[kubernetes]
command=$SCRIPT_DIR/kubernetes
interval=10
10 changes: 10 additions & 0 deletions kubernetes/kubernetes
@@ -0,0 +1,10 @@
#!/bin/bash
KCONTEXT=$(kubectl config current-context 2>/dev/null)
if [[ $?=="0" ]]; then
CC=$(kubectl config view -ojsonpath='{..current-context}')
KNAMESPACE=$(kubectl config view -ojsonpath="{.Contexts[?(@.Name==\"$CC\")]..namespace}")
echo "$KCONTEXT/$KNAMESPACE"
echo "$KCONTEXT/$KNAMESPACE"
echo \#4040FF # color
fi

Binary file added kubernetes/kubernetes.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 54082a7

Please sign in to comment.