This repository implements a kubectl plugin for get/delete kubernetes resources by regex patterns.
🔍 Get resources by regex (Pods, Deployments, Services, ConfigMaps, CRDs, …)
🗑 Delete resources by regex with confirmation
🏷 Works with any resource supported by your cluster’s API
🌐 Supports --namespace, -n, --context, --kubeconfig, --all-namespaces like native kubectl
⚡ Powered by Go’s RE2 regex engine (safe, no catastrophic backtracking)
Instead of typing something like to delete all pods that contain "app" in current namespace:
kubectl get pods | grep "app" | awk '{print $1}' | xargs kubectl delete podsYou can simply run:
kubectl regex delete pods "app"git clone https://github.com/ahmedTouati/kubectl-regex.git
cd kubectl-regex
go build -o kubectl-regex cmd/kubectl-regex.go
mv kubectl-regex /usr/local/bin/Check plugin discovery:
kubectl plugin listGet resources
# Get pods starting with "nginx-"
kubectl regex get pods "^nginx-"
# Get services ending with "-svc"
kubectl regex get services ".*-svc"
# Get deployments containing "web" in namespace "foo"
kubectl regex get deployments "web" -n "foo"Delete resources
# Delete all configmaps containing "app" in namespace foo
kubectl regex delete configmaps "app" -n foo
# Delete all deployments whose names start with "test-" in the default namespace, without asking for confirmation (use with caution)
kubectl regex delete deployments "^test-" --yesAll namespaces
kubectl regex get pods "nginx" -AUses Go’s built-in regexp
Apache 2.0 License.