use of io.strimzi.operator.cluster.operator.resource.ZooKeeperRoller in project strimzi by strimzi.
the class CaReconciler method rollingUpdateForNewCaKey.
/**
* Perform a rolling update of the cluster so that CA certificates get added to their truststores, or expired CA
* certificates get removed from their truststores. Note this is only necessary when the CA certificate has changed
* due to a new CA key. It is not necessary when the CA certificate is replace while retaining the existing key.
*/
Future<Void> rollingUpdateForNewCaKey() {
List<String> reason = new ArrayList<>(2);
if (clusterCa.keyReplaced()) {
reason.add("trust new cluster CA certificate signed by new key");
}
if (clientsCa.keyReplaced()) {
reason.add("trust new clients CA certificate signed by new key");
}
if (!reason.isEmpty()) {
Future<Void> zkRollFuture;
Function<Pod, List<String>> rollPodAndLogReason = pod -> {
LOGGER.debugCr(reconciliation, "Rolling Pod {} to {}", pod.getMetadata().getName(), reason);
return reason;
};
if (clusterCa.keyReplaced()) {
// ZooKeeper is rolled only for new Cluster CA key
Labels zkSelectorLabels = Labels.EMPTY.withStrimziKind(reconciliation.kind()).withStrimziCluster(reconciliation.name()).withStrimziName(KafkaResources.zookeeperStatefulSetName(reconciliation.name()));
zkRollFuture = new ZooKeeperRoller(podOperator, zookeeperLeaderFinder, operationTimeoutMs).maybeRollingUpdate(reconciliation, zkSelectorLabels, rollPodAndLogReason, clusterCa.caCertSecret(), oldCoSecret);
} else {
zkRollFuture = Future.succeededFuture();
}
return zkRollFuture.compose(i -> {
if (featureGates.useStrimziPodSetsEnabled()) {
return strimziPodSetOperator.getAsync(reconciliation.namespace(), KafkaResources.kafkaStatefulSetName(reconciliation.name())).compose(podSet -> {
if (podSet != null) {
return Future.succeededFuture(KafkaCluster.generatePodList(reconciliation.name(), podSet.getSpec().getPods().size()));
} else {
return Future.succeededFuture(List.<String>of());
}
});
} else {
return stsOperator.getAsync(reconciliation.namespace(), KafkaResources.kafkaStatefulSetName(reconciliation.name())).compose(sts -> {
if (sts != null) {
return Future.succeededFuture(KafkaCluster.generatePodList(reconciliation.name(), sts.getSpec().getReplicas()));
} else {
return Future.succeededFuture(List.<String>of());
}
});
}
}).compose(replicas -> new KafkaRoller(reconciliation, vertx, podOperator, 1_000, operationTimeoutMs, () -> new BackOff(250, 2, 10), replicas, clusterCa.caCertSecret(), oldCoSecret, adminClientProvider, brokerId -> null, null, null, false).rollingRestart(rollPodAndLogReason)).compose(i -> {
if (clusterCa.keyReplaced()) {
// EO, KE and CC need to be rolled only for new Cluster CA key.
return rollDeploymentIfExists(KafkaResources.entityOperatorDeploymentName(reconciliation.name()), reason.toString()).compose(i2 -> rollDeploymentIfExists(KafkaExporterResources.deploymentName(reconciliation.name()), reason.toString())).compose(i2 -> rollDeploymentIfExists(CruiseControlResources.deploymentName(reconciliation.name()), reason.toString()));
} else {
return Future.succeededFuture();
}
});
} else {
return Future.succeededFuture();
}
}
use of io.strimzi.operator.cluster.operator.resource.ZooKeeperRoller in project strimzi-kafka-operator by strimzi.
the class CaReconciler method rollingUpdateForNewCaKey.
/**
* Perform a rolling update of the cluster so that CA certificates get added to their truststores, or expired CA
* certificates get removed from their truststores. Note this is only necessary when the CA certificate has changed
* due to a new CA key. It is not necessary when the CA certificate is replace while retaining the existing key.
*/
Future<Void> rollingUpdateForNewCaKey() {
List<String> reason = new ArrayList<>(2);
if (clusterCa.keyReplaced()) {
reason.add("trust new cluster CA certificate signed by new key");
}
if (clientsCa.keyReplaced()) {
reason.add("trust new clients CA certificate signed by new key");
}
if (!reason.isEmpty()) {
Future<Void> zkRollFuture;
Function<Pod, List<String>> rollPodAndLogReason = pod -> {
LOGGER.debugCr(reconciliation, "Rolling Pod {} to {}", pod.getMetadata().getName(), reason);
return reason;
};
if (clusterCa.keyReplaced()) {
// ZooKeeper is rolled only for new Cluster CA key
Labels zkSelectorLabels = Labels.EMPTY.withStrimziKind(reconciliation.kind()).withStrimziCluster(reconciliation.name()).withStrimziName(KafkaResources.zookeeperStatefulSetName(reconciliation.name()));
zkRollFuture = new ZooKeeperRoller(podOperator, zookeeperLeaderFinder, operationTimeoutMs).maybeRollingUpdate(reconciliation, zkSelectorLabels, rollPodAndLogReason, clusterCa.caCertSecret(), oldCoSecret);
} else {
zkRollFuture = Future.succeededFuture();
}
return zkRollFuture.compose(i -> {
if (featureGates.useStrimziPodSetsEnabled()) {
return strimziPodSetOperator.getAsync(reconciliation.namespace(), KafkaResources.kafkaStatefulSetName(reconciliation.name())).compose(podSet -> {
if (podSet != null) {
return Future.succeededFuture(KafkaCluster.generatePodList(reconciliation.name(), podSet.getSpec().getPods().size()));
} else {
return Future.succeededFuture(List.<String>of());
}
});
} else {
return stsOperator.getAsync(reconciliation.namespace(), KafkaResources.kafkaStatefulSetName(reconciliation.name())).compose(sts -> {
if (sts != null) {
return Future.succeededFuture(KafkaCluster.generatePodList(reconciliation.name(), sts.getSpec().getReplicas()));
} else {
return Future.succeededFuture(List.<String>of());
}
});
}
}).compose(replicas -> new KafkaRoller(reconciliation, vertx, podOperator, 1_000, operationTimeoutMs, () -> new BackOff(250, 2, 10), replicas, clusterCa.caCertSecret(), oldCoSecret, adminClientProvider, brokerId -> null, null, null, false).rollingRestart(rollPodAndLogReason)).compose(i -> {
if (clusterCa.keyReplaced()) {
// EO, KE and CC need to be rolled only for new Cluster CA key.
return rollDeploymentIfExists(KafkaResources.entityOperatorDeploymentName(reconciliation.name()), reason.toString()).compose(i2 -> rollDeploymentIfExists(KafkaExporterResources.deploymentName(reconciliation.name()), reason.toString())).compose(i2 -> rollDeploymentIfExists(CruiseControlResources.deploymentName(reconciliation.name()), reason.toString()));
} else {
return Future.succeededFuture();
}
});
} else {
return Future.succeededFuture();
}
}
Aggregations