-
Notifications
You must be signed in to change notification settings - Fork 1
/
psmdb-logs.sh
executable file
·49 lines (44 loc) · 928 Bytes
/
psmdb-logs.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
#!/usr/bin/env bash
usage() {
echo "Usage: $(basename "$0") --namespace <namespace>"
exit 1
}
main() {
local namespace=""
local pod=""
local args=""
while [[ $# -gt 0 ]]; do
key="$1"
case "${key}" in
-h | --help)
usage
exit 0
;;
-n | --namespace)
namespace="$2"
shift
shift
;;
-f | --follow)
args="${args:--f}"
shift
;;
*)
echo "unknown flag or option ${key}"
usage
exit 1
;;
esac
done
pod=$(kubectl get pods -l name=percona-server-mongodb-operator --output name ${namespace:+--namespace $namespace})
if [ -z "${pod}" ]; then
pod=$(kubectl get pods -l app.kubernetes.io/name=psmdb-operator --output name ${namespace:+--namespace $namespace})
fi
if [ -n "${pod}" ]; then
kubectl logs "${pod}" ${namespace:+--namespace $namespace} ${args:-}
else
echo "Operator pod is not found in the namespace!"
exit 1
fi
}
main "$@" || exit 1