This repository has been archived by the owner on Oct 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script to enable upgrade from 7.1.3
- Loading branch information
Mario Manno
committed
Mar 1, 2021
1 parent
a341d67
commit 6e0ffa4
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
deploy/helm/quarks/hooks/pre-upgrade/remove-sts-name-label-v7.1.3.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,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 |