Skip to content

Instantly share code, notes, and snippets.

@funollet
Created December 14, 2017 16:14
Show Gist options
  • Save funollet/662f3c6feb6314eb87fd707f40a40717 to your computer and use it in GitHub Desktop.
Save funollet/662f3c6feb6314eb87fd707f40a40717 to your computer and use it in GitHub Desktop.
Quick&dirty dashboard for Elasticsearch in kubernetes
#!/usr/bin/env bash
# dashboard-es
#
# Args:
# $1: k8s namespace (default: read from $KUBECONFIG)
#
# You need some port redirection already established:
#
# kubectl port-forward <pod-name> 9200
CONTEXT=$(kubectl config current-context)
DEFAULT_NS=$(kubectl config view -o json \
| jq -r ".contexts | map(select(.name == \"${CONTEXT}\")) | .[].context.namespace")
NS="${1:-$DEFAULT_NS}"
title () {
local BLUE NORMAL LENGHT
BLUE='\033[0;34m' # Blue
NORMAL='\033[0m' # Normal
LENGHT=78
echo -e ${BLUE}
( printf '%0.1s' '#'{1..80} ; echo " $* ##" ) | tail -c -${LENGHT}
echo -en ${NORMAL}
}
title "Namespace: ${NS}"
title pods
kubectl -n ${NS} get deploy,sts -l component=elasticsearch
title nodes
curl -s 'localhost:9200/_cat/nodes?v&s=name'
title allocation
curl -s 'localhost:9200/_cat/allocation?v&s=node'
title health
curl -s localhost:9200/_cat/health?v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment