-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release 1.1.0 (-loops, -time, doc and examples adapted)
- Loading branch information
Jean-Paul Argudo
committed
Jan 20, 2024
1 parent
2d70747
commit bcff015
Showing
21 changed files
with
393 additions
and
61 deletions.
There are no files selected for viewing
This file contains 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 characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
Binary file not shown.
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/bin/bash | ||
|
||
#YOUR CONFIG | ||
PRIMARY_POD=$(kubectl -n postgres-operator get pods \ | ||
--selector=postgres-operator.crunchydata.com/role=master \ | ||
-o jsonpath='{.items[*].metadata.labels.postgres-operator\.crunchydata\.com/instance}') | ||
|
||
NAMESPACE="postgres-operator" | ||
|
||
usage() { | ||
echo "Usage: $0" | ||
echo "" | ||
echo " Will delete the StatefulSet of the PostgreSQL primary pod" | ||
echo " Adapt the script in #YOUR_CONFIG section to your environment" | ||
echo " kubectl must be present in your PATH" | ||
echo " Current NAMESPACE is set to \"${NAMESPACE}\"" | ||
} | ||
|
||
delete_primary_pod_sts () { | ||
echo "Deleting sts on ${NAMESPACE} for pod ${PRIMARY_POD}" | ||
kubectl delete sts -n ${NAMESPACE} "${PRIMARY_POD}" | ||
} | ||
|
||
check_kubectl_is_present () { | ||
if ! [ -x "$(command -v kubectl)" ] | ||
then | ||
echo "kubebctl could not be found on this system" | ||
echo "install it prior executing this script" | ||
exit 1 | ||
fi | ||
} | ||
|
||
# check presence of kubectl | ||
check_kubectl_is_present | ||
|
||
# WARNING MESSAGE | ||
echo "************************************************************************" | ||
echo "WARNING!" | ||
echo "========" | ||
echo " You're about to delete the follwing StafefulSet of the PG primary pod:" | ||
echo " - namespace \"${NAMESPACE}\"" | ||
echo " - pod \"${PRIMARY_POD}\"" | ||
echo " This action has no return back, unless you have a working HA in place" | ||
echo "************************************************************************" | ||
echo "Abort this if your namespace is different from the default" | ||
echo "" | ||
read -p "Are you sure you want to continue [y/N]: " SURETHING | ||
SURETHING=`echo ${SURETHING:-N} | tr 'a-z' 'A-Z'` | ||
|
||
if [[ "${SURETHING}" == "N" ]] | ||
then | ||
echo "Aborting!" | ||
usage | ||
exit 0 | ||
else | ||
delete_primary_pod_sts | ||
fi | ||
|
51 changes: 51 additions & 0 deletions
51
examples/patroni_monitoring/ha_test_tools/kill_pgSimload_sessions.sh
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/bash | ||
|
||
#YOUR CONFIG | ||
SUPERUSER='postgres' | ||
POSTGRESDB='postgres' | ||
POSTGRESPORT=5432 | ||
|
||
usage() { | ||
echo "Usage: $0 -h (hostname|ip)" | ||
echo "" | ||
echo " Will pg_terminate_backend() all pids matching pgSimload application." | ||
echo " It assumes your superuser is '${SUPERUSER}' on database '${POSTGRESDB}'" | ||
echo " running on port ${POSTGRESPORT}. If that's not the case, please" | ||
echo " edit this tool ${0} in the section #YOUR CONFIG" | ||
echo " and that you know the superuser password, prefabilty have it in ~/.pgpass" | ||
} | ||
|
||
exit_abnormal () { | ||
usage | ||
exit 0 | ||
} | ||
|
||
execute_kills () { | ||
echo "Killing pgSimload process(es) on ${HOSTNAME}" | ||
psql -h ${HOSTNAME} -U ${SUPERUSER} -p ${POSTGRESPORT} ${SUPERUSERDB} \ | ||
-c "select pg_terminate_backend(pids.pid) | ||
from | ||
(select pid | ||
from pg_stat_activity | ||
where application_name='pgSimload') pids" | ||
} | ||
|
||
if [ -z "$1" ]; then | ||
exit_abnormal | ||
fi | ||
|
||
while getopts ":h:" flag; do | ||
case "${flag}" in | ||
h) | ||
HOSTNAME=${OPTARG} | ||
execute_kills | ||
;; | ||
:) | ||
echo "Error : -${OPTARG} requires an argument." | ||
exit_abnormal | ||
;; | ||
*) | ||
exit_abnormal | ||
;; | ||
esac | ||
done |
Oops, something went wrong.