Skip to content

Instantly share code, notes, and snippets.

@onefoursix
Last active July 23, 2023 04:25
Show Gist options
  • Save onefoursix/d3b3c07f811f583f726c54f154d378b4 to your computer and use it in GitHub Desktop.
Save onefoursix/d3b3c07f811f583f726c54f154d378b4 to your computer and use it in GitHub Desktop.
A Bash script to call the StreamSets Platform REST API to delete Kubernetes Deployments stuck in an Activating state
#!/usr/bin/env bash
# Script that calls the /provisioning/rest/v1/csp/deployment/${DEP_ID}/unsafeForceStop
# endpoint to delete StreamSets Kubernetes Deployments stuck in an Activating state.
#
# Use this REST API endpoint only if Kubernetes Deployments are stuck
# in an Activating state.
#
# After the script completes, the selected Deployments will be in a
# "Deactivation Error" state and can be deleted using the Control Hub UI
#
# Make sure to read the Deactivation Error status details in the Control Hub UI
# that will list the resources that might require manual cleanup after the
# unsafeForceStop operation has comnpleted.
CRED_ID="<YOUR CRED_ID>"
CRED_TOKEN="<YOUR CRED_TOKEN>"
BASE_URL="https://na01.hub.streamsets.com/provisioning/rest/v1/csp/deployment"
# Declare a space or newline delimited array of Deployment IDs to be deleted. For example
# declare -a DEP_IDS=( "72e0f740-c010-4ec7-b016-3346fa02effe:8030c2e9-1a39-11ec-a5fe-97c8d4369386"
# "dfc2542a-9295-46ce-9888-f5c7617489a5:8030c2e9-1a39-11ec-a5fe-97c8d4369386")
declare -a DEP_IDS=( "<Deployment ID1>"
"<Deployment ID2>"
"<Deployment ID3>")
# Loop through the list of Deployment IDs and call the unsafeForceStop endpoint
for DEP_ID in "${DEP_IDS[@]}"
do
curl -X POST ${BASE_URL}/${DEP_ID}/unsafeForceStop\?confirm=true \
-H "Content-Type:application/json" \
-H "X-Requested-By:curl" \
-H "X-SS-REST-CALL:true" \
-H "X-SS-App-Component-Id: $CRED_ID" \
-H "X-SS-App-Auth-Token: $CRED_TOKEN" -i
done
echo "See the status details in the Control Hub UI for each Deployment "
echo "for a list of resources that might require manual cleanup after the "
echo "unsafeForceStop operation."
echo "Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment