-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathget-nfs-volume-details.sh
More file actions
executable file
·61 lines (54 loc) · 2.18 KB
/
get-nfs-volume-details.sh
File metadata and controls
executable file
·61 lines (54 loc) · 2.18 KB
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
59
60
61
#! /bin/bash
# Copyright 2021 The OpenEBS Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This script runs tests and generates a report file.
if [ $# -ne 2 ]; then
echo "Please specify NFS PVC name and namespace"
echo "$0 <nfs_pvc_name> <nfs_pvc_namespace>"
exit 1
fi
nfs_pvc_name=$1
nfs_pvc_namespace=$2
backend_pvc_name=""
backend_pvc_namespace=""
nfs_pv_name=$(kubectl get pvc "${nfs_pvc_name}" -n "${nfs_pvc_namespace}" -o jsonpath='{.spec.volumeName}')
if [ -z "$nfs_pv_name" ]; then
echo "Unable to find NFS PV for PVC ${nfs_pvc_namespace}/${nfs_pvc_name}"
exit 1
fi
all_pvc_namespaces=$(kubectl get pvc --all-namespaces -o jsonpath="{range .items[*]}{@.metadata.name};{@.metadata.namespace}:{end}")
for pvc_name_namespace in `echo $all_pvc_namespaces | tr ":" " "`; do
arr=(${pvc_name_namespace//;/ })
pvc_name=${arr[0]}
pvc_namespace=${arr[1]}
if [ "nfs-${nfs_pv_name}" == "${pvc_name}" ]; then
backend_pvc_name="$pvc_name"
backend_pvc_namespace="$pvc_namespace"
break
fi
done
if [ -z "$backend_pvc_name" ] || [ -z "$backend_pvc_namespace" ]; then
echo "Looks like ${nfs_pvc_namespace}/${nfs_pvc_name} is not a NFS PVC... Not able to find backend PVC"
exit 1
fi
backend_pv_name=$(kubectl get pvc "${backend_pvc_name}" -n "${backend_pvc_namespace}" -o jsonpath='{.spec.volumeName}')
echo ""
echo ""
echo "----------------------------------------------------------------"
echo "Backend PVC Name: ${backend_pvc_name}"
echo "Backend PVC Namespace: ${backend_pvc_namespace}"
echo "Backend PV Name: ${backend_pv_name}"
echo "NFS PV Name: ${nfs_pv_name}"
echo "NFS PVC Namespace/Name: ${nfs_pvc_namespace}/${nfs_pvc_name}"