From 2238d43564d8eb11927419065aa6853fcb887335 Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Fri, 31 Mar 2023 23:06:49 +0200 Subject: [PATCH] add fancy debug pod script --- hack/start-debug-pod.sh | 65 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100755 hack/start-debug-pod.sh diff --git a/hack/start-debug-pod.sh b/hack/start-debug-pod.sh new file mode 100755 index 0000000..813d580 --- /dev/null +++ b/hack/start-debug-pod.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +# Usage: start-debug-pod.sh + +# Validate input parameters +if [ $# -ne 2 ]; then + echo "Usage: start-debug-pod.sh " + exit 1 +fi + +PVC_NAME=$1 +NAMESPACE=$2 + +if [ -z "$PVC_NAME" ] || [ -z "$NAMESPACE" ]; then + echo "PVC name and namespace cannot be empty" + exit 1 +fi + +# Check if namespace exists +if ! kubectl get namespace "$NAMESPACE" > /dev/null 2>&1; then + echo "Namespace $NAMESPACE does not exist" + exit 1 +fi + +# Check if PVC exists in the specified namespace +if ! kubectl get pvc "$PVC_NAME" -n "$NAMESPACE" > /dev/null 2>&1; then + echo "PVC $PVC_NAME does not exist in namespace $NAMESPACE" + exit 1 +fi + +# Define the name of the debug pod +DEBUG_POD_NAME="debug-pod-$PVC_NAME" + +# Create the YAML file for the debug pod +kubectl apply -f - <