4 # Query k8s to determine where the mgr is running and how to reach the
5 # dashboard from the local machine. This assumes that the dashboard is being
6 # exposed via a nodePort service
8 K8S_NAMESPACE
='rook-ceph'
10 HOST
=$
(kubectl get pods
-n $K8S_NAMESPACE -l "app=rook-ceph-mgr" -o json | jq .items
[0].spec.nodeName |
sed s
/\"//g
)
11 if [ "$HOST" = "minikube" ]; then
14 PORT
=$
(kubectl get service
-n $K8S_NAMESPACE rook-ceph-mgr-dashboard
-o yaml |
grep nodePort
: |
awk '{print $2}')
15 API_URL
="https://${HOST}:${PORT}"
18 # Rook automagically sets up an "admin" account with a random PW and stuffs
19 # that into a k8s secret. This fetches it.
21 PASSWD
=$
(kubectl
-n $K8S_NAMESPACE get secret rook-ceph-dashboard-password
-o yaml |
grep "password:" |
awk '{print $2}' | base64
--decode)
23 if [ "$API_URL" = "null" ]; then
24 echo "Couldn't retrieve API URL, exiting..." >&2
29 TOKEN
=`curl --insecure -s -H "Content-Type: application/json" -X POST \
30 -d "{\"username\":\"admin\",\"password\":\"${PASSWD}\"}" $API_URL/api/auth \
31 | jq .token | sed -e 's/"//g'`
34 echo "URL: ${API_URL}${2}"
38 curl
--insecure -s -b /tmp
/cd-cookie.txt
-H "Authorization: Bearer $TOKEN " \
39 -H "Content-Type: application/json" -X $1 -d "$3" ${API_URL}$2 | jq