17.3. Certificate renewal and validity periods


Cluster CA and clients CA certificates are only valid for a limited time period, known as the validity period. This is usually defined as a number of days since the certificate was generated.

For CA certificates automatically created by the Cluster Operator, configure the validity period for certificates in the kafka resource using the following properties:

  • Kafka.spec.clusterCa.validityDays for Cluster CA certificates
  • Kafka.spec.clientsCa.validityDays for Clients CA certificates

The default validity period for both certificates is 365 days. Manually-installed CA certificates should have their own validity periods defined.

When a CA certificate expires, components and clients that still trust that certificate do not accept connections from peers whose certificates were signed by the CA private key. The components and clients need to trust the new CA certificate instead.

To allow the renewal of CA certificates without a loss of service, the Cluster Operator initiates certificate renewal before the old CA certificates expire.

Configure the renewal period of the certificates created by the Cluster Operator in the kafka resource using the following properties:

  • Kafka.spec.clusterCa.renewalDays for Cluster CA certificates
  • Kafka.spec.clientsCa.renewalDays for Clients CA certificates

The default renewal period for both certificates is 30 days.

The renewal period is measured backwards, from the expiry date of the current certificate.

Validity period against renewal period

Not Before                                     Not After
    |                                              |
    |<--------------- validityDays --------------->|
                              <--- renewalDays --->|

To schedule the renewal period at a convenient time, use maintenance time windows.

To make a change to the validity and renewal periods after creating the Kafka cluster, configure and apply the Kafka custom resource, and manually renew the CA certificates. If you do not manually renew the certificates, the new periods will be used the next time the certificate is renewed automatically.

Example Kafka configuration for certificate validity and renewal periods

apiVersion: kafka.strimzi.io/v1beta2
kind: Kafka
# ...
spec:
# ...
  clusterCa:
    renewalDays: 30
    validityDays: 365
    generateCertificateAuthority: true
  clientsCa:
    renewalDays: 30
    validityDays: 365
    generateCertificateAuthority: true
# ...

The behavior of the Cluster Operator during the renewal period depends on the settings for the generateCertificateAuthority certificate generation properties for the cluster CA and clients CA.

true
If the properties are set to true, a CA certificate is generated automatically by the Cluster Operator, and renewed automatically within the renewal period.
false
If the properties are set to false, a CA certificate is not generated by the Cluster Operator. Use this option if you are installing your own certificates.

17.3.1. Renewing automatically generated CA Certificates

When it’s time to renew CA certificates, the Cluster Operator follows these steps:

  1. Generates a new CA certificate, but retains the existing key.

    The new certificate replaces the old one with the name ca.crt within the corresponding Secret.

  2. Generates new client certificates (for ZooKeeper nodes, Kafka brokers, and the Entity Operator).

    This is not strictly necessary because the signing key has not changed, but it keeps the validity period of the client certificate in sync with the CA certificate.

  3. Restarts ZooKeeper nodes to trust the new CA certificate and use the new client certificates.
  4. Restarts Kafka brokers to trust the new CA certificate and use the new client certificates.
  5. Restarts the Topic Operator and User Operator to trust the new CA certificate and use the new client certificates.

    User certificates are signed by the clients CA. The User Operator handles renewing user certificates when the client’s CA is renewed.

17.3.2. Renewing client certificates

The Cluster Operator is not aware of the client applications using the Kafka cluster. You must ensure clients continue to work after certificate renewal. The renewal process depends on how the clients are configured.

When connecting to the cluster, and to ensure they operate correctly, client applications must include the following configuration:

  • Truststore credentials from the <cluster_name>-cluster-ca-cert secret to verify the identity of the Kafka cluster.
  • Keystore credentials from the <user_name> secret to connect to verify the user when connecting to the Kafka cluster.

The user secret provides credentials in PEM and PKCS #12 format, or it can provide a password when using SCRAM-SHA authentication. The User Operator creates the user credentials when a user is created. For an example of adding certificates to client configuration, see 「Securing user access to Kafka」.

If you are provisioning client certificates and keys manually, you must generate new client certificates and ensure the new certificates are used by clients within the renewal period. Failure to do this by the end of the renewal period could result in client applications being unable to connect to the cluster.

注記

For workloads running inside the same OpenShift cluster and namespace, secrets can be mounted as a volume so the client pods construct their keystores and truststores from the current state of the secrets. For more details on this procedure, see Configuring internal clients to trust the cluster CA.

17.3.3. Scheduling maintenance time windows

Schedule certificate renewal updates by the Cluster Operator to Kafka or ZooKeeper clusters for minimal impact on client applications. Use time windows in conjunction with the renewal periods of the CA certificates created by the Cluster Operator (Kafka.spec.clusterCa.renewalDays and Kafka.spec.clusterCa.renewalDays).

Updates are usually triggered by changes to the Kafka resource by the user or through user tooling. Rolling restarts for certificate expiration may occur without Kafka resource changes. While unscheduled restarts shouldn’t affect service availability, they could impact the performance of client applications. Maintenance time windows allow scheduling of these updates for convenient times.

Configure maintenance time windows as follows:

  • Configure an array of strings using the Kafka.spec.maintenanceTimeWindows property of the Kafka resource.
  • Each string is a cron expression interpreted as being in UTC (Coordinated Universal Time)

The following example configures a single maintenance time window that starts at midnight and ends at 01:59am (UTC), on Sundays, Mondays, Tuesdays, Wednesdays, and Thursdays.

Example maintenance time window configuration

apiVersion: kafka.strimzi.io/v1beta2
kind: Kafka
metadata:
  name: my-cluster
spec:
  kafka:
    #...
  maintenanceTimeWindows:
    - "* * 0-1 ? * SUN,MON,TUE,WED,THU *"
  #...

注記

The Cluster Operator doesn’t adhere strictly to the given time windows for maintenance operations. Maintenance operations are triggered by the first reconciliation that occurs within the specified time window. If the time window is shorter than the interval between reconciliations, there’s a risk that the reconciliation may happen outside of the time window, Therefore, maintenance time windows must be at least as long as the interval between reconciliations.

17.3.4. Manually renewing Cluster Operator-managed CA certificates

Cluster and clients CA certificates generated by the Cluster Operator auto-renew at the start of their respective certificate renewal periods. However, you can use the strimzi.io/force-renew annotation to manually renew one or both of these certificates before the certificate renewal period starts. You might do this for security reasons, or if you have changed the renewal or validity periods for the certificates.

A renewed certificate uses the same private key as the old certificate.

注記

If you are using your own CA certificates, the force-renew annotation cannot be used. Instead, follow the procedure for renewing your own CA certificates.

Prerequisites

  • The Cluster Operator must be deployed.
  • A Kafka cluster in which CA certificates and private keys are installed.
  • The OpenSSL TLS management tool to check the period of validity for CA certificates.

In this procedure, we use a Kafka cluster named my-cluster within the my-project namespace.

Procedure

  1. Apply the strimzi.io/force-renew annotation to the secret that contains the CA certificate that you want to renew.

    Renewing the Cluster CA secret

    oc annotate secret my-cluster-cluster-ca-cert -n my-project strimzi.io/force-renew="true"

    Renewing the Clients CA secret

    oc annotate secret my-cluster-clients-ca-cert -n my-project strimzi.io/force-renew="true"

  2. At the next reconciliation, the Cluster Operator generates new certificates.

    If maintenance time windows are configured, the Cluster Operator generates the new CA certificate at the first reconciliation within the next maintenance time window.

  3. Check the period of validity for the new CA certificates.

    Checking the period of validity for the new cluster CA certificate

    oc get secret my-cluster-cluster-ca-cert -n my-project -o=jsonpath='{.data.ca\.crt}' | base64 -d | openssl x509 -noout -dates

    Checking the period of validity for the new clients CA certificate

    oc get secret my-cluster-clients-ca-cert -n my-project -o=jsonpath='{.data.ca\.crt}' | base64 -d | openssl x509 -noout -dates

    The command returns a notBefore and notAfter date, which is the valid start and end date for the CA certificate.

  4. Update client configurations to trust the new cluster CA certificate.

    See:

17.3.5. Manually recovering from expired Cluster Operator-managed CA certificates

The Cluster Operator automatically renews the cluster and clients CA certificates when their renewal periods begin. Nevertheless, unexpected operational problems or disruptions may prevent the renewal process, such as prolonged downtime of the Cluster Operator or unavailability of the Kafka cluster. If CA certificates expire, Kafka cluster components cannot communicate with each other and the Cluster Operator cannot renew the CA certificates without manual intervention.

To promptly perform a recovery, follow the steps outlined in this procedure in the order given. You can recover from expired cluster and clients CA certificates. The process involves deleting the secrets containing the expired certificates so that new ones are generated by the Cluster Operator. For more information on the secrets managed in Streams for Apache Kafka, see 「Secrets generated by the Cluster Operator」.

注記

If you are using your own CA certificates and they expire, the process is similar, but you need to renew the CA certificates rather than use certificates generated by the Cluster Operator.

Prerequisites

  • The Cluster Operator must be deployed.
  • A Kafka cluster in which CA certificates and private keys are installed.
  • The OpenSSL TLS management tool to check the period of validity for CA certificates.

In this procedure, we use a Kafka cluster named my-cluster within the my-project namespace.

Procedure

  1. Delete the secret containing the expired CA certificate.

    Deleting the Cluster CA secret

    oc delete secret my-cluster-cluster-ca-cert -n my-project

    Deleting the Clients CA secret

    oc delete secret my-cluster-clients-ca-cert -n my-project

  2. Wait for the Cluster Operator to generate new certificates.

    • A new CA cluster certificate to verify the identity of the Kafka brokers is created in a secret of the same name (my-cluster-cluster-ca-cert).
    • A new CA clients certificate to verify the identity of Kafka users is created in a secret of the same name (my-cluster-clients-ca-cert).
  3. Check the period of validity for the new CA certificates.

    Checking the period of validity for the new cluster CA certificate

    oc get secret my-cluster-cluster-ca-cert -n my-project -o=jsonpath='{.data.ca\.crt}' | base64 -d | openssl x509 -noout -dates

    Checking the period of validity for the new clients CA certificate

    oc get secret my-cluster-clients-ca-cert -n my-project -o=jsonpath='{.data.ca\.crt}' | base64 -d | openssl x509 -noout -dates

    The command returns a notBefore and notAfter date, which is the valid start and end date for the CA certificate.

  4. Delete the component pods and secrets that use the CA certificates.

    1. Delete the ZooKeeper secret.
    2. Wait for the Cluster Operator to detect the missing ZooKeeper secret and recreate it.
    3. Delete all ZooKeeper pods.
    4. Delete the Kafka secret.
    5. Wait for the Cluster Operator to detect the missing Kafka secret and recreate it.
    6. Delete all Kafka pods.

    If you are only recovering the clients CA certificate, you only need to delete the Kafka secret and pods.

    You can use the following oc command to find resources and also verify that they have been removed.

    oc get <resource_type> --all-namespaces | grep <kafka_cluster_name>

    Replace <resource_type> with the type of the resource, such as Pod or Secret.

  5. Wait for the Cluster Operator to detect the missing Kafka and ZooKeeper pods and recreate them with the updated CA certificates.

    On reconciliation, the Cluster Operator automatically updates other components to trust the new CA certificates.

  6. Verify that there are no issues related to certificate validation in the Cluster Operator log.
  7. Update client configurations to trust the new cluster CA certificate.

    See:

17.3.6. Replacing private keys used by Cluster Operator-managed CA certificates

You can replace the private keys used by the cluster CA and clients CA certificates generated by the Cluster Operator. When a private key is replaced, the Cluster Operator generates a new CA certificate for the new private key.

注記

If you are using your own CA certificates, the force-replace annotation cannot be used. Instead, follow the procedure for renewing your own CA certificates.

Prerequisites

  • The Cluster Operator is running.
  • A Kafka cluster in which CA certificates and private keys are installed.

Procedure

  • Apply the strimzi.io/force-replace annotation to the Secret that contains the private key that you want to renew.

    表17.13 Commands for replacing private keys
    Private key forSecretAnnotate command

    Cluster CA

    <cluster_name>-cluster-ca

    oc annotate secret <cluster_name>-cluster-ca strimzi.io/force-replace="true"

    Clients CA

    <cluster_name>-clients-ca

    oc annotate secret <cluster_name>-clients-ca strimzi.io/force-replace="true"

At the next reconciliation the Cluster Operator will:

  • Generate a new private key for the Secret that you annotated
  • Generate a new CA certificate

If maintenance time windows are configured, the Cluster Operator will generate the new private key and CA certificate at the first reconciliation within the next maintenance time window.

Client applications must reload the cluster and clients CA certificates that were renewed by the Cluster Operator.

Red Hat logoGithubRedditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

Red Hat ドキュメントについて

Legal Notice

Theme

© 2026 Red Hat
トップに戻る