shwstppr commented on a change in pull request #5254:
URL: https://github.com/apache/cloudstack/pull/5254#discussion_r679788290



##########
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("Failed to upgrade 
Kubernetes cluster %s, unable to prepare upgrade 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) {
+            return true;

Review comment:
       better to add a log here that provider deployment skipped for networks 
other than Isolated




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to