Skip to main content

Checking Entitlements in Helm Charts Before Deployment

This topic describes how to check license entitlements before a Helm chart is installed or upgraded. The information in this topic applies to Helm charts installed with Replicated KOTS or Helm.

The Replicated SDK API can be used to check entitlements at runtime. For more information, see Querying Entitlements with the Replicated SDK API.

Overview

The Replicated registry automatically injects customer entitlement information in the global.replicated.licenseFields field of your Helm chart values. For example:

# Helm chart values.yaml
global:
replicated:
licenseFields:
expires_at:
description: License Expiration
name: expires_at
signature:
v1: iZBpESXx7fpdtnbMKingYHiJH42rP8fPs0x8izy1mODckGBwVoA...
title: Expiration
value: "2023-05-30T00:00:00Z"
valueType: String

You can access the values in the global.replicated.licenseFields field from your Helm templates to check customer entitlements before installation.

Prerequisite

Add the Replicated SDK to your application:

Check Entitlements Before Installation or Upgrade

To check entitlements before installation:

  1. Create or edit a customer to use for testing:

    1. In the Vendor Portal, click Customers. Select a customer and click the Manage customer tab. Alternatively, click + Create customer to create a new customer. For more information, see Creating and Managing Customers.

    2. Edit the built-in license fields or add custom fields for the customer. For example, you can set a license expiration date in the Expiration policy field. Or, you can create a custom field that limits the number of nodes a user is permitted in their cluster. For more information, see Managing Custom License Fields.

  2. In your Helm chart, update the Helm templates with one or more directives to access the license field. For example, you can access the built-in expires_at field with {{ .Values.global.replicated.licenseFields.expires_at }}. Add the desired logic to control application behavior based on the values of license fields.

    For more information about accessing values files from Helm templates, see Values Files in the Chart Template Guide section of the Helm documentation.

  3. Test your changes by promoting a new release and installing in a development environment:

    1. Package your Helm chart and its dependencies into a .tgz chart archive. See Packaging a Helm Chart for a Release.

    2. Add the .tgz archive to a release and promote to a development channel, such as Unstable. See Managing Releases with the Vendor Portal.

    3. Install in a development environment using the license ID for the test customer that you created. See Installing with Helm.

  4. Repeat these steps to add and test new license fields.