Created
May 22, 2018 08:23
-
-
Save gitnik/59cb416d4e1b1589cfe79d50287bd6ab to your computer and use it in GitHub Desktop.
Revisions
-
gitnik created this gist
May 22, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ #!/usr/bin/env bash set -e kubedl () { TYPE=$1 NAME=$2 NAMESPACE=$3 if [ -z "$TYPE" ] || [ -z "$NAME" ]; then echo "Usage: kubedl <type> <name/label> <namespace=default>" return fi if [ -z "$NAMESPACE" ]; then NAMESPACE="default" fi if [[ "$NAME" =~ "=" ]]; then OBJECT=$(kubectl get "$TYPE" --no-headers --namespace="$NAMESPACE" --ignore-not-found | grep "$NAME" | awk '{print $1}') else OBJECT=$(kubectl get "$TYPE" --no-headers --namespace="$NAMESPACE" -l "$NAME" --ignore-not-found | awk '{print $1}') fi if [ -z "$OBJECT" ]; then echo "$TYPE not found with name/label $NAME" return fi kubectl delete "$TYPE" "$OBJECT" --namespace="$NAMESPACE" }