@@ -161,6 +161,8 @@ private Pair<String, String> getKubernetesControlNodeConfig(final String control
161
161
final String certSans = "{{ k8s_control.server_ips }}" ;
162
162
final String k8sCertificate = "{{ k8s_control.certificate_key }}" ;
163
163
final String externalCniPlugin = "{{ k8s.external.cni.plugin }}" ;
164
+ final String isHaCluster = "{{ k8s.ha.cluster }}" ;
165
+ final String publicIP = "{{ k8s.public.ip }}" ;
164
166
165
167
final List <String > addresses = new ArrayList <>();
166
168
addresses .add (controlNodeIp );
@@ -202,7 +204,7 @@ private Pair<String, String> getKubernetesControlNodeConfig(final String control
202
204
CLUSTER_API_PORT ,
203
205
KubernetesClusterUtil .generateClusterHACertificateKey (kubernetesCluster ));
204
206
}
205
- initArgs += String .format ("--apiserver-cert-extra-sans=%s" , controlNodeIp );
207
+ initArgs += String .format ("--apiserver-cert-extra-sans=%s" , String . join ( "," , addresses ) );
206
208
initArgs += String .format (" --kubernetes-version=%s" , getKubernetesClusterVersion ().getSemanticVersion ());
207
209
k8sControlNodeConfig = k8sControlNodeConfig .replace (clusterInitArgsKey , initArgs );
208
210
k8sControlNodeConfig = k8sControlNodeConfig .replace (ejectIsoKey , String .valueOf (ejectIso ));
@@ -212,6 +214,8 @@ private Pair<String, String> getKubernetesControlNodeConfig(final String control
212
214
k8sControlNodeConfig = k8sControlNodeConfig .replace (certSans , String .format ("- %s" , serverIp ));
213
215
k8sControlNodeConfig = k8sControlNodeConfig .replace (k8sCertificate , KubernetesClusterUtil .generateClusterHACertificateKey (kubernetesCluster ));
214
216
k8sControlNodeConfig = k8sControlNodeConfig .replace (externalCniPlugin , String .valueOf (externalCni ));
217
+ k8sControlNodeConfig = k8sControlNodeConfig .replace (isHaCluster , String .valueOf (kubernetesCluster .getControlNodeCount () > 1 ));
218
+ k8sControlNodeConfig = k8sControlNodeConfig .replace (publicIP , publicIpAddress );
215
219
216
220
k8sControlNodeConfig = updateKubeConfigWithRegistryDetails (k8sControlNodeConfig );
217
221
@@ -309,6 +313,8 @@ private String getKubernetesAdditionalControlNodeConfig(final String joinIp, fin
309
313
final String ejectIsoKey = "{{ k8s.eject.iso }}" ;
310
314
final String installWaitTime = "{{ k8s.install.wait.time }}" ;
311
315
final String installReattemptsCount = "{{ k8s.install.reattempts.count }}" ;
316
+ final String isHaCluster = "{{ k8s.ha.cluster }}" ;
317
+ final String publicIP = "{{ k8s.public.ip }}" ;
312
318
313
319
final Long waitTime = KubernetesClusterService .KubernetesControlNodeInstallAttemptWait .value ();
314
320
final Long reattempts = KubernetesClusterService .KubernetesControlNodeInstallReattempts .value ();
@@ -328,6 +334,8 @@ private String getKubernetesAdditionalControlNodeConfig(final String joinIp, fin
328
334
k8sControlNodeConfig = k8sControlNodeConfig .replace (clusterTokenKey , KubernetesClusterUtil .generateClusterToken (kubernetesCluster ));
329
335
k8sControlNodeConfig = k8sControlNodeConfig .replace (clusterHACertificateKey , KubernetesClusterUtil .generateClusterHACertificateKey (kubernetesCluster ));
330
336
k8sControlNodeConfig = k8sControlNodeConfig .replace (ejectIsoKey , String .valueOf (ejectIso ));
337
+ k8sControlNodeConfig = k8sControlNodeConfig .replace (isHaCluster , String .valueOf (kubernetesCluster .getControlNodeCount () > 1 ));
338
+ k8sControlNodeConfig = k8sControlNodeConfig .replace (publicIP , publicIpAddress );
331
339
k8sControlNodeConfig = updateKubeConfigWithRegistryDetails (k8sControlNodeConfig );
332
340
333
341
return k8sControlNodeConfig ;
@@ -426,7 +434,7 @@ private UserVm createKubernetesAdditionalControlNode(final String joinIp, final
426
434
String hostName = String .format ("%s-control-%s" , kubernetesClusterNodeNamePrefix , suffix );
427
435
String k8sControlNodeConfig = null ;
428
436
try {
429
- k8sControlNodeConfig = getKubernetesAdditionalControlNodeConfig (joinIp , Hypervisor .HypervisorType .VMware .equals (clusterTemplate .getHypervisorType ()));
437
+ k8sControlNodeConfig = getKubernetesAdditionalControlNodeConfig (publicIpAddress , Hypervisor .HypervisorType .VMware .equals (clusterTemplate .getHypervisorType ()));
430
438
} catch (IOException e ) {
431
439
logAndThrow (Level .ERROR , "Failed to read Kubernetes control configuration file" , e );
432
440
}
0 commit comments