diff --git a/docs-site/content/kagent/main/operations/operational-considerations.md b/docs-site/content/kagent/main/operations/operational-considerations.md index 97928d19..6a3222e8 100644 --- a/docs-site/content/kagent/main/operations/operational-considerations.md +++ b/docs-site/content/kagent/main/operations/operational-considerations.md @@ -277,6 +277,7 @@ To sign callbacks, generate one unencrypted PKCS#8 Ed25519 key and store it in a | Setting | Description | | ------- | ----------- | | `controller.push.signing.secretName` | The Secret that holds `private-key.pem`. Leave it empty to send push notifications without JSON Web Token (JWT) authentication. Helm references a Secret that you create, and neither generates nor rotates signing keys. If you set this field, the chart mounts the key and sets `config.push.signingPrivateKeyFile` to `/etc/kagent/secrets/push-private-key.pem`. | + | `controller.push.signing.previousSecretName` | Optional. The Secret that holds the previous `private-key.pem` during a signing-key handoff. If you set this field, the chart mounts the key and sets `config.push.previousSigningPrivateKeyFile` to `/etc/kagent/secrets/push-previous-private-key.pem`. The chart fails to render when this field is set without `controller.push.signing.secretName` or `config.push.signingPrivateKeyFile`. | | `config.push.issuer` | The stable URL that webhook receivers trust as the JWT issuer. If you omit the key, the chart derives the issuer from `ui.externalUrl`, and then from the in-cluster A2A gateway URL. An empty string is rejected, because the controller requires an absolute `http://` or `https://` URL. | | `config.push.signingKeyActivationDelay` | How long the controller publishes a replacement public key before it signs callbacks with the replacement key. The default is `300s`, and the maximum is `86400s`. Add enough time for receivers to refresh their JWKS cache. The controller also adds a fixed 30-second buffer before signing with the replacement key. | @@ -291,9 +292,56 @@ To sign callbacks, generate one unencrypted PKCS#8 Ed25519 key and store it in a When a signing key is configured, each callback attempt carries a newly issued five-minute Ed25519 JWT in an `Authorization: Bearer` header, and the `/.well-known/jwks.json` endpoint publishes the matching public key. -Every controller replica must load the same key. The controller reopens the mounted key file every 15 seconds, so a Secret or Container Storage Interface (CSI) rotation does not need a controller restart. The JWKS endpoint publishes the replacement public key as soon as a replica reloads the key, but the replica keeps signing with the previous key until `config.push.signingKeyActivationDelay` plus the 30-second buffer passes. After activation, the previous public key stays in the JWKS until the five-minute tokens that it signed expire, plus 30 seconds of clock skew. +Every controller replica must load the same key. The controller reopens the mounted key file every 12 to 18 seconds, so a Secret or Container Storage Interface (CSI) rotation does not need a controller restart. The JWKS endpoint publishes the replacement public key as soon as a replica reloads the key, but the replica keeps signing with the previous key until `config.push.signingKeyActivationDelay` plus the 30-second buffer passes. After activation, the previous public key stays in the JWKS until the five-minute tokens that it signed expire, plus 30 seconds of clock skew. -Restarting the controller loses key history. After a restart, the controller immediately signs with the key that is mounted in the pod and publishes only that key. +Without a previous key, a controller restart loses the key history. After the restart, the controller immediately signs with the key that is mounted in the pod, and publishes only that key. To keep the activation delay across restarts, rotate with a previous key, as described in [Rotate the push signing key](#rotate-the-push-signing-key). + +### Rotate the push signing key {#rotate-the-push-signing-key} + +To rotate the signing key, mount the new key as the current key and the old key as the previous key. This handoff keeps the activation delay across controller restarts. The controller reads the previous key only at startup. + +1. Generate a new signing key. + ```bash + openssl genpkey -algorithm ED25519 -out next-private-key.pem + ``` + +2. Store the key in a new Secret. The Secret must hold the key under the `private-key.pem` key. + ```bash + kubectl create secret generic kagent-push-signing-next -n kagent \ + --from-file=private-key.pem=next-private-key.pem + ``` + +3. In `kagent.yaml`, name both Secrets. + ```yaml + controller: + push: + signing: + secretName: kagent-push-signing-next + previousSecretName: kagent-push-signing + config: + push: + signingKeyActivationDelay: 300s + ``` + + | Setting | Description | + | ------- | ----------- | + | `controller.push.signing.secretName` | The Secret that contains the new key. | + | `controller.push.signing.previousSecretName` | The Secret that contains the key that is active before the rotation starts. | + | `config.push.signingKeyActivationDelay` | How long the new public key stays in the JWKS before the controller signs callbacks with the new private key. | + +4. Apply the values to the kagent release. + ```bash + helm upgrade kagent \ + {{< reuse "kagent-docs/snippets/helm-path.md" >}}/{{< reuse "kagent-docs/snippets/helm-kagent.md" >}} \ + --version {{< reuse "kagent-docs/versions/kagent.md" >}} \ + --namespace kagent \ + --reuse-values \ + --values kagent.yaml + ``` + +During the handoff, each controller replica keeps signing with the previous key until its own activation delay finishes. The JWKS endpoint continues to publish keys that any replica still needs to verify outstanding callbacks. After the current key is recorded as active, a restarted controller can start with the current key even if the previous key file is no longer mounted. + +For CSI or custom mounts that do not use Helm-managed Secrets, set `config.push.previousSigningPrivateKeyFile` to the old key path before you replace the current file. This field requires `config.push.signingPrivateKeyFile`, and a relative path resolves from the controller configuration file directory. If the previous file is missing before the current key is active, the controller fails to start. ## Tune push notification delivery