# \[SOLVED\]How update image with rancher API

**URL:** <https://forums.suse.com/t/solved-how-update-image-with-rancher-api/18349>\
**Category:** SUSE Rancher Prime\
**Created:** [September 16, 2020, 2:13pm UTC](https://forums.suse.com/t/solved-how-update-image-with-rancher-api/18349 "2020-09-16T14:13:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kolodziejczykrelyens](https://avatars.discourse-cdn.com/v4/letter/k/c68b51/32.png) [@kolodziejczykrelyens](https://forums.suse.com/u/kolodziejczykrelyens)\
**Post date:** [September 16, 2020, 2:13pm UTC](https://forums.suse.com/t/solved-how-update-image-with-rancher-api/18349/1 "2020-09-16T14:13:37Z")

</div>

I try to change the “Docker Image” of a “workload” via rancher api v3

I did manage to find how to do it via kubectl

> kubectl set image deployment documentservice [documentservice=private.depot.net/services/document-service:latest](http://documentservice=private.depot.net/services/document-service:latest) -n services

But, can’t find a way to do the same with Rancher API without sending a bigpayload with extrat information not needed.

I seek some thingth that would look like that

> curl -u “token:KEY” -X POST -H “Accept: application/json” -H “Content-Type: application/json”  
> “base\_url\_rancher/v3/project/c-b9wm7:p-pz5l8/workloads/deployment:services:documentservice?action=redeploy” -k

I did found some old post on this forum about this, but no good answer.

Link of old post

> [@Upgrade deployment image with rancher 2.0](http://forums.suse.com/t/upgrade-deployment-image-with-rancher-2-0/10399):
>
> Is there a way, updating via rancher API v3, to keep previous configurations and only updating the docker image?

A simple solution existe outside hack or usage of kubectl ?

---

<div class="post-metadata">

**Author:** ![vincent](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/vincent/32/7156_2.png) [@vincent](https://forums.suse.com/u/vincent)\
**Post date:** [September 16, 2020, 7:52pm UTC](https://forums.suse.com/t/solved-how-update-image-with-rancher-api/18349/2 "2020-09-16T19:52:06Z")

</div>

This doesn’t exist in the Rancher API but you can do it with the k8s one. `/k8s/clusters/<cluster id>` gets you to the k8s API for a cluster through Rancher. So something like:

```bash
curl -u ...
-X PATCH
-H 'Content-Type: application/json-patch+json'
https://<rancher server>/k8s/clusters/<cluster_id>/apis/apps/v1/namespaces/<namespace name>/deployments/<deployment name>
-d '[{"op": "replace", "path": "/spec/template/spec/containers/0/image", "value": "<new image>"}]'

```

---

<div class="post-metadata">

**Author:** ![kolodziejczykrelyens](https://avatars.discourse-cdn.com/v4/letter/k/c68b51/32.png) [@kolodziejczykrelyens](https://forums.suse.com/u/kolodziejczykrelyens)\
**Post date:** [September 17, 2020, 8:35am UTC](https://forums.suse.com/t/solved-how-update-image-with-rancher-api/18349/3 "2020-09-17T08:35:00Z")

</div>

Thanks for the response.  
It’s work exactly as expected.

Note:  
The base url can be find in the “Kubeconfig File”  
Don’t forget to had your token in the Header.
