Upgrading services via API

Hi everyone.

I’m currently developing a CI / CD pipeline with Jenkins and Rancher. What I accomplished so far:

  • Fetching the sourcecode from a GIT repo
  • Build an image
  • Push that image into a private and local registry
  • Setup the service in Rancher

So far everything is up and running. What I’d like to do now is to automate the process of deploying the images into Docker containers on Rancher. This basically involves the upgrade-mechanism in Rancher (I’m using the mechanism via the UI and it works flawlessly).

Unfortunately, the documentation doesn’t help me to understand that mechanism better (http://docs.rancher.com/rancher/api/api-resources/service/).

I don’t know how this request would look like. Where to give the image registry and name? Where to give the target host strategy?

I’d be really happy about some examples. For normal (automated) deployments, only the imagetags change - nothing else.

Thanks for any help in advance.

Rgds

Thomas

@qdrop I just wrote about this in GitHub for someone else: https://github.com/rancher/rancher/issues/1874#issuecomment-180082502

1 Like

@vincent

Question: is there a way to call the API to get Rancher to refresh the catalog before calling the API for the upgrade? An issue I’ve come across is that the CI automation would update the git repo to the rancher catalog, but with the default refresh interval of 300 seconds, the catalog doesn’t always get refreshed before the API call for the upgrade.

Thanks in advance!

There is a refresh action in /v1-catalog/templates

@vincent

I missed that entry. Thank you very much!

Sorry to bother you again, but is there a way to specify the catalog to be refreshed?

EDIT: actually I don’t think that’s necessary. Sorry - and thanks again!

Nope, only all of them. That particular call (unlike most others) is synchronous so it doesn’t return a reply until the refresh is done.