# Manage License

## Objective

- Configure the EMQX Enterprise license.
- Update EMQX Enterprise license.

## Configure License

You can apply for an EMQX Enterprise license for free on the EMQX official website: [Apply for EMQX Enterprise License](https://www.emqx.com/en/apply-licenses/emqx).

## Configure EMQX Cluster

The `apps.emqx.io/v3beta1` EMQX CRD supports configuring the EMQX cluster license through `.spec.config.roots.license`. Refer to the [Configuration Manual](https://docs.emqx.com/en/enterprise/v6.2.0/hocon/) for a complete configuration reference.

1. Save the following as a YAML file and deploy it using `kubectl apply`.

   ```yaml
   apiVersion: apps.emqx.io/v3beta1
   kind: EMQX
   metadata:
     name: emqx
   spec:
     config:
       roots:
         license:
           key: "..."
     image: emqx/emqx:6.3.2
     dashboardServiceTemplate:
       spec:
         type: LoadBalancer
   ```

   ::: tip

   The `.spec.config.roots.license.key` field contains the license key. Replace the placeholder in this example with your license key.

   :::

2. Wait for the EMQX cluster to become ready. 

   Check the status of the EMQX cluster with `kubectl get` and ensure that `STATUS` is `Ready`. This may take some time.

   ```bash
   $ kubectl get emqx emqx
   NAME   STATUS   AGE
   emqx   Ready    10m
   ```

## Update License

1. View the license information.

   ```bash
   $ kubectl exec -it service/emqx-headless -c emqx -- emqx ctl license info
   customer        : Evaluation
   email           : contact@emqx.io
   deployment      : default
   max_connections : 100
   start_at        : 2023-01-09
   expiry_at       : 2028-01-08
   type            : trial
   customer_type   : 10
   expiry          : false
   ```

   The output shows basic license information, including the applicant's information, the maximum number of connections supported by the license, and the expiration time.

2. Modify the EMQX CR to update the license.

   ```bash
   $ kubectl edit emqx emqx
   ...
   spec:
     image: emqx/emqx:6.3.2
     config:
       roots:
         license:
           key: "${new_license_key}"
   ...
   ```

3. Verify that the license has been updated.

   ```bash
   $ kubectl exec -it service/emqx-headless -c emqx -- emqx ctl license info
   customer        : Evaluation
   email           : contact@emqx.io
   deployment      : default
   max_connections : 100000
   start_at        : 2023-01-09
   expiry_at       : 2028-01-08
   type            : trial
   customer_type   : 10
   expiry          : false
   ```

   The updated `max_connections` field clearly indicates that the EMQX Enterprise license has been updated successfully. Keep in mind that the license update may take time, so you may need to retry the command.
