-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch_token.sh
More file actions
39 lines (34 loc) · 767 Bytes
/
fetch_token.sh
File metadata and controls
39 lines (34 loc) · 767 Bytes
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
#!/bin/bash
prom_token () {
kubectl get secrets \
-ojson \
-n openshift-monitoring \
--context "$1" | jq '
[
.items[] |
select(
(.metadata.annotations | has("kubernetes.io/service-account.name"))
and
(.metadata.annotations["kubernetes.io/service-account.name"] == "prometheus-k8s")
and (.data | has("token"))
)
] | .[0].data.token' -r | base64 --decode
}
context=""
print_usage() {
printf "
-c | cluster context to use:
"
}
while getopts "c:" f; do
case "$f" in
c)
context=${OPTARG}
;;
*)
print_usage
exit 1
;;
esac
done
prom_token $context