forked from fabianlee/gcloud-kubectl-workload-identity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·57 lines (46 loc) · 1.46 KB
/
test.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
#!/bin/bash
dep="$1"
[ -n "$dep" ] || dep=workload-identity-test
ns=default
echo ""
echo "--GCP METADATA--"
kubectl exec -it deployment/$dep -n $ns -- curl -H "Metadata-Flavor: Google" http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/ 2>/dev/null
res_metadata=$?
echo ""
echo "--LIST PODS--"
kubectl exec -it deployment/$dep -n $ns -- kubectl get pods -A 2>/dev/null
res_pods=$?
echo ""
echo "--LIST DEPLOYMENTS--"
kubectl exec -it deployment/$dep -n $ns -- kubectl get deployments -A 2>/dev/null
res_deployments=$?
echo ""
echo "--LIST DAEMONSETS--"
kubectl exec -it deployment/$dep -n $ns -- kubectl get daemonset -A 2>/dev/null
res_ds=$?
echo ""
echo "--LIST REPLICASETS--"
kubectl exec -it deployment/$dep -n $ns -- kubectl get replicasets -A 2>/dev/null
res_rs=$?
echo ""
echo "--GCLOUD CLUSTERS--"
kubectl exec -it deployment/$dep -n $ns -- gcloud auth list 2>/dev/null
kubectl exec -it deployment/$dep -n $ns -- gcloud container clusters list 2>/dev/null
res_gcloud=$?
function resolve_code() {
if [ $1 -eq 0 ]; then
echo "OK"
else
echo "FAIL"
fi
}
echo "-----------------"
echo "SUMMARY"
echo "-----------------"
echo "GCP metadata $(resolve_code $res_metadata)"
echo "kubectl pods $(resolve_code $res_pods)"
echo "kubectl dep $(resolve_code $res_deployments)"
echo "kubectl ds $(resolve_code $res_ds)"
echo "kubectl rs $(resolve_code $res_rs)"
echo "gcloud clusters $(resolve_code $res_gcloud)"
echo ""