#!/bin/bash

namespace=$1
pg_pod=`kubectl -n ${namespace} get pod --no-headers  | awk '{print $1}' | grep postgres`
kubectl_cmd="kubectl -n ${namespace} exec -it ${pg_pod} --"
${kubectl_cmd} bash -c "echo \"select count(*) from pg_database where datname='keycloak';\" | /usr/bin/psql -U postgres | egrep -iv '(count|---|row)' | tr -d ' ' | tr -d '\n'"