Skip to content

Commit 0be2cd5

Browse files
authored
Revert "Fix CKS HA clusters" (#120)
This reverts commit 8dac16a.
1 parent 05f357e commit 0be2cd5

File tree

3 files changed

+2
-24
lines changed

3 files changed

+2
-24
lines changed

plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterStartWorker.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,6 @@ private Pair<String, String> getKubernetesControlNodeConfig(final String control
161161
final String certSans = "{{ k8s_control.server_ips }}";
162162
final String k8sCertificate = "{{ k8s_control.certificate_key }}";
163163
final String externalCniPlugin = "{{ k8s.external.cni.plugin }}";
164-
final String isHaCluster = "{{ k8s.ha.cluster }}";
165-
final String publicIP = "{{ k8s.public.ip }}";
166164

167165
final List<String> addresses = new ArrayList<>();
168166
addresses.add(controlNodeIp);
@@ -204,7 +202,7 @@ private Pair<String, String> getKubernetesControlNodeConfig(final String control
204202
CLUSTER_API_PORT,
205203
KubernetesClusterUtil.generateClusterHACertificateKey(kubernetesCluster));
206204
}
207-
initArgs += String.format("--apiserver-cert-extra-sans=%s", String.join(",", addresses));
205+
initArgs += String.format("--apiserver-cert-extra-sans=%s", controlNodeIp);
208206
initArgs += String.format(" --kubernetes-version=%s", getKubernetesClusterVersion().getSemanticVersion());
209207
k8sControlNodeConfig = k8sControlNodeConfig.replace(clusterInitArgsKey, initArgs);
210208
k8sControlNodeConfig = k8sControlNodeConfig.replace(ejectIsoKey, String.valueOf(ejectIso));
@@ -214,8 +212,6 @@ private Pair<String, String> getKubernetesControlNodeConfig(final String control
214212
k8sControlNodeConfig = k8sControlNodeConfig.replace(certSans, String.format("- %s", serverIp));
215213
k8sControlNodeConfig = k8sControlNodeConfig.replace(k8sCertificate, KubernetesClusterUtil.generateClusterHACertificateKey(kubernetesCluster));
216214
k8sControlNodeConfig = k8sControlNodeConfig.replace(externalCniPlugin, String.valueOf(externalCni));
217-
k8sControlNodeConfig = k8sControlNodeConfig.replace(isHaCluster, String.valueOf(kubernetesCluster.getControlNodeCount() > 1));
218-
k8sControlNodeConfig = k8sControlNodeConfig.replace(publicIP, publicIpAddress);
219215

220216
k8sControlNodeConfig = updateKubeConfigWithRegistryDetails(k8sControlNodeConfig);
221217

@@ -313,8 +309,6 @@ private String getKubernetesAdditionalControlNodeConfig(final String joinIp, fin
313309
final String ejectIsoKey = "{{ k8s.eject.iso }}";
314310
final String installWaitTime = "{{ k8s.install.wait.time }}";
315311
final String installReattemptsCount = "{{ k8s.install.reattempts.count }}";
316-
final String isHaCluster = "{{ k8s.ha.cluster }}";
317-
final String publicIP = "{{ k8s.public.ip }}";
318312

319313
final Long waitTime = KubernetesClusterService.KubernetesControlNodeInstallAttemptWait.value();
320314
final Long reattempts = KubernetesClusterService.KubernetesControlNodeInstallReattempts.value();
@@ -334,8 +328,6 @@ private String getKubernetesAdditionalControlNodeConfig(final String joinIp, fin
334328
k8sControlNodeConfig = k8sControlNodeConfig.replace(clusterTokenKey, KubernetesClusterUtil.generateClusterToken(kubernetesCluster));
335329
k8sControlNodeConfig = k8sControlNodeConfig.replace(clusterHACertificateKey, KubernetesClusterUtil.generateClusterHACertificateKey(kubernetesCluster));
336330
k8sControlNodeConfig = k8sControlNodeConfig.replace(ejectIsoKey, String.valueOf(ejectIso));
337-
k8sControlNodeConfig = k8sControlNodeConfig.replace(isHaCluster, String.valueOf(kubernetesCluster.getControlNodeCount() > 1));
338-
k8sControlNodeConfig = k8sControlNodeConfig.replace(publicIP, publicIpAddress);
339331
k8sControlNodeConfig = updateKubeConfigWithRegistryDetails(k8sControlNodeConfig);
340332

341333
return k8sControlNodeConfig;
@@ -434,7 +426,7 @@ private UserVm createKubernetesAdditionalControlNode(final String joinIp, final
434426
String hostName = String.format("%s-control-%s", kubernetesClusterNodeNamePrefix, suffix);
435427
String k8sControlNodeConfig = null;
436428
try {
437-
k8sControlNodeConfig = getKubernetesAdditionalControlNodeConfig(publicIpAddress, Hypervisor.HypervisorType.VMware.equals(clusterTemplate.getHypervisorType()));
429+
k8sControlNodeConfig = getKubernetesAdditionalControlNodeConfig(joinIp, Hypervisor.HypervisorType.VMware.equals(clusterTemplate.getHypervisorType()));
438430
} catch (IOException e) {
439431
logAndThrow(Level.ERROR, "Failed to read Kubernetes control configuration file", e);
440432
}

plugins/integrations/kubernetes-service/src/main/resources/conf/k8s-control-node-add.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,6 @@ write_files:
225225
exit 0
226226
fi
227227
228-
HA_CLUSTER={{ k8s.ha.cluster }}
229-
CLUSTER_PUBLIC_IP={{ k8s.public.ip }}
230-
231228
if [[ $(systemctl is-active setup-kube-system) != "inactive" ]]; then
232229
echo "setup-kube-system is running!"
233230
exit 1
@@ -245,10 +242,6 @@ write_files:
245242
cp -i /etc/kubernetes/admin.conf /root/.kube/config
246243
chown $(id -u):$(id -g) /root/.kube/config
247244
248-
if [[ "$HA_CLUSTER" == "true" ]]; then
249-
sed -i -E "s|(server:\\s*).*|\\1https://${CLUSTER_PUBLIC_IP}:6443|" /root/.kube/config
250-
fi
251-
252245
sudo touch /home/cloud/success
253246
echo "true" > /home/cloud/success
254247

plugins/integrations/kubernetes-service/src/main/resources/conf/k8s-control-node.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,6 @@ write_files:
276276
exit 0
277277
fi
278278
279-
HA_CLUSTER={{ k8s.ha.cluster }}
280-
CLUSTER_PUBLIC_IP={{ k8s.public.ip }}
281-
282279
if [[ "$PATH" != *:/opt/bin && "$PATH" != *:/opt/bin:* ]]; then
283280
export PATH=$PATH:/opt/bin
284281
fi
@@ -323,10 +320,6 @@ write_files:
323320
chown $(id -u):$(id -g) /root/.kube/config
324321
echo export PATH=\$PATH:/opt/bin >> /root/.bashrc
325322
326-
if [[ "$HA_CLUSTER" == "true" ]]; then
327-
sed -i -E "s|(server:\\s*).*|\\1https://${CLUSTER_PUBLIC_IP}:6443|" /root/.kube/config
328-
fi
329-
330323
if [ -d "$K8S_CONFIG_SCRIPTS_COPY_DIR" ]; then
331324
### Network, dashboard configs available offline ###
332325
echo "Offline configs are available!"

0 commit comments

Comments
 (0)