Skip to content

Commit

Permalink
handle bare pods as well
Browse files Browse the repository at this point in the history
Signed-off-by: Gerd Oberlechner <[email protected]>
  • Loading branch information
geoberle committed Dec 19, 2024
1 parent 3a2ae4c commit 5eaf957
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions dev-infrastructure/scripts/istio.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,13 @@ echo "********** Istio Upgrade Started with version ${NEWVERSION} **************
istioctl tag set "$TAG" --revision "${NEWVERSION}" --istioNamespace ${ISTIO_NAMESPACE} --overwrite
for namespace in $(kubectl get namespaces --selector=istio.io/rev="$TAG" -o jsonpath='{.items[*].metadata.name}'); do
echo "in namespace $namespace"
pods="$(kubectl get pods --namespace "${namespace}" -o json)"
for owner in $(kubectl get pods --namespace "${namespace}" -o json | jq -r --arg NEWVERSION ${NEWVERSION} '.items[] | select(.metadata.annotations["sidecar.istio.io/status"] | fromjson.revision != $NEWVERSION) | "\(.metadata.ownerReferences[0].kind)/\(.metadata.ownerReferences[0].name)"' | sort | uniq); do
# bare pods
for pod in $(kubectl get pods --namespace "${namespace}" -o json | jq -r --arg NEWVERSION ${NEWVERSION} '.items[] | select(.metadata.annotations["sidecar.istio.io/status"] | fromjson.revision != $NEWVERSION) | select(.metadata.ownerReferences | length == 0) | .metadata.name'); do
echo "recycle pod $pod"
kubectl delete pod "$pod" -n "$namespace"
done
# pods with owners
for owner in $(kubectl get pods --namespace "${namespace}" -o json | jq -r --arg NEWVERSION ${NEWVERSION} '.items[] | select(.metadata.annotations["sidecar.istio.io/status"] | fromjson.revision != $NEWVERSION) | select(.metadata.ownerReferences) | "\(.metadata.ownerReferences[0].kind)/\(.metadata.ownerReferences[0].name)"' | sort | uniq); do
echo "process pod owner ${owner}"
case "$owner" in
"ReplicaSet"*)
Expand Down

0 comments on commit 5eaf957

Please sign in to comment.