License server

Back up and restore activity

Keep the license server's key and its activity history safe, and put them back after a loss.

The license server keeps two things you can’t get back from anywhere else: its signing key, and its activity history, the record of what every seat was used for. It snapshots the activity history every day by itself, but those snapshots live in the same cluster, so keep a copy of both elsewhere. Seat state needs no backup: every seat expires on its own, so a lost seat store only means that machines check out new seats.

The commands below need the license server’s admin token, which the chart generates when it installs, and keeps across upgrades and an uninstall. It’s the credential that reads everyone’s activity and shows holders’ names, so hand it out as carefully as the rest.

To replace the token, delete its Secret and upgrade the release, which generates a new one, then restart the three deployments that read it when they start. To manage the token yourself instead, put it in a Secret of your own under the key token and name that Secret in adminToken.existingSecret.

Get the admin token
TOKEN=$(kubectl -n tenon-licensing get secret \    license-manager-admin-token \    -o jsonpath='{.data.token}' | base64 -d)
Replace the admin token
kubectl -n tenon-licensing delete secret \    license-manager-admin-tokenhelm upgrade license-manager \    oci://<registry>/<path>/license-manager \    -n tenon-licensing --version <chart-version> \    -f tenon-licensing-values.yamlkubectl -n tenon-licensing rollout restart \    deploy/license-manager-licensed \    deploy/license-manager-activityd \    deploy/license-manager-dashboard

Keep the license server’s key

The license server signs every seat with a key it generated inside your cluster, which your license from Tangram is bound to. If the key is lost, as when its namespace is deleted, the license server generates a new one at its next install, and your license no longer matches it: you’d need a new license from Tangram before it could hand out seats again. Save the key from its Secret, licensed-delegate, somewhere as safe as your other credentials. Keep the two files Tangram sent you, delegation.json and root-pub.pem, beside it.

To restore them, create both Secrets in the namespace before you install the chart. The key-generation job then keeps the key you restored, and the license server starts with your license.

Save the key
kubectl -n tenon-licensing get secret licensed-delegate \    -o jsonpath='{.data.delegate-key\.pem}' \    | base64 -d > delegate-key.pem
Restore the key and the license
kubectl -n tenon-licensing create secret generic \    licensed-delegate --from-file=delegate-key.pemkubectl -n tenon-licensing create secret generic licensed-trust \    --from-file=delegation.json --from-file=root-pub.pem

Export the activity history

Export the whole activity history, as one JSON record per line, and keep the file off the cluster. Do this as often as you need, such as daily: an export is never too much, because importing one skips the records that are already there.

Export the activity history
curl -H "Authorization: Bearer $TOKEN" \    https://licensing.example.com/v1/activity/export \    -o activity.ndjson

The daily snapshots

The activity store takes a snapshot of its database every 24 hours, onto its own volume, license-manager-activityd-backup, and keeps the newest 14. The snapshots are SQLite files, named activity-<time>.db. Set activity.backup.interval and activity.backup.keep in your values file to change how often, and how many; activity.backup.existingClaim puts them on a volume you provide, such as one on other storage.

The license server reports on them at /v1/activity/export’s neighbour, /v1/activity/health: when the last snapshot was taken, how large the database is, and whether the store is keeping up with what’s coming in. It answers to the admin token.

To take one now, rather than wait for the next, ask the activity store itself. It isn’t on your network, so reach it with a port-forward.

Check the snapshots
curl -H "Authorization: Bearer $TOKEN" \    https://licensing.example.com/v1/activity/health
Take a snapshot now
kubectl -n tenon-licensing port-forward \    svc/license-manager-activityd 18091:8080 &curl -X POST -H "Authorization: Bearer $TOKEN" \    http://localhost:18091/v1/backup/run

Restore from a snapshot

Restoring from a snapshot puts the activity history back as it was when the snapshot was taken. Stop the activity store, copy the snapshot over its database, and start it again. The copy has to run as the activity store’s own user, 65532, or the restored database is read-only to it, and has to remove the database’s leftover journal files, which would otherwise be replayed onto it.

Replace <time> with the snapshot you want. Any image with a shell works in place of busybox, such as one from your own registry. Then import your latest export, to bring back anything recorded after the snapshot.

activity-restore.yaml
apiVersion: v1
kind: Pod
metadata:
  name: activity-restore
spec:
  restartPolicy: Never
  securityContext:
    runAsUser: 65532
    runAsGroup: 65532
    fsGroup: 65532
  containers:
    - name: restore
      image: busybox
      command:
        - sh
        - -c
        - >-
          cp /backup/activity-<time>.db /data/activity.db &&
          rm -f /data/activity.db-wal /data/activity.db-shm
      volumeMounts:
        - { name: data, mountPath: /data }
        - { name: backup, mountPath: /backup }
  volumes:
    - name: data
      persistentVolumeClaim:
        claimName: license-manager-activityd
    - name: backup
      persistentVolumeClaim:
        claimName: license-manager-activityd-backup
Restore from a snapshot
kubectl -n tenon-licensing scale \    deploy/license-manager-activityd --replicas=0kubectl -n tenon-licensing apply -f activity-restore.yamlkubectl -n tenon-licensing wait pod/activity-restore \    --for=jsonpath='{.status.phase}'=Succeededkubectl -n tenon-licensing delete pod activity-restorekubectl -n tenon-licensing scale \    deploy/license-manager-activityd --replicas=1

Restore from an export

Import an export into the license server, in the cluster it came from or a new one. Records that are already there are skipped, so it’s safe to import the same file more than once, or to import over a restored snapshot.

The license server answers with how many records it added, and how many it skipped.

Import an export
curl -X POST -H "Authorization: Bearer $TOKEN" \    -H "Content-Type: application/x-ndjson" \    --data-binary @activity.ndjson \    https://licensing.example.com/v1/activity/import

How long activity is kept

The activity store keeps 365 days of history, and deletes what’s older when it starts and once a day after that. activity.retentionDays sets the number. That same window is how long a seat holder can still read their own history after their seat has gone, and activity.lateAcceptDays, 7 days, is how long the license server accepts activity a machine queued while it was offline.

Nothing you export is removed, so an export taken inside the window keeps that history for as long as you keep the file, and importing it back is safe.

Send activity to your logging system

Besides storing each record, the license server writes it to its own log as one JSON line, marked "msg":"activity". Collecting the seat service’s pod logs gives you a copy of the history outside the cluster’s volumes, in whatever your security information and event management system already reads. Set activity.logToStdout to false to stop it.

Read the activity the license server logs
kubectl -n tenon-licensing logs \    deploy/license-manager-licensed \    | grep '"msg":"activity"'

Next steps