# License

The user is required to provide a license to run Alluxio, with the exception running with the trial version. The license is provided by your Alluxio sales representative in the form of a text string.

The license comes in two forms and are applied in different ways:

* A cluster license is set in the cluster's configuration properties
* A deployment license is applied by creating a separate license CRD

## Cluster license

A cluster license is the default way to provide a license for a single test cluster; it is not recommended for production deployments.

When creating `alluxio-cluster.yaml` as part of [deploying Alluxio](https://documentation.alluxio.io/ee-ai-en/ai-3.6/start/install-alluxio-on-kubernetes#deploy-alluxio), add `alluxio.license` as an entry under `spec.properties`:

```yaml
apiVersion: k8s-operator.alluxio.com/v1
kind: AlluxioCluster
spec:
  properties:
    alluxio.license: <CLUSTER_LICENSE>
```

## Deployment license

A deployment license is the default way to provide a license for a production deployment. A single deployment license is able to provide licenses for multiple clusters. Instead of reading the license string from configuration, the cluster processes will retrieve it from ETCD. A prerequisite for generating a deployment license is to provide the name and namespace of each cluster.

When creating `alluxio-cluster.yaml` as part of [deploying Alluxio](https://documentation.alluxio.io/ee-ai-en/ai-3.6/start/install-alluxio-on-kubernetes#deploy-alluxio), be sure not to set `alluxio.license` as an entry under `spec.properties`, otherwise it is assumed to be used as a cluster license.

After launching the cluster, wait for the coordinator and worker pods to reach a `Status` of `Init:2/3`; note this will be `Init:1/2` if ETCD deployment is disabled. This means that the pods are waiting for the license to be allocated to ETCD.

Create a `alluxio-license.yaml`:

```yaml
apiVersion: k8s-operator.alluxio.com/v1
kind: License
metadata:
  name: alluxio-license
  namespace: alx-ns
spec:
  clusters:
  - name: <clusterName>
    namespace: <namespaceName>
  - name: <clusterName2>
    namespace: <namespaceName2>
  licenseString: <DEPLOYMENT_LICENSE>
```

The `<DEPLOYMENT_LICENSE>` is the deployment license string as provided. The `<clusterName>` and `<namespaceName>` should match the corresponding values under `metadata` in `alluxio-cluster.yaml`:

```yaml
apiVersion: k8s-operator.alluxio.com/v1
kind: AlluxioCluster
metadata:
  name: <clusterName>
  namespace: <namespaceName>
```

If the namespace is not set, use `default` as the namespace name. If there are more than one cluster managed by the same operator, continue to enumerate the clusters' name and namespace under `clusters`.

{% hint style="warning" %}
Only specify the exact clusters that have been launched in `alluxio-license.yaml`. If the operator fails to locate one of the clusters listed, the license operation will fail and no clusters can proceed with their deployment.
{% endhint %}

Apply the license by running `kubectl create -f alluxio-license.yaml`. Inspect the Alluxio pods again and they should shortly transition their Status from `Init` to `Running`.

### Updating a deployment license

Use the same `alluxio-license.yaml` as before to specify the clusters. Update the `licenseString` with the new deployment license string.

Recreate the license by running delete and create.

```
kubectl delete -f alluxio-license.yaml
kubectl create -f alluxio-license.yaml
```

The Alluxio processes will be notified to pick up and apply the new license.

## Checking the license status

The CLI commands under `bin/alluxio license` describe the license details and the cluster utilization of license limits.

To view the contents of the license, such as listing the expiration date and cluster capacity,\
run `bin/alluxio license show`.

```bash
$ bin/alluxio license show
{
    "type": "official",
    "productionId": "<productionId>",
    "licenseId": "<licenseId>",
    "licenseVersion": 1,
    "expirationDate": "2025-01-01T00:00:00Z",
    "gracePeriodDate": "2025-01-01T00:00:00Z",
    "maxTotalStorageCapacityGB": 5000
}
```

To view the utilization of license limits, run `bin/alluxio license status`.

```bash
$ bin/alluxio license status
{
    "summary": {
        "vCPU": 9,
        "memory": "12.00GB",
        "storage": "100.00GB",
        "processes": 2,
        "versions": {
            "<licenseId>": 2
        }
    },
    "processes": {
        "10.0.0.1:29999": {
            "licenseId": "<licenseId>",
            "vCPU": 8,
            "memory": "8.00GB",
            "storage": "100.00GB"
        },
        "alluxio-coordinator-0.alluxio:19998": {
            "licenseId": "<licenseId>",
            "vCPU": 1,
            "memory": "4.00GB"
        }
    }
}
```

The `summary` section describes the aggregate of all the values listed by each individual process.\
The fields of particular note are:

* `storage` is the total worker capacity, which is compared against the license's `maxTotalStorageCapacityGB` if it exists
* `processes` is the total number of processes, which is compared against the license's `maxProcessCount` if it exists
* `versions` maps the license ID to the number of processes configured with the corresponding license.\
  It is expected that all processes are configured with the same license, but a mismatch could occur due to an incomplete license update.
