20
20
import io .strimzi .operator .cluster .model .KafkaVersion ;
21
21
import io .strimzi .operator .cluster .model .NodeRef ;
22
22
import io .strimzi .operator .cluster .operator .resource .ResourceOperatorSupplier ;
23
+ import io .strimzi .operator .common .Annotations ;
23
24
import io .strimzi .operator .common .Reconciliation ;
24
25
import io .strimzi .operator .common .ReconciliationLogger ;
25
26
import io .strimzi .operator .common .Util ;
26
27
import io .strimzi .operator .common .model .Ca ;
27
28
import io .strimzi .operator .common .model .Labels ;
29
+ import io .strimzi .operator .common .model .PasswordGenerator ;
28
30
import io .strimzi .operator .common .operator .resource .ConfigMapOperator ;
29
31
import io .strimzi .operator .common .operator .resource .DeploymentOperator ;
30
32
import io .strimzi .operator .common .operator .resource .NetworkPolicyOperator ;
40
42
import java .util .Map ;
41
43
import java .util .Set ;
42
44
43
-
44
45
/**
45
46
* Class used for reconciliation of Cruise Control. This class contains both the steps of the Cruise Control
46
47
* reconciliation pipeline and is also used to store the state between them.
@@ -63,18 +64,21 @@ public class CruiseControlReconciler {
63
64
private final ServiceOperator serviceOperator ;
64
65
private final NetworkPolicyOperator networkPolicyOperator ;
65
66
private final ConfigMapOperator configMapOperator ;
67
+ private final PasswordGenerator passwordGenerator ;
66
68
67
69
private boolean existingCertsChanged = false ;
68
70
69
71
private String serverConfigurationHash = "" ;
70
72
private String capacityConfigurationHash = "" ;
71
-
73
+ private String apiSecretHash = "" ;
74
+
72
75
/**
73
76
* Constructs the Cruise Control reconciler
74
77
*
75
78
* @param reconciliation Reconciliation marker
76
79
* @param config Cluster Operator Configuration
77
80
* @param supplier Supplier with Kubernetes Resource Operators
81
+ * @param passwordGenerator The password generator for API users
78
82
* @param kafkaAssembly The Kafka custom resource
79
83
* @param versions The supported Kafka versions
80
84
* @param kafkaBrokerNodes List of the broker nodes which are part of the Kafka cluster
@@ -87,6 +91,7 @@ public CruiseControlReconciler(
87
91
Reconciliation reconciliation ,
88
92
ClusterOperatorConfig config ,
89
93
ResourceOperatorSupplier supplier ,
94
+ PasswordGenerator passwordGenerator ,
90
95
Kafka kafkaAssembly ,
91
96
KafkaVersion .Lookup versions ,
92
97
Set <NodeRef > kafkaBrokerNodes ,
@@ -102,7 +107,8 @@ public CruiseControlReconciler(
102
107
this .operatorNamespace = config .getOperatorNamespace ();
103
108
this .operatorNamespaceLabels = config .getOperatorNamespaceLabels ();
104
109
this .isNetworkPolicyGeneration = config .isNetworkPolicyGeneration ();
105
-
110
+ this .passwordGenerator = passwordGenerator ;
111
+
106
112
this .deploymentOperator = supplier .deploymentOperations ;
107
113
this .secretOperator = supplier .secretOperations ;
108
114
this .serviceAccountOperator = supplier .serviceAccountOperations ;
@@ -240,15 +246,17 @@ protected Future<Void> apiSecret() {
240
246
if (cruiseControl != null ) {
241
247
return secretOperator .getAsync (reconciliation .namespace (), CruiseControlResources .apiSecretName (reconciliation .name ()))
242
248
.compose (oldSecret -> {
243
- Secret newSecret = cruiseControl .generateApiSecret ();
249
+ Secret newSecret = cruiseControl .generateApiSecret (passwordGenerator );
244
250
245
251
if (oldSecret != null ) {
246
252
// The credentials should not change with every release
247
253
// So if the secret with credentials already exists, we re-use the values
248
254
// But we use the new secret to update labels etc. if needed
249
255
newSecret .setData (oldSecret .getData ());
250
256
}
251
-
257
+
258
+ this .apiSecretHash = ReconcilerUtils .hashSecretContent (newSecret );
259
+
252
260
return secretOperator .reconcile (reconciliation , reconciliation .namespace (), CruiseControlResources .apiSecretName (reconciliation .name ()), newSecret )
253
261
.map ((Void ) null );
254
262
});
@@ -285,7 +293,8 @@ protected Future<Void> deployment(boolean isOpenShift, ImagePullPolicy imagePull
285
293
podAnnotations .put (Ca .ANNO_STRIMZI_IO_CLUSTER_CA_KEY_GENERATION , String .valueOf (clusterCa .caKeyGeneration ()));
286
294
podAnnotations .put (CruiseControl .ANNO_STRIMZI_SERVER_CONFIGURATION_HASH , serverConfigurationHash );
287
295
podAnnotations .put (CruiseControl .ANNO_STRIMZI_CAPACITY_CONFIGURATION_HASH , capacityConfigurationHash );
288
-
296
+ podAnnotations .put (Annotations .ANNO_STRIMZI_AUTH_HASH , apiSecretHash );
297
+
289
298
Deployment deployment = cruiseControl .generateDeployment (podAnnotations , isOpenShift , imagePullPolicy , imagePullSecrets );
290
299
291
300
return deploymentOperator
0 commit comments