Previews enable automated deployments, triggered by pull requests and feature branches. They allow you to test changes in isolated environments before merging to your main branch. When you create a pull request, Ryvn automatically deploys your changes using blueprints, giving you a live preview of your application.

Previews help you catch issues early by providing isolated testing environments for every pull request.

How Previews Work

Previews are automatically triggered by GitHub webhooks when pull requests are opened, updated, or closed. Ryvn will create a unique blueprint installation for the preview and allow you to stand up a single or multiple services, depending on what your blueprint contains. Each preview is destroyed after the pull request is closed or merged or if there is no new activity for 7 consecutive days.

Previews may continue to incur additional infrastructure costs if you have a large number of PRs being opened and not being closed.

Enabling Previews

1

Configure Preview

Define previews in your ryvn.yaml file with a blueprint and target environment. Make sure the target environment supports cluster auto-scaling.

2

Create Pull Request

Push your changes to a feature branch and create a pull request.
3

Automatic Deployment

Ryvn detects the PR and automatically deploys your changes using the preview configuration.

4

Test & Review

Access your preview environment to test changes and share with reviewers.
5

Cleanup

When the PR is closed or merged, the preview environment is automatically removed.

Using Previews

Previews are configured in your ryvn.yaml file alongside your blueprints and environments. Here’s an example of a preview configuration:

apiVersion: v1

blueprints:
  - name: frontend-blueprint
    description: "Frontend application"
    services:
      - service: frontend
        config: |
          ingress:
            annotations:
              cert-manager.io/cluster-issuer: external-issuer
          className: external-nginx
          enabled: true
          hosts:
              - host: '{{.ryvn.installation.name}}.{{.ryvn.env.state.public_domain.name}}'
              paths:
                  - path: /
                  pathType: Prefix
          tls:
              - hosts:
                  - '{{.ryvn.installation.name}}.{{.ryvn.env.state.public_domain.name}}'
              secretName: '{{.ryvn.installation.name}}-tls'

      - service: backend
        config: |
          replicas: 3

previews:
  - name: "frontend-previews"
    environment: "previews"
    fromBlueprint:
      name: "frontend-blueprint"

See ryvn.yaml Preview Reference for detailed information about all the preview fields.

Preview Configuration

Each preview requires three main components:

Preview Properties

PropertyTypeRequiredDescription
namestringYesName of the preview. Must be lowercase alphanumeric with hyphens, max 63 characters.
environmentstringYesName of the environment where previews will be installed.
fromBlueprintobjectYesBlueprint configuration for the preview.

Environment Selection

The environment field specifies where your preview will be deployed. This should typically be a dedicated environment for previews that is using an auto-scaling cluster.

Avoid using production environments for previews to prevent accidental exposure of untested changes and resource contention.

Blueprint Configuration

The fromBlueprint configuration is similar to environment installations but with preview-specific inputs:

fromBlueprint:
  name: "my-app-blueprint"
  inputs:
    - name: "replica_count"
      value: 1
    - name: "debug_mode"
      value: true

Automating URL Generation

Each preview can get a unique URL assigned if your installation uses the correct ingress configuration that generates unique URLs. See the example below:

ingress:
  annotations:
    cert-manager.io/cluster-issuer: external-issuer
className: external-nginx
enabled: true
hosts:
  - host: "{{.ryvn.installation.name}}.{{.ryvn.env.state.public_domain.name}}"
    paths:
      - path: /
        pathType: Prefix
tls:
  - hosts:
      - "{{.ryvn.installation.name}}.{{.ryvn.env.state.public_domain.name}}"
    secretName: "{{.ryvn.installation.name}}-tls"

Troubleshooting

Common Issues