You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2021/08/02 05:44:33 UTC
[GitHub] [cloudstack] shwstppr commented on a change in pull request #5254: kubernetes: Deploy kubernetes-provider when creating a cluster
shwstppr commented on a change in pull request #5254:
URL: https://github.com/apache/cloudstack/pull/5254#discussion_r680668376
##########
File path: plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterActionWorker.java
##########
@@ -380,4 +394,108 @@ protected boolean stateTransitTo(long kubernetesClusterId, KubernetesCluster.Eve
return false;
}
}
+
+ protected boolean createCloudStackSecret(String[] keys) {
+ File pkFile = getManagementServerSshPublicKeyFile();
+ Pair<String, Integer> publicIpSshPort = getKubernetesClusterServerIpSshPort(null);
+ publicIpAddress = publicIpSshPort.first();
+ sshPort = publicIpSshPort.second();
+
+ try {
+ Pair<Boolean, String> result = SshHelper.sshExecute(publicIpAddress, sshPort, CLUSTER_NODE_VM_USER,
+ pkFile, null, String.format("sudo /opt/bin/deploy-cloudstack-secret -u '%s' -k '%s' -s '%s'",
+ ApiServiceConfiguration.ApiServletPath.value(), keys[0], keys[1]),
+ 10000, 10000, 60000);
+ return result.first();
+ } catch (Exception e) {
+ String msg = String.format("Failed to add cloudstack-secret to Kubernetes cluster: %s", kubernetesCluster.getName());
+ LOGGER.warn(msg, e);
+ }
+ return false;
+ }
+
+ protected File retrieveScriptFile(String filename) {
+ File file = null;
+ try {
+ String data = readResourceFile("/script/" + filename);
+ file = File.createTempFile(filename, ".sh");
+ BufferedWriter writer = new BufferedWriter(new FileWriter(file));
+ writer.write(data);
+ writer.close();
+ } catch (IOException e) {
+ logAndThrow(Level.ERROR, String.format("Kubernetes Cluster %s : Failed to to fetch script %s",
+ kubernetesCluster.getName(), filename), e);
+ }
+ return file;
+ }
+
+ protected void retrieveScriptFiles() {
+ deploySecretsScriptFile = retrieveScriptFile(deploySecretsScriptFilename);
+ deployProviderScriptFile = retrieveScriptFile(deployProviderScriptFilename);
+ }
+
+ protected void copyScripts(String nodeAddress, final int sshPort) {
+ try {
+ SshHelper.scpTo(nodeAddress, sshPort, CLUSTER_NODE_VM_USER, sshKeyFile, null,
+ "~/", deploySecretsScriptFile.getAbsolutePath(), "0755");
+ SshHelper.scpTo(nodeAddress, sshPort, CLUSTER_NODE_VM_USER, sshKeyFile, null,
+ "~/", deployProviderScriptFile.getAbsolutePath(), "0755");
+ String cmdStr = String.format("sudo mv ~/%s /opt/bin/%s", deploySecretsScriptFile.getName(), deploySecretsScriptFilename);
+ SshHelper.sshExecute(publicIpAddress, sshPort, CLUSTER_NODE_VM_USER, sshKeyFile, null,
+ cmdStr, 10000, 10000, 10 * 60 * 1000);
+ cmdStr = String.format("sudo mv ~/%s /opt/bin/%s", deployProviderScriptFile.getName(), deployProviderScriptFilename);
+ SshHelper.sshExecute(publicIpAddress, sshPort, CLUSTER_NODE_VM_USER, sshKeyFile, null,
+ cmdStr, 10000, 10000, 10 * 60 * 1000);
+ } catch (Exception e) {
+ throw new CloudRuntimeException(e);
+ }
+ }
+
+ protected boolean deployProvider() {
+ Network network = networkDao.findById(kubernetesCluster.getNetworkId());
+ // Since the provider creates IP addresses, don't deploy it unless the underlying network supports it
+ if (network.getGuestType() != GuestType.Isolated) {
+ logMessage(Level.INFO, String.format("Skipping adding the provider as %s is not on an isoalted network",
Review comment:
```suggestion
logMessage(Level.INFO, String.format("Skipping adding the provider as %s is not on an isolated network",
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org