use of io.strimzi.certs.CertAndKey in project strimzi by strimzi.
the class KafkaCluster method generateBrokersSecret.
/**
* Generate the Secret containing the Kafka brokers certificates signed by the cluster CA certificate used for TLS based
* internal communication with Zookeeper.
* It also contains the related Kafka brokers private keys.
*
* @param clusterCa The CA for cluster certificates
* @param clientsCa The CA for clients certificates
* @return The generated Secret
*/
public Secret generateBrokersSecret(ClusterCa clusterCa, ClientsCa clientsCa) {
Map<String, String> data = new HashMap<>(replicas * 4);
for (int i = 0; i < replicas; i++) {
CertAndKey cert = brokerCerts.get(KafkaCluster.kafkaPodName(cluster, i));
data.put(KafkaCluster.kafkaPodName(cluster, i) + ".key", cert.keyAsBase64String());
data.put(KafkaCluster.kafkaPodName(cluster, i) + ".crt", cert.certAsBase64String());
data.put(KafkaCluster.kafkaPodName(cluster, i) + ".p12", cert.keyStoreAsBase64String());
data.put(KafkaCluster.kafkaPodName(cluster, i) + ".password", cert.storePasswordAsBase64String());
}
Map<String, String> annotations = Map.of(clusterCa.caCertGenerationAnnotation(), String.valueOf(clusterCa.certGeneration()), clientsCa.caCertGenerationAnnotation(), String.valueOf(clientsCa.certGeneration()));
return createSecret(KafkaCluster.brokersSecretName(cluster), data, annotations);
}
Aggregations