Skip to content
Permalink
Browse files

Update migration documentation

  • Loading branch information
polskikiel committed Nov 5, 2019
1 parent deeac82 commit 0d9ab30475a1c2be04abf8aba1ef4fb3bce58f5c
Showing with 118 additions and 25 deletions.
  1. +110 −25 contrib/hack/migration-check.sh
  2. +8 −0 docs/migration-apiserver-to-crds.md
@@ -1,67 +1,152 @@
#!/usr/bin/env bash

RESULT=
EXIT_CODE=0

function checkIfClassExist(){
local externalName=$1
local classesNames=$2

for class in ${classesNames}
do
if [[ "${class}" -eq "${externalName}" ]]; then
return 0
fi
done

return 1
}

function checkIfClassExistForInstance(){
serviceClassesNames=$(kubectl get serviceclasses --all-namespaces -ojsonpath="{.items[*].spec.externalName}")
clusterServiceClassesNames=$(kubectl get clusterserviceclasses -ojsonpath="{.items[*].spec.externalName}")

for className in $(kubectl get serviceinstances --all-namespaces -ojsonpath="{.items[*].status.userSpecifiedClassName}")
do
type=$(echo "${className}" | cut -d'/' -f1)
externalName=$(echo "${className}" | cut -d'/' -f2)

if [[ "${type}" -eq "ClusterServiceClass" ]]; then
checkIfClassExist "${externalName}" "${clusterServiceClassesNames}"
if [[ $? -eq 1 ]]; then
echo "${className} not exist in the cluster for the ServiceInstance anymore"
EXIT_CODE=1
fi
fi
if [[ "${type}" -eq "ServiceClass" ]]; then
checkIfClassExist "${externalName}" "${serviceClassesNames}"
if [[ $? -eq 1 ]]; then
echo "${className} not exist in the cluster for the ServiceInstance anymore"
EXIT_CODE=1
fi
fi
done

}

#
# Check if any class/plan was removed from broker's catalog
# Check if any class/plans were removed from broker's catalog
#

CSC=$(kubectl get clusterserviceclasses -ojsonpath="{.items[*].metadata.deletionTimestamp}")
CSC_STATUS=$(kubectl get clusterserviceclasses -ojsonpath="{.items[*].status.removedFromBrokerCatalog}")
if [[ -n ${CSC} ]] || [[ -n ${CSC_STATUS} ]]; then
RESULT="Some ClusterServiceClasses are dangling"
if [[ -n ${CSC} ]]; then
echo "There are ClusterServiceClasses with deletionTimestamp set"
EXIT_CODE=1
fi
for status in $(kubectl get clusterserviceclasses -ojsonpath="{.items[*].status.removedFromBrokerCatalog}")
do
if [[ -n "${status}" ]] && ${status}; then
echo "There are removedFromBrokerCatalog ClusterServiceClasses"
EXIT_CODE=1
fi
done

SC=$(kubectl get serviceclasses --all-namespaces -ojsonpath="{.items[*].metadata.deletionTimestamp}")
SC_STATUS=$(kubectl get serviceclasses --all-namespaces -ojsonpath="{.items[*].status.removedFromBrokerCatalog}")
if [[ -n ${SC} ]] || [[ -n ${SC_STATUS} ]]; then
RESULT="$RESULT Some ServiceClasses are dangling"
if [[ -n ${SC} ]]; then
echo "There are ServiceClasses with deletionTimestamp set"
EXIT_CODE=1
fi
for status in $(kubectl get serviceclasses --all-namespaces -ojsonpath="{.items[*].status.removedFromBrokerCatalog}")
do
if [[ -n "${status}" ]] && ${status}; then
echo "There are removedFromBrokerCatalog ServiceClasses"
EXIT_CODE=1
fi
done

CSP=$(kubectl get clusterserviceplans -ojsonpath="{.items[*].metadata.deletionTimestamp}")
CSP_STATUS=$(kubectl get clusterserviceplans -ojsonpath="{.items[*].status.removedFromBrokerCatalog}")
if [[ -n ${CSP} ]] || [[ -n ${CSP_STATUS} ]]; then
RESULT="$RESULT Some ClusterServicePlans are dangling"
if [[ -n ${CSP} ]]; then
echo "There are ClusterServicePlans with deletionTimestamp set"
EXIT_CODE=1
fi
for status in $(kubectl get clusterserviceplans -ojsonpath="{.items[*].status.removedFromBrokerCatalog}")
do
if [[ -n "${status}" ]] && ${status}; then
echo "There are removedFromBrokerCatalog ClusterServicePlans"
EXIT_CODE=1
fi
done

SP=$(kubectl get serviceplans --all-namespaces -ojsonpath="{.items[*].metadata.deletionTimestamp}")
SP_STATUS=$(kubectl get serviceplans --all-namespaces -ojsonpath="{.items[*].status.removedFromBrokerCatalog}")
if [[ -n ${SP} ]] || [[ -n ${SP_STATUS} ]]; then
RESULT="$RESULT Some ServicePlans are dangling"
if [[ -n ${SP} ]]; then
echo "There are ServicePlans with deletionTimestamp set"
EXIT_CODE=1
fi
for status in $(kubectl get serviceplans --all-namespaces -ojsonpath="{.items[*].status.removedFromBrokerCatalog}")
do
if [[ -n "${status}" ]] && ${status}; then
echo "There are removedFromBrokerCatalog ServicePlans"
EXIT_CODE=1
fi
done

#
# Check if any instance/binding is in progress or is being deleted
#
SI=$(kubectl get serviceinstances --all-namespaces -ojsonpath="{.items[*].metadata.deletionTimestamp}")
SI_STATUS=$(kubectl get serviceinstances --all-namespaces -ojsonpath="{.items[*].status.asyncOpInProgress}")
if [[ -n ${SI} ]] || [[ "${SI_STATUS}" -eq "true" ]]; then
RESULT="$RESULT Some ServiceInstances are dangling"
if [[ -n "${SI}" ]]; then
echo "There are ServiceInstances with deletionTimestamp set"
EXIT_CODE=1
fi
for status in $(kubectl get serviceinstances --all-namespaces -ojsonpath="{.items[*].status.asyncOpInProgress}")
do
if [[ -n "${status}" ]] && ${status}; then
echo "There are ServiceInstance in progress"
EXIT_CODE=1
fi
done
# checks if there are some instances with not existing classes
checkIfClassExistForInstance

SBI=$(kubectl get servicebindings --all-namespaces -ojsonpath="{.items[*].metadata.deletionTimestamp}")
SBI_STATUS=$(kubectl get servicebindings --all-namespaces -ojsonpath="{.items[*].status.asyncOpInProgress}")
if [[ -n ${SBI} ]]; then
RESULT="$RESULT Some ServiceBindings are dangling"
echo "There are ServiceBindings with deletionTimestamp set"
EXIT_CODE=1
fi
for status in $(kubectl get servicebindings --all-namespaces -ojsonpath="{.items[*].status.asyncOpInProgress}")
do
if [[ -n "${status}" ]] && ${status}; then
echo "There are ServiceBinding in progress"
EXIT_CODE=1
fi
done

#
# Check if any broker is being deleted
#
SB=$(kubectl get servicebrokers --all-namespaces -ojsonpath="{.items[*].metadata.deletionTimestamp}")
if [[ -n ${SB} ]]; then
RESULT="$RESULT Some ServiceBrokers are dangling"
echo "There are being deleted ServiceBrokers"
EXIT_CODE=1
fi
CSB=$(kubectl get clusterservicebrokers -ojsonpath="{.items[*].metadata.deletionTimestamp}")
if [[ -n ${CSB} ]]; then
RESULT="$RESULT Some ClusterServiceBrokers are dangling"
echo "There are being deleted ClusterServiceBrokers"
EXIT_CODE=1
fi


echo "${RESULT}"
echo "EXIT CODE: $EXIT_CODE"
if [[ ${EXIT_CODE} -eq 0 ]]; then
echo "Your Service Catalog resources are ready to migrate!"
else
echo "Please prepare your Service Catalog resources for migration"
fi

exit ${EXIT_CODE}
@@ -119,6 +119,12 @@ To test the mutation blocking feature, execute the following commands:
./service-catalog migration --action undeploy-blocker --service-catalog-namespace=default
```

>**CAUTION:** You can safely remove the migration job PVC, which contains data about your Service Catalog resources only when the migration end up successfully.
In order to make an successful migration, the Service Catalog resources can't be in the unfinished/deleted state. Otherwise our upgrade job can fail.

To check if your cluster is ready to migration, use the sanity check [script](https://github.com/kubernetes-sigs/service-catalog/blob/master/contrib/hack/migration-check.sh).

## Cleanup

You can delete all the migration-related resources using this command:
@@ -151,3 +157,5 @@ Then you can execute the rollback using this command:
```
helm rollback catalog 1 --cleanup-on-fail --no-hooks
```

The migration job PVC with the data about your Service Catalog resources still exists after the rollback. You can run migration again to restore them.

0 comments on commit 0d9ab30

Please sign in to comment.
You can’t perform that action at this time.