Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

Commit

Permalink
Add script to enable upgrade from 7.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Mario Manno committed Mar 1, 2021
1 parent a341d67 commit 6e0ffa4
Showing 1 changed file with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash

# quarks-operator v7.1.3 added a new label `quarks.cloudfoundry.org/statefulset-name`. This is no longer supported and breaks STS updates.

if [ -n "$SINGLE_NAMESPACE" ]; then

# delete these
for sts in $(kubectl get sts -n "$SINGLE_NAMESPACE" -o name -l quarks.cloudfoundry.org/statefulset-name --ignore-not-found)
do
sts_name=$(echo "$sts" | sed 's@.*/@@')
echo 1>&2 "### Recreate sts: $sts_name ..."

if test -z "${sts_name}" ; then
echo 1>&2 "SKIP STS $sts: error"
continue
fi

kubectl get -n "$SINGLE_NAMESPACE" "$sts" -o json | jq --arg N "$sts_name" '
del(.metadata.namespace,.metadata.resourceVersion,.metadata.uid,.metadata.managedFields)
| .metadata.creationTimestamp=null
| del(
.spec.template.metadata.labels."quarks.cloudfoundry.org/statefulset-name",
.metadata.labels."quarks.cloudfoundry.org/statefulset-name",
.spec.selector.matchLabels."quarks.cloudfoundry.org/statefulset-name")
| .spec.template.metadata.labels."quarks.cloudfoundry.org/quarks-statefulset-name"=$N
| .spec.selector.matchLabels."quarks.cloudfoundry.org/quarks-statefulset-name"=$N
' > "$sts_name".json

kubectl delete -n "$SINGLE_NAMESPACE" --cascade=orphan "$sts"

kubectl apply --wait -n "$SINGLE_NAMESPACE" -f "$sts_name".json
done

# # update labels on pods
# for pod in $(kubectl get pod -n "$SINGLE_NAMESPACE" -o name -l "quarks.cloudfoundry.org/statefulset-name" --ignore-not-found)
# do
# sts_name=$(kubectl get -n "$SINGLE_NAMESPACE" "$pod" -o jsonpath="{.metadata.labels.quarks\.cloudfoundry\.org/statefulset-name}")

# echo 1>&2 " ### Update pod labels: $sts"
# # delete
# kubectl label -n "$SINGLE_NAMESPACE" "$pod" "quarks.cloudfoundry.org/statefulset-name"-
# # with az
# kubectl label --overwrite -n "$SINGLE_NAMESPACE" "$pod" "quarks.cloudfoundry.org/quarks-statefulset-name=$sts_name"
# done

fi

0 comments on commit 6e0ffa4

Please sign in to comment.