Skip to content

Change the Encryption Key

This guide replaces the encryption key of a running Ella Core deployment.

1. Create the new key

openssl rand -base64 32 > encryption-new.key

Copy it to every node.

2. Switch each node

On each node, one at a time:

  1. On the Cluster page, drain the node.
  2. Keep the current key as the previous key, and install the new one:

    sudo mv /var/snap/ella-core/common/data/encryption.key /var/snap/ella-core/common/data/encryption-previous.key
    sudo install -m 0600 encryption-new.key /var/snap/ella-core/common/data/encryption.key
    
  3. Add to /var/snap/ella-core/common/core.yaml:

    encryption:
      previous-key:
        file:
          path: /var/snap/ella-core/common/data/encryption-previous.key
    
  4. Restart the node:

    sudo snap restart ella-core.cored
    
  5. On the Cluster page, resume the node.

Delete encryption-new.key.

3. Verify

Once every node runs with the new key, the leader logs the audit event retire_cluster_key:

sudo snap logs -n all ella-core.cored | grep retire_cluster_key

4. Remove the previous key

On each node, one at a time:

  1. On the Cluster page, drain the node.
  2. Remove the encryption block from core.yaml.
  3. Restart the node:

    sudo snap restart ella-core.cored
    
  4. On the Cluster page, resume the node.

  5. Move encryption-previous.key off the node. Keep it as long as you keep backups taken before the change.

On a standalone deployment, the pod is ella-core-0. In a cluster, node <n>'s pod is ella-core-<n>-0.

To restart a node:

  1. On the Cluster page, drain the node.
  2. Restart its pod:

    kubectl -n ella delete pod ella-core-<n>-0
    kubectl -n ella wait --for=condition=Ready pod/ella-core-<n>-0 --timeout=10m
    
  3. On the Cluster page, resume the node.

1. Keep the current key as the previous key

kubectl -n ella get secret ella-core-encryption -o jsonpath='{.data.key}' | base64 -d > encryption-previous.key
kubectl -n ella create secret generic ella-core-encryption-previous --from-file=key=encryption-previous.key
helm upgrade ella-core oci://ghcr.io/ellanetworks/charts/ella-core --version <current-version> --namespace ella --reuse-values \
  --set encryption.previousSecretName=ella-core-encryption-previous

Restart each node, one at a time.

2. Replace the key

kubectl -n ella create secret generic ella-core-encryption --from-literal=key="$(openssl rand -base64 32)" \
  --dry-run=client -o yaml | kubectl apply -f -

Restart each node, one at a time.

3. Verify

Once every node runs with the new key, the leader logs the audit event retire_cluster_key:

kubectl -n ella logs -l app.kubernetes.io/name=ella-core --tail=-1 | grep retire_cluster_key

4. Remove the previous key

helm upgrade ella-core oci://ghcr.io/ellanetworks/charts/ella-core --version <current-version> --namespace ella --reuse-values \
  --set encryption.previousSecretName=

Restart each node, one at a time.

Delete the Secret:

kubectl -n ella delete secret ella-core-encryption-previous

Keep encryption-previous.key as long as you keep backups taken before the change.