1

I was able to rollback pod. However, I am not able to redeploy. Following is query.

curl -u "auth" -X POST -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{"replicaSetId":null}' 'URL?action=rollback'

Is any one know how to do it ?

Kush Patel
  • 3,685
  • 5
  • 42
  • 65

2 Answers2

3

I agree it will be nice to have redeploy action in the API. But for now you can use the following workaround (taken from official rancher forum, but I fixed some headers due to errors):

pod_upgrade_body=$(curl -u "token-[use your token here]" \
-s 'https://rancher.mydomain.com/v3/project/c-zqpm5:p-h884r/workloads/deployment:development:api' \
-X GET \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Pragma: no-cache' \
-H 'Cache-Control: no-cache' 2>&1 | sed  "s/\"cattle\.io\/timestamp\"\:\"[0-9T:Z-]*\"/\"cattle\.io\/timestamp\":\"$(date -u +"%Y-%m-%dT%H:%M:%SZ")\"/g")

curl -u "token-[use your token here]" \
-s 'https://rancher.mydomain.com/v3/project/c-zqpm5:p-h884r/workloads/deployment:development:api' \
-X PUT \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--data-binary "$pod_upgrade_body" --compressed 
Roman Podlinov
  • 23,806
  • 7
  • 41
  • 60
1

Updating the answer for current 2.6 rancher:

url='https://yourdomain'
cluster=c-m-yourcluter
app=yourappname
namespace=probablyisDefault
token=token-name:keyvalue


pod_upgrade_body=$(curl -s -u "$token" \
-k $url/k8s/clusters/$cluster/v1/apps.deployments/$namespace/$app \
-X GET \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Pragma: no-cache' \
-H 'Cache-Control: no-cache' 2>&1 | sed  "s/\"cattle\.io\/timestamp\"\:\"[0-9T:Z-]*\"/\"cattle\.io\/timestamp\":\"$(date -u +"%Y-%m-%dT%H:%M:%SZ")\"/g")

curl -u "$token" \
-k -s $url/k8s/clusters/$cluster/v1/apps.deployments/$namespace/$app \
-X PUT \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--data-binary "$pod_upgrade_body" --compressed