#!/bin/bash

for ns in `kubectl get ns --no-headers | cut -d" " -f1`; do
  web=""
  app=""
  web=`kubectl -n $ns get po  -l app.kubernetes.io/name=nextcloud,app.kubernetes.io/component=web --no-headers -o wide | grep "pw5\|pw6" | cut -d" " -f1 | head -n1`
  app=`kubectl -n $ns get po  -l app.kubernetes.io/name=nextcloud,app.kubernetes.io/component=app --no-headers -o wide | grep "pw5\|pw6" | cut -d" " -f1 | head -n1`
  if [ ! -z "$web" ]; then
    kubectl -n $ns --wait=false delete po $web
  fi
  if [ ! -z "$app" ]; then
    kubectl -n $ns --wait=false delete po $app
  fi
done
