Last active
June 15, 2022 12:50
-
-
Save mrWinston/fa0ac133e2bc9965b296804d6dd0b4a8 to your computer and use it in GitHub Desktop.
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
#/bin/bash | |
set -euo pipefail | |
monitoringPodList="$(oc -n openshift-monitoring get pods)" | |
firstDelete=( | |
"openshift-monitoring/alertmanager-main-0" | |
"openshift-monitoring/prometheus-k8s-0" | |
"openshift-monitoring/$(echo "$monitoringPodList" | grep "grafana" | awk '{print $1}')" | |
"openshift-monitoring/$(echo "$monitoringPodList" | grep "telemeter-client" | awk '{print $1}')" | |
"openshift-monitoring/$(echo "$monitoringPodList" | grep "thanos-querier" | awk '{print $1}' | head -n 1)" | |
"openshift-user-workload-monitoring/prometheus-user-workload-0" | |
) | |
secondDelete=( | |
"openshift-monitoring/alertmanager-main-1" | |
"openshift-monitoring/prometheus-k8s-1" | |
"openshift-monitoring/$(echo "$monitoringPodList" | grep "thanos-querier" | awk '{print $1}' | tail -n 1)" | |
"openshift-user-workload-monitoring/prometheus-user-workload-1" | |
) | |
printf "Deleting the following pods:\n" | |
for pod in ${firstDelete[@]}; do | |
printf "\t$pod\n" | |
done | |
for pod in ${secondDelete[@]}; do | |
printf "\t$pod\n" | |
done | |
read -p "Are you sure? [y/n]" -n 1 -r | |
if [[ ! $REPLY =~ ^[Yy]$ ]] | |
then | |
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1 | |
fi | |
for pod in ${firstDelete[@]}; do | |
echo "Deleting pod $pod" | |
oc -n "$(cut -d / -f 1 <<< $pod)" delete pod "$(cut -d / -f 2 <<< $pod)" | |
done | |
echo "Waiting for userworkloadmonitoring-0 and prometheus-0 to come back up..." | |
oc wait --for=condition=ready -n openshift-user-workload-monitoring pod prometheus-user-workload-0 | |
oc wait --for=condition=ready -n openshift-monitoring pod prometheus-k8s-0 | |
for pod in ${secondDelete[@]}; do | |
echo "Deleting pod $pod" | |
oc -n "$(cut -d / -f 1 <<< $pod)" delete pod "$(cut -d / -f 2 <<< $pod)" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Workaround for known issue https://bugzilla.redhat.com/show_bug.cgi?id=2033575 in Openshift 4.10. Run this after connected to your cluster.