How to redeploy your app using the command line

When using the kots dashboard, and you already have a version of your application deployed, you probably know there’s an option to “redeploy” your application.

Doing the same from the command line, we’ll use combination of the kots kubectl plugin and some REST api call (not supported, so subject to change)

app_slug=[YOUR_APP_SLUG]
kotsadm_url=[KOTSADM ENDPOINT, for example: https://34.74.175.182:8800]
kotsadm_password=[KOTSADM PASSWORD]
json=$(jq -n -c --arg password "$kotsadm_password" '$ARGS.named')
token=$(curl -s -k -H "Content-Type: application/json" --request POST -d "$json" $kotsadm_url/api/v1/login | jq -r ".token")
sequence=$(kubectl kots upstream upgrade $app_slug -n default -o json | jq .currentRelease.sequence)
echo "Redeploying application $app_slug with sequence $sequence"
curl -k -H "Authorization: $token" --request POST $kotsadm_url/api/v1/app/$app_slug/sequence/$sequence/redeploy

Change the first 3 lines to contain the correct values for your instance.

1 Like

Also, you can use kotsd if you want to do it with a single command.
kotsd redeploy [...name]: Redeploy all the apps on the instance.