-
Notifications
You must be signed in to change notification settings - Fork 0
/
kube.dot.sh
58 lines (49 loc) · 1.71 KB
/
kube.dot.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
function kubectl() {
if ! type __start_kubectl >/dev/null 2>&1; then
source <(command kubectl completion zsh)
fi
command kubectl "$@"
}
function kube-prometheus () {
kubectl port-forward --namespace prometheus $(kubectl get pod --namespace=prometheus -l app=prometheus -l component=server | tail -n 1 | awk '{print $1}') 9090 &
sleep 1
open "http://localhost:9090"
fg
}
function kube-pushgateway () {
kubectl port-forward --namespace prometheus $(kubectl get pod --namespace=prometheus -l app=prometheus -l component=pushgateway | tail -n 1 | awk '{print $1}') 9091 &
sleep 1
open "http://localhost:9091"
fg
}
function kube-alertmanager () {
kubectl port-forward --namespace prometheus $(kubectl get pod --namespace=prometheus -l app=prometheus -l component=alertmanager | tail -n 1 | awk '{print $1}') 9093 &
sleep 1
open "http://localhost:9093"
fg
}
function kube-grafana () {
kubectl port-forward --namespace grafana $(kubectl get pod --namespace=grafana | tail -n 1 | awk '{print $1}') 3000 &
sleep 1
open "http://localhost:3000"
fg
}
function kube-image () {
kubectl get pods -l $1 -o jsonpath="{template.spec.containers.image}" |\
tr -s '[[:space:]]' '\n' |\
sort |\
uniq -c
}
function kube-check () {
kubectl describe pod `kubectl get pods -o go-template --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}' | fzf` | less
}
function kube-pods-maybe-broken () {
# Print kube pods with a high number of restarts, or that are in a crash loop.
kubectl get pod | awk -F ' ' '{if (($4 >= 10) || ($3 ~ ".*Crash.*")) print $0}'
}
function kube-kibana () {
kubectl port-forward svc/kibana-kibana 5601 -n elastic &
sleep 1
open "http://localhost:5601"
fg
}