Managing services with webhooks

In this article


Overview

When a successful request is made to a service's unique webhook, the service and all its active containers are forced to stop and restart.

You can create a webhook for any containerized service in MedStack. There are two common cases users may wish to create and use webhooks on a service:

  1. Troubleshooting problematic services.
  2. Updating services that use the "latest" tag.

When a service with the latest tag is restarted, the latest image will be pulled from the registry for deployment in the service. Here's an example of what the latest tag would look like in the image url.

// Service configuration
image: "postgres:latest"

Multiple webhooks can exist for a service, and they can be enabled, or deleted and recreated to roll them. Each time a webhook is created, a new unique url is generated.

Create

A webhook can be created in a few steps.

  1. Navigate into the cluster running the desired service.

  2. Select the service to which you'd like to add a webhook.

  3. Click "ADD WEBHOOK" to create the webhook.
  4. A toast notification will indicate successful creation of the webhook. The details of the webhook can be found further down the service's details page.Navigate to the bottom of the page to copy the webhook.

Update

Webhooks cannot be updated. Rather, you can delete and existing webhook and generate a new unique webhook.

Delete

Webhooks can be deleted individually by clicking the "DELETE" button at the end of the line for each webhook.


FAQ

How do I format the request when calling a webhook?

A webhook can be trigger by using a HTTP POST request. This could look like:

curl --data `{}` $URL

The body in curly braces is not used, but is added to the request for completion. A curl request uses POST by default when passing data in this way. Alternatively, formatting a curl request in the following way will also work:

curl -X POST $URL

A successful response upon calling the a webhook appears as follows, and is the response from the docker swarm manager:

{"warnings": null}

Can I create multiple webhooks for the same service?

Yes, multiple unique webhooks can be created for the same service. Some users may wish to do this for tracking purposes.

Which version of the image is updated when the webhook is requested?

When the webhook is requested, the service is stopped and then restarted. The service's settings are not changed by any means. As such, the best configuration for a service's image tag, if intended to be updated using webhooks, is {imageUrl}:latest to ensure that the latest image is deployed upon the service restart invoked by the webhook.

The webhook uses the registry credentials stored in the Docker state for the service to fetch the image and tag available on the registry as specified in the service. It is important to note that the registry credentials tied to the service are those belonging to the MedStack Control user who last updated the service in the web application.

Does updating the image result in downtime?

Yes. The default Swarm configuration for updating services is stop-start. This is the default configuration to mitigate complications that can occur when different versions of the same service are running at the same time.

Users can expect the service downtime to elapse the duration of:

  • shutting down the service
  • starting the service. 

The time required to do this varies for each service.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Submit a request for support Submit a request for support