http plugin

The http plugin can call REST API over http/https on component instances.

Note: the http plugin currently works well only with ec2-asg as core plugin; specifically, with docker and docker-swarm plugins, the http plugin cannot access the project-specific network and hence cannot complete the requests. We're working on a solution in an upcoming version of the http plugin.

The http plugin supports the following actions:

  • get - perform a HTTP GET
  • post - perform a HTTP POST
  • get_ok - try GET and keep retrying until successful or times out (readiness check/wait)

The following arguments can be defined for the actions:

  • schema - URL schema to use: http (default) or https
  • port - port number, default is based on schema (80 for http, 443 for https)
  • path - URL path relative to host; e.g., 'healthz' or '/healthz'; '/' is allowed but not required (default '/')
  • data - string containing JSON data to pass on POST (default: no data)
  • ok_codes - comma-separated list of status codes to be considered ok (e.g., "200,404"). If empty, the standard OK codes are assumed
  • timeout - operation timeout, in seconds (default 120):
    • for get and post: maximum time to connect and get the first response byte
    • for get_ok: how long to keep retrying to get any of the ok_codes (success)

Note: selector is a deprecated argument that is no longer required. If you are migrating models from an older version of Skopos (up to an including 0.14), you can simply remove this argument. If it was the only argument, you can remove the whole arguments attribute.

Examples

Here are a few examples in the Skopos model "injected step" format:

components:
  appsrv:
    ...
    lifecycle:

      quality_probe:
        steps:
        - call:
            plugin: http
            action: get
            label: "check health over https"
            arguments: { schema: "https", path: "/healthz" }
        - call:
            plugin: http
            action: get
            label: "check health on alternate port"
            arguments: { port: 8080, path: "/healthz" }
        - call:
            plugin: http
            action: get
            label: "check for any response with short timeout"
            arguments: { path: "/anypath", ok_codes: "200,404", timeout: 5 }
        - call:
            plugin: http
            action: get_ok
            label: "wait until health check OK, retrying with timeout"
            arguments: { port: 8080, path: "/healthz", timeout: 300 }

      service_discovery_detach:
        - call:
            plugin: http
            action: post
            label: "enter maintance mode"  # using POST and post data (JSON-encoding)
            arguments: { port: 8080, path: "/admin/maintenance_mode", data: '{ "value":"1" }' }

Configuration

This plugin has no configuration settings