Configure a Temporary Preview Link to a Deployed Service

Configure a temporary public preview link to a deployed service for testing.

Overview

Create a temporary public preview link to a deployed service to verify HTTP services after their deployment. The created link is generated with a cryptographically secure domain prefix and automatically expires after a configured time period.

You can use this step in both canary and blue-green deployment strategies.

Expose your service

Canary strategy: add an exposeServices step to strategies.<strategyName>.canary.steps in your deployment file.

Blue/Green strategy: add an exposeServices entry to strategies.<strategyName>.redirectTrafficAfter in your deployment file.

The section enables exposing deployed service resources via a temporary, internet-facing, randomly generated link for testing purposes.

...
- exposeServices:
    services:
      - <service-name-1>
      - <service-name-2>
      - <service-name-n>
    ttl:
      duration: <integer>
      unit: <seconds|minutes|hours>
  • services: List of one-to-many services to expose
    • Each service name must match an existing service deployed in the target cluster.
    • Each service must be in the same namespace as the app you are deploying.
    • Each service must define a single HTTP port.
  • ttl: (Optional) The lifetime of the exposed service preview
    • Minimum: 1 minute (60 seconds)
    • Maximum: 24 hours
    • Default: 5 minutes

Each link automatically expires after the configured amount of time. The exposed link is not secure.

You can configure multiple exposeServices entries, each having a different expiration time.

You can use exposed service links elsewhere in your deploy config, such as in your webhook definitions. The naming convention is armory.preview.<service-name>.

Example

In this example, the snippet instructs Armory CD-as-a-Service to create a public URL to the deployed services service-name-1 and service-name-2. Both automatically expire after 2 hours.

...
- exposeServices:
    services:
      - service-name-1
      - service-name-2
    ttl:
      duration: 2
      unit: hours

Find your exposed service URL

Customer Portal

The Resources section of your Deployment details page displays a clickable link to preview your service. CD-as-a-Service automatically creates the preview link right after the exposeServices step completes - no need to refresh the page. On the link itself there is a tooltip with the approximate remaining lifetime of the preview link.

CD-as-a-Service deactivates the link after the service preview expires.

REST API

You can find your exposed URL by doing a GET to https://api.cloud.armory.io/deploy-engine/deployments/{{deploymentID}}.

You can find the exposeServices step in the strategy’s steps collection. The exposeServices steps contains a preview object with the following keys:

  • previews: map of service-name:URL objects
  • expiresAtIso8601: the absolute timestamp of the preview link’s expiration

Webhook context

After the preview link is created, you can use it in context of the webhook action for current strategy. The link naming convention is armory.preview.<service name>.

If you have a long-running deployment, be suure to choose a long enough ttl for the service, so that the link passed to the webhook has not already expired.

Example

If you configure the following in a canary strategy:

...
steps:
...
- exposeServices:
    services:
      - sample-app-svc
    ttl:
      duration: 20
      unit: minutes

… and then deploy your app, you would see this in your deployment details:

The preview link in the Resources section

If you query the REST API endpoint, you see results similar to:

The preview link in the REST API results

To reference an exposed service in your webhook, add a runWebhook step in your strategy and then add a preview-link in your webhook definition. For example:

...
steps:
...
- runWebhook:
    name: call-service
...
webhooks:
- name: call-service
  ... other webhook configuration properties
  bodyTemplate:
  inline: >-
  {
  "preview-link": "{{armory.preview.sample-app-svc}}"
  }  

Last modified October 31, 2023: (f370fe9)