Skip to content

Commit 856c12d

Browse files
committed
deploy: more helpful output when kubectl fails
While debugging for PR kubernetes-csi#26 it was useful to see the actual input that was sent to kubectl. It's still not perfect, but that's because line numbers by kubectl refer to individual items, not the entire input, but at least it's something.
1 parent 28948fc commit 856c12d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

deploy/kubernetes-1.13/deploy-hostpath.sh

+7-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ run kubectl apply -f "${CSI_SNAPSHOTTER_RBAC}"
8888
echo "deploying hostpath components"
8989
for i in ${BASE_DIR}/hostpath/*.yaml; do
9090
echo " $i"
91-
cat "$i" | while IFS= read -r line; do
91+
modified="$(cat "$i" | while IFS= read -r line; do
9292
if echo "$line" | grep -q '^\s*image:\s*'; then
9393
# Split 'image: quay.io/k8scsi/csi-attacher:v1.0.1'
9494
# into image (quay.io/k8scsi/csi-attacher:v1.0.1),
@@ -111,7 +111,12 @@ for i in ${BASE_DIR}/hostpath/*.yaml; do
111111
echo " using $line" >&2
112112
fi
113113
echo "$line"
114-
done | kubectl apply -f -
114+
done)"
115+
if ! echo "$modified" | kubectl apply -f -; then
116+
echo "modified version of $i:"
117+
echo "$modified"
118+
exit 1
119+
fi
115120
done
116121
117122
# Wait until all pods are running. We have to make some assumptions

0 commit comments

Comments
 (0)