# How Can I Use License Custom Fields Value in a Pre-Flight Check?

**URL:** <https://community.replicated.com/t/how-can-i-use-license-custom-fields-value-in-a-pre-flight-check/624>\
**Category:** Packaging an application\
**Tags:** kots, support-bundle, troubleshoot, pre-flights\
**Created:** [December 29, 2021, 3:34pm UTC](https://community.replicated.com/t/how-can-i-use-license-custom-fields-value-in-a-pre-flight-check/624 "2021-12-29T15:34:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fernando\_Cremer](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.replicated.com/fernando_cremer/32/436_2.png) [@Fernando\_Cremer](https://community.replicated.com/u/Fernando_Cremer)\
**Post date:** [December 29, 2021, 3:34pm UTC](https://community.replicated.com/t/how-can-i-use-license-custom-fields-value-in-a-pre-flight-check/624/1 "2021-12-29T15:34:51Z")

</div>

The short answer is YES!

Let’s illustrate how to do this with a somewhat contrived example. Let’s say we want to license our product based on the number of nodes in the cluster. When we run a pre flight check, or even a support bundle, we want to check the number of nodes in the cluster against what we have licensed our customer.

**Step 1 - Create Custom License Field**

First, we’ll create our Custom License Field as shown below:

 ![Screen Shot 2021-12-29 at 10.21.52 AM](https://canada1.discourse-cdn.com/flex030/uploads/replicated/original/1X/cb5439de1818a969fb8f3e3e893d3b673902151c.png)

**Step 2 - Create Pre-Flight Check Using the Custom License Field**

Then, we’ll define a simple pre-flight check that uses the [node resources analyzer](https://troubleshoot.sh/docs/analyze/node-resources/) to check against the value:

```auto
apiVersion: troubleshoot.replicated.com/v1beta1
kind: Preflight
metadata:
  name: example-preflight-checks
spec:
  analyzers:
    - nodeResources:
        checkName: Node Count Check
        outcomes:
          - fail:
              when: 'count() > {{repl LicenseFieldValue "node_count"}}'
              message: The cluster has more nodes than the {{repl LicenseFieldValue "node_count"}} you are licensed for.
          - pass:
              message: The number of nodes matches your license ({{repl LicenseFieldValue "node_count"}})

```

**Step 3 - Create Test License**

Now, we’ll create the license and set up to fail. My cluster has 3 nodes, so I will set the value initially to 2:

 ![Screen Shot 2021-12-29 at 10.26.23 AM](https://canada1.discourse-cdn.com/flex030/uploads/replicated/original/1X/ac72952d407f82d4b9b12b7ccb4c20f53638b19c.jpeg)

**Step 4 - Validate!**

To quickly test this, I am going to deploy my app to a test cluster. Since my cluster has 3 nodes, the preflight fails:

 ![preflight-fail2](https://canada1.discourse-cdn.com/flex030/uploads/replicated/original/1X/c6292785c0265baa93bccaf7f7507c761c74c4ce.png)

To test the other condition, we’ll update the license field to 4, and then sync the license:

 ![license-sync](https://canada1.discourse-cdn.com/flex030/uploads/replicated/original/1X/5656a3768e8aaf66c2e9936675ff182b868964ac.png)

Once we sync the license, we are prompted to update the application and run the preflights again. This time, they pass:

 ![preflight-pass2](https://canada1.discourse-cdn.com/flex030/uploads/replicated/original/1X/a6d55a6124f0f927d508b4f62f7a3a5e2ce2343e.png)

Note that you can also use the value in the Custom License Field in the message that is displayed to the end user.
