You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by "vishesh92 (via GitHub)" <gi...@apache.org> on 2023/06/07 09:41:04 UTC

[GitHub] [cloudstack] vishesh92 opened a new pull request, #7515: Feature: Add unmanaged kubernetes cluster

vishesh92 opened a new pull request, #7515:
URL: https://github.com/apache/cloudstack/pull/7515

   ### Description
   
   There are tools like cluster-api which create and manage kubernetes cluster on CloudStack. This PR adds the option to add *unmanaged* kubernetes cluster which are not managed by CKS plugin. This helps provide a consolidated view of unmanaged clusters on CloudStack. The changes done make sure that operations for managed clusters are not executed for unmanaged clusters.
   
   Two new APIs have also been added:
   1. `addVirtualMachinesToKubernetesCluster` - to add VMs to unmanaged clusters.
   2.  `removeVirtualMachinesFromKubernetesCluster` - to remove VMs to unmanaged clusters.
   
   Two APIs have been updated:
   1. `createKubernetesCluster` - made `KUBERNETES_VERSION_ID`, `SERVICE_OFFERING_ID`, `SIZE` as not required for unmanaged clusters. Add an additional parameter, `managed`, which is true by default.
   2. `listKubernetesClusters` - Add a parameter `managed` to filter on `managed` field.
   3. 
   <!--- Describe your changes in DETAIL - And how has behaviour functionally changed. -->
   
   <!-- For new features, provide link to FS, dev ML discussion etc. -->
   <!-- In case of bug fix, the expected and actual behaviours, steps to reproduce. -->
   
   <!-- When "Fixes: #<id>" is specified, the issue/PR will automatically be closed when this PR gets merged -->
   <!-- For addressing multiple issues/PRs, use multiple "Fixes: #<id>" -->
   <!-- Fixes: # -->
   
   <!--- ********************************************************************************* -->
   <!--- NOTE: AUTOMATATION USES THE DESCRIPTIONS TO SET LABELS AND PRODUCE DOCUMENTATION. -->
   <!--- PLEASE PUT AN 'X' in only **ONE** box -->
   <!--- ********************************************************************************* -->
   
   ### Types of changes
   
   - [ ] Breaking change (fix or feature that would cause existing functionality to change)
   - [x] New feature (non-breaking change which adds functionality)
   - [ ] Bug fix (non-breaking change which fixes an issue)
   - [ ] Enhancement (improves an existing feature and functionality)
   - [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
   
   ### Feature/Enhancement Scale or Bug Severity
   
   #### Feature/Enhancement Scale
   
   - [ ] Major
   - [x] Minor
   
   #### Bug Severity
   
   - [ ] BLOCKER
   - [ ] Critical
   - [ ] Major
   - [ ] Minor
   - [ ] Trivial
   
   
   ### Screenshots (if appropriate):
   
   
   ### How Has This Been Tested?
   <!-- Please describe in detail how you tested your changes. -->
   <!-- Include details of your testing environment, and the tests you ran to -->
   <!-- see how your change affects other areas of the code, etc. -->
   Test locally by creating a kubernetes cluster using https://github.com/kubernetes-sigs/cluster-api-provider-cloudstack.
   
   <!-- Please read the [CONTRIBUTING](https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md) document -->
   


-- 
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


[GitHub] [cloudstack] weizhouapache commented on a diff in pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "weizhouapache (via GitHub)" <gi...@apache.org>.
weizhouapache commented on code in PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#discussion_r1205223919


##########
engine/schema/src/main/resources/META-INF/db/schema-41810to41900.sql:
##########
@@ -135,3 +135,7 @@ CREATE VIEW `cloud`.`async_job_view` AS
 UPDATE `cloud`.`console_session` SET removed=now();
 -- Modify acquired column in console_session to datetime type
 ALTER TABLE `cloud`.`console_session` DROP `acquired`, ADD `acquired` datetime COMMENT 'When the session was acquired' AFTER `host_id`;
+
+ALTER TABLE `cloud`.`kubernetes_cluster` ADD COLUMN is_managed tinyint(1) DEFAULT 1;
+
+ALTER TABLE `cloud`.`kubernetes_cluster` MODIFY COLUMN `kubernetes_version_id` bigint unsigned NULL;

Review Comment:
   the field has a comment before, will the comment be removed after modification ?
   ```
     `kubernetes_version_id` bigint unsigned NOT NULL COMMENT 'the ID of the Kubernetes version of this Kubernetes cluster',
   ```



##########
engine/schema/src/main/resources/META-INF/db/schema-41810to41900.sql:
##########
@@ -135,3 +135,7 @@ CREATE VIEW `cloud`.`async_job_view` AS
 UPDATE `cloud`.`console_session` SET removed=now();
 -- Modify acquired column in console_session to datetime type
 ALTER TABLE `cloud`.`console_session` DROP `acquired`, ADD `acquired` datetime COMMENT 'When the session was acquired' AFTER `host_id`;
+
+ALTER TABLE `cloud`.`kubernetes_cluster` ADD COLUMN is_managed tinyint(1) DEFAULT 1;

Review Comment:
   add a comment to the new column ?



##########
plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/command/user/kubernetes/cluster/RemoveVirtualMachinesFromKubernetesClusterCmd.java:
##########
@@ -0,0 +1,99 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.kubernetes.cluster;
+
+import com.cloud.kubernetes.cluster.KubernetesClusterService;
+import com.cloud.utils.exception.CloudRuntimeException;
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.KubernetesClusterResponse;
+import org.apache.cloudstack.api.response.SuccessResponse;
+import org.apache.cloudstack.api.response.UserVmResponse;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
+
+import javax.inject.Inject;
+import java.util.List;
+
+@APICommand(name = "removeVirtualMachinesFromKubernetesCluster",
+        description = "Remove VMs from a kubernetes cluster",
+        responseObject = SuccessResponse.class,
+        since = "4.19.0",
+        authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
+public class RemoveVirtualMachinesFromKubernetesClusterCmd extends BaseCmd {
+    public static final Logger LOGGER = Logger.getLogger(RemoveVirtualMachinesFromKubernetesClusterCmd.class.getName());
+
+    @Inject
+    public KubernetesClusterService kubernetesClusterService;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name = ApiConstants.ID, type = CommandType.UUID,
+            entityType = KubernetesClusterResponse.class,
+            required = true,
+            description = "the ID of the Kubernetes cluster")
+    private Long id;
+
+    @Parameter(name = ApiConstants.VIRTUAL_MACHINE_IDS, type = CommandType.LIST,
+            collectionType=CommandType.UUID,
+            entityType = UserVmResponse.class,
+            required = true,
+            description = "the IDs of the VMs to remove from the cluster")
+    private List<Long> vmIds;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    public List<Long> getVmIds() {
+        return vmIds;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public long getEntityOwnerId() {
+        return CallContext.current().getCallingAccount().getId();
+    }
+
+    @Override
+    public void execute() throws ServerApiException {
+        try {
+            if (!kubernetesClusterService.removeVmsFromCluster(this)) {
+                throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add VM to cluster");

Review Comment:
   ```suggestion
                   throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to remove VMs from cluster");
   ```
   



##########
plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java:
##########
@@ -783,15 +843,16 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
                 List<KubernetesClusterDetailsVO> details = new ArrayList<>();
                 long kubernetesClusterId = kubernetesCluster.getId();
 
-                if (Network.GuestType.Shared.equals(network.getGuestType())) {
+                if ((network != null && Network.GuestType.Shared.equals(network.getGuestType())) || !cmd.isManaged()) {

Review Comment:
   is the condition `!cmd.isManaged()` needed ?



##########
plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/command/user/kubernetes/cluster/AddVirtualMachinesToKubernetesClusterCmd.java:
##########
@@ -0,0 +1,106 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.kubernetes.cluster;
+
+import com.cloud.kubernetes.cluster.KubernetesClusterService;
+import com.cloud.utils.exception.CloudRuntimeException;
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.KubernetesClusterResponse;
+import org.apache.cloudstack.api.response.SuccessResponse;
+import org.apache.cloudstack.api.response.UserVmResponse;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
+
+import javax.inject.Inject;
+import java.util.List;
+
+@APICommand(name = "addVirtualMachinesToKubernetesCluster",
+        description = "Add VM to a kubernetes cluster",

Review Comment:
   ```suggestion
           description = "Add VMs to a kubernetes cluster",
   ```



-- 
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


[GitHub] [cloudstack] weizhouapache commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "weizhouapache (via GitHub)" <gi...@apache.org>.
weizhouapache commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1562532598

   @blueorangutan package


-- 
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


[GitHub] [cloudstack] DaanHoogland commented on a diff in pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on code in PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#discussion_r1221148995


##########
test/integration/smoke/test_kubernetes_clusters.py:
##########
@@ -622,11 +704,10 @@ def createKubernetesCluster(self, name, version_id, size=1, control_nodes=1):
         createKubernetesClusterCmd.noderootdisksize = 10
         createKubernetesClusterCmd.account = self.account.name
         createKubernetesClusterCmd.domainid = self.domain.id
+        createKubernetesClusterCmd.clustertype = cluster_type
         if self.default_network:
             createKubernetesClusterCmd.networkid = self.default_network.id
         clusterResponse = self.apiclient.createKubernetesCluster(createKubernetesClusterCmd)
-        if not clusterResponse:
-            self.cleanup.append(clusterResponse)

Review Comment:
   if we remove this here , we need to add it in the calling method(s). Alternative to muy suggestion (https://github.com/apache/cloudstack/pull/7515/files#r1217636578) we can validate the response here and on success add the cluster to self.cleanup here.



-- 
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


[GitHub] [cloudstack] vishesh92 commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1572751322

   @blueorangutan test


-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1576064147

   @vishesh92 [SF] I understand these words: "help", "hello", "thanks", "SFpackage", "test"
   Test command usage: test [mgmt os] [hypervisor] [keepEnv] [qemuEv]
   Mgmt OS options: ['centos7', 'centos6', 'suse15', 'alma8', 'ubuntu18', 'ubuntu22', 'ubuntu20', 'rocky8', 'alma9']
   Hypervisor options: ['kvm-centos6', 'kvm-centos7', 'kvm-rocky8', 'kvm-alma8', 'kvm-alma9', 'kvm-ubuntu18', 'kvm-ubuntu20', 'kvm-ubuntu22', 'kvm-suse15', 'vmware-55u3', 'vmware-60u2', 'vmware-65u2', 'vmware-67u3', 'vmware-70u1', 'vmware-70u2', 'vmware-70u3', 'vmware-80', 'vmware-80u1', 'xenserver-65sp1', 'xenserver-71', 'xenserver-74', 'xcpng74', 'xcpng76', 'xcpng80', 'xcpng81', 'xcpng82']
   	Note: when keepEnv is passed, you need to specify mgmt server os and hypervisor or use the `matrix` command.
   	when qemuEv is passed, it will deploy KVM hyperviosr hosts with qemu-kvm-ev, else it will default to stock qemu.
   Package command usage: package [all(default value),kvm,xen,vmware,hyperv,ovm] - a comma separated list can be passed with package command to bundle the required hypervisor's systemVM templates. Not passing any argument will bundle all - kvm,xen and vmware templates.
   
   Blessed contributors for kicking Trillian test jobs: ['rohityadavcloud', 'shwstppr', 'vishesh92', 'harikrishna-patnala', 'nvazquez', 'DaanHoogland', 'weizhouapache', 'kishankavala', 'borisstoyanov', 'vladimirpetrov', 'kiranchavala', 'andrijapanicsb', 'NuxRo', 'rajujith', 'alexandremattioli', 'mlsorensen', 'oscaralvaro']


-- 
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


[GitHub] [cloudstack] codecov[bot] commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1543559202

   ## [Codecov](https://app.codecov.io/gh/apache/cloudstack/pull/7515?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#7515](https://app.codecov.io/gh/apache/cloudstack/pull/7515?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (544e04e) into [main](https://app.codecov.io/gh/apache/cloudstack/commit/b280370a983aca2fa5c065960c25786e9b40341b?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b280370) will **increase** coverage by `0.22%`.
   > The diff coverage is `0.00%`.
   
   ```diff
   @@             Coverage Diff              @@
   ##               main    #7515      +/-   ##
   ============================================
   + Coverage     12.72%   12.94%   +0.22%     
   - Complexity     8706     8986     +280     
   ============================================
     Files          2727     2729       +2     
     Lines        256526   256821     +295     
     Branches      39989    40061      +72     
   ============================================
   + Hits          32636    33258     +622     
   + Misses       219738   219383     -355     
   - Partials       4152     4180      +28     
   ```
   
   
   | [Impacted Files](https://app.codecov.io/gh/apache/cloudstack/pull/7515?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...om/cloud/kubernetes/cluster/KubernetesCluster.java](https://app.codecov.io/gh/apache/cloudstack/pull/7515?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGx1Z2lucy9pbnRlZ3JhdGlvbnMva3ViZXJuZXRlcy1zZXJ2aWNlL3NyYy9tYWluL2phdmEvY29tL2Nsb3VkL2t1YmVybmV0ZXMvY2x1c3Rlci9LdWJlcm5ldGVzQ2x1c3Rlci5qYXZh) | `0.00% <ø> (ø)` | |
   | [...bernetes/cluster/KubernetesClusterManagerImpl.java](https://app.codecov.io/gh/apache/cloudstack/pull/7515?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGx1Z2lucy9pbnRlZ3JhdGlvbnMva3ViZXJuZXRlcy1zZXJ2aWNlL3NyYy9tYWluL2phdmEvY29tL2Nsb3VkL2t1YmVybmV0ZXMvY2x1c3Rlci9LdWJlcm5ldGVzQ2x1c3Rlck1hbmFnZXJJbXBsLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...d/kubernetes/cluster/KubernetesClusterService.java](https://app.codecov.io/gh/apache/cloudstack/pull/7515?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGx1Z2lucy9pbnRlZ3JhdGlvbnMva3ViZXJuZXRlcy1zZXJ2aWNlL3NyYy9tYWluL2phdmEvY29tL2Nsb3VkL2t1YmVybmV0ZXMvY2x1c3Rlci9LdWJlcm5ldGVzQ2x1c3RlclNlcnZpY2UuamF2YQ==) | `100.00% <ø> (ø)` | |
   | [.../cloud/kubernetes/cluster/KubernetesClusterVO.java](https://app.codecov.io/gh/apache/cloudstack/pull/7515?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGx1Z2lucy9pbnRlZ3JhdGlvbnMva3ViZXJuZXRlcy1zZXJ2aWNlL3NyYy9tYWluL2phdmEvY29tL2Nsb3VkL2t1YmVybmV0ZXMvY2x1c3Rlci9LdWJlcm5ldGVzQ2x1c3RlclZPLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...bernetes/cluster/dao/KubernetesClusterDaoImpl.java](https://app.codecov.io/gh/apache/cloudstack/pull/7515?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGx1Z2lucy9pbnRlZ3JhdGlvbnMva3ViZXJuZXRlcy1zZXJ2aWNlL3NyYy9tYWluL2phdmEvY29tL2Nsb3VkL2t1YmVybmV0ZXMvY2x1c3Rlci9kYW8vS3ViZXJuZXRlc0NsdXN0ZXJEYW9JbXBsLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...bernetes/cluster/AddVmsToKubernetesClusterCmd.java](https://app.codecov.io/gh/apache/cloudstack/pull/7515?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGx1Z2lucy9pbnRlZ3JhdGlvbnMva3ViZXJuZXRlcy1zZXJ2aWNlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9jbG91ZHN0YWNrL2FwaS9jb21tYW5kL3VzZXIva3ViZXJuZXRlcy9jbHVzdGVyL0FkZFZtc1RvS3ViZXJuZXRlc0NsdXN0ZXJDbWQuamF2YQ==) | `0.00% <0.00%> (ø)` | |
   | [...kubernetes/cluster/CreateKubernetesClusterCmd.java](https://app.codecov.io/gh/apache/cloudstack/pull/7515?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGx1Z2lucy9pbnRlZ3JhdGlvbnMva3ViZXJuZXRlcy1zZXJ2aWNlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9jbG91ZHN0YWNrL2FwaS9jb21tYW5kL3VzZXIva3ViZXJuZXRlcy9jbHVzdGVyL0NyZWF0ZUt1YmVybmV0ZXNDbHVzdGVyQ21kLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [.../kubernetes/cluster/ListKubernetesClustersCmd.java](https://app.codecov.io/gh/apache/cloudstack/pull/7515?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGx1Z2lucy9pbnRlZ3JhdGlvbnMva3ViZXJuZXRlcy1zZXJ2aWNlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9jbG91ZHN0YWNrL2FwaS9jb21tYW5kL3VzZXIva3ViZXJuZXRlcy9jbHVzdGVyL0xpc3RLdWJlcm5ldGVzQ2x1c3RlcnNDbWQuamF2YQ==) | `0.00% <0.00%> (ø)` | |
   | [...tes/cluster/RemoveVmsFromKubernetesClusterCmd.java](https://app.codecov.io/gh/apache/cloudstack/pull/7515?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGx1Z2lucy9pbnRlZ3JhdGlvbnMva3ViZXJuZXRlcy1zZXJ2aWNlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9jbG91ZHN0YWNrL2FwaS9jb21tYW5kL3VzZXIva3ViZXJuZXRlcy9jbHVzdGVyL1JlbW92ZVZtc0Zyb21LdWJlcm5ldGVzQ2x1c3RlckNtZC5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [.../kubernetes/cluster/StartKubernetesClusterCmd.java](https://app.codecov.io/gh/apache/cloudstack/pull/7515?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGx1Z2lucy9pbnRlZ3JhdGlvbnMva3ViZXJuZXRlcy1zZXJ2aWNlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9jbG91ZHN0YWNrL2FwaS9jb21tYW5kL3VzZXIva3ViZXJuZXRlcy9jbHVzdGVyL1N0YXJ0S3ViZXJuZXRlc0NsdXN0ZXJDbWQuamF2YQ==) | `0.00% <0.00%> (ø)` | |
   
   ... and [109 files with indirect coverage changes](https://app.codecov.io/gh/apache/cloudstack/pull/7515/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


-- 
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


[GitHub] [cloudstack] vishesh92 commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1545183748

   @Pearl1594 Thanks for reviewing my PR.  I have resolved some of your comments & replied to some.


-- 
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


[GitHub] [cloudstack] Pearl1594 commented on a diff in pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "Pearl1594 (via GitHub)" <gi...@apache.org>.
Pearl1594 commented on code in PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#discussion_r1192355352


##########
plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java:
##########
@@ -600,8 +609,66 @@ private void validateEndpointUrl() {
             throw new InvalidParameterValueException(error);
         }
     }
+    private void validateUnmanagedKubernetesClusterCreateParameters(final CreateKubernetesClusterCmd cmd) throws CloudRuntimeException {
+        final String name = cmd.getName();
+        final Long zoneId = cmd.getZoneId();
+        final Account owner = accountService.getActiveAccountById(cmd.getEntityOwnerId());
+        final Long networkId = cmd.getNetworkId();
+        final String sshKeyPair = cmd.getSSHKeyPairName();
+        final String dockerRegistryUserName = cmd.getDockerRegistryUserName();
+        final String dockerRegistryPassword = cmd.getDockerRegistryPassword();
+        final String dockerRegistryUrl = cmd.getDockerRegistryUrl();
+        final Long nodeRootDiskSize = cmd.getNodeRootDiskSize();
+        final String externalLoadBalancerIpAddress = cmd.getExternalLoadBalancerIpAddress();
+
+        if (name == null || name.isEmpty()) {
+            throw new InvalidParameterValueException("Invalid name for the Kubernetes cluster name:" + name);

Review Comment:
   This comment can be ignored.. I just thought that this log statement would read something like `Invalid name for Kubernetes cluster name: null` and the same could be simply conveyed with a missing k8s cluster name statement... but this can be ignored thanks.



-- 
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


[GitHub] [cloudstack] vishesh92 commented on a diff in pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on code in PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#discussion_r1191907394


##########
plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/command/user/kubernetes/cluster/AddVmsToKubernetesClusterCmd.java:
##########
@@ -0,0 +1,108 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.kubernetes.cluster;
+
+import com.cloud.kubernetes.cluster.KubernetesClusterService;
+import com.cloud.utils.exception.CloudRuntimeException;
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.KubernetesClusterResponse;
+import org.apache.cloudstack.api.response.SuccessResponse;
+import org.apache.cloudstack.api.response.UserVmResponse;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
+
+import javax.inject.Inject;
+import java.util.List;
+
+
+@APICommand(name = "addVmsToKubernetesCluster",

Review Comment:
   I am passing a list of VM IDs. That is why I used "Vms". Let me change it to "VirtualMachines".



-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1614183075

   @vishesh92 a [SF] Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests


-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1562535274

   @weizhouapache a [SF] Jenkins job has been kicked to build packages. It will be bundled with  KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.


-- 
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


[GitHub] [cloudstack] vishesh92 commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1600612678

   @blueorangutan package


-- 
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


[GitHub] [cloudstack] github-actions[bot] commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1571960497

   This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.


-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1572756515

   @vishesh92 a [SF] Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests


-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1600615393

   @vishesh92 a [SF] Jenkins job has been kicked to build packages. It will be bundled with  KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.


-- 
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


[GitHub] [cloudstack] DaanHoogland commented on a diff in pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on code in PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#discussion_r1217839430


##########
plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java:
##########
@@ -1342,6 +1507,71 @@ public boolean upgradeKubernetesCluster(UpgradeKubernetesClusterCmd cmd) throws
         return upgradeWorker.upgradeCluster();
     }
 
+    @Override
+    public boolean addVmsToCluster(AddVirtualMachinesToKubernetesClusterCmd cmd) {

Review Comment:
   i understand (though i think some checks are possible) but this must be well documented.
   I wonder also if we can do diagnosis on any clusters that were imported. Why do they fail and what can be done. i might be a hypochondriac but I foresee a lot of user questions on this feature ;)



-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1608294337

   Packaging result [SF]: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: el9 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 6340


-- 
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


[GitHub] [cloudstack] rohityadavcloud merged pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "rohityadavcloud (via GitHub)" <gi...@apache.org>.
rohityadavcloud merged PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515


-- 
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


[GitHub] [cloudstack] vishesh92 commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1614144119

   @blueorangutan package


-- 
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


[GitHub] [cloudstack] vishesh92 commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1614181934

   @blueorangutan test


-- 
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


[GitHub] [cloudstack] vishesh92 commented on a diff in pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on code in PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#discussion_r1203554020


##########
plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/command/user/kubernetes/cluster/StartKubernetesClusterCmd.java:
##########
@@ -99,6 +99,9 @@ public KubernetesCluster validateRequest() {
         if (kubernetesCluster == null) {
             throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Given Kubernetes cluster was not found");
         }
+        if (!kubernetesCluster.getManaged()) {
+            throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Given Kubernetes cluster is not managed by Apache CloudStack");

Review Comment:
   [deleteKubernetesCluster](https://cloudstack.apache.org/api/apidocs-4.18/apis/deleteKubernetesCluster.html) - Handled.
   [getKubernetesClusterConfig](https://cloudstack.apache.org/api/apidocs-4.18/apis/getKubernetesClusterConfig.html) should return config for any cluster if the details are present.
   [listKubernetesClusters](https://cloudstack.apache.org/api/apidocs-4.18/apis/listKubernetesClusters.html) - option to filter by managed.
   [scaleKubernetesCluster](https://cloudstack.apache.org/api/apidocs-4.18/apis/scaleKubernetesCluster.html) -  validateKubernetesClusterScaleParameters fails if the cluster is not managed.
   [startKubernetesCluster](https://cloudstack.apache.org/api/apidocs-4.18/apis/startKubernetesCluster.html) - Handled
   [stopKubernetesCluster](https://cloudstack.apache.org/api/apidocs-4.18/apis/stopKubernetesCluster.html) - Handled
   [upgradeKubernetesCluster](https://cloudstack.apache.org/api/apidocs-4.18/apis/upgradeKubernetesCluster.html) - validateKubernetesClusterUpgradeParameters fails if the cluster is not managed.
   
   @weizhouapache I have verified the implementation, and I have handled all the APIs.
   



-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1563526848

   @vishesh92 a [SF] Jenkins job has been kicked to build packages. It will be bundled with  KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.


-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1567932698

   @weizhouapache a [LL] Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests


-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1571062129

   Packaging result [SF]: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: el9 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 6188


-- 
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


[GitHub] [cloudstack] vishesh92 commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1570989183

   @blueorangutan package


-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1573397522

   <b>[SF] Trillian test result (tid-6662)</b>
   Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
   Total time taken: 42454 seconds
   Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr7515-t6662-kvm-centos7.zip
   Smoke tests completed. 109 look OK, 1 have errors, 0 did not run
   Only failed and skipped tests results shown below:
   
   
   Test | Result | Time (s) | Test File
   --- | --- | --- | ---
   test_10_test_unmanaged_cluster_lifecycle | `Error` | 36.61 | test_kubernetes_clusters.py
   ContextSuite context=TestKubernetesCluster>:teardown | `Error` | 143.96 | test_kubernetes_clusters.py
   


-- 
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


[GitHub] [cloudstack] DaanHoogland commented on a diff in pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on code in PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#discussion_r1219245032


##########
plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java:
##########
@@ -607,8 +622,58 @@ private void validateEndpointUrl() {
             throw new InvalidParameterValueException(error);
         }
     }
+    private void validateUnmanagedKubernetesClusterCreateParameters(final CreateKubernetesClusterCmd cmd) throws CloudRuntimeException {
+        final String name = cmd.getName();
+        final Long zoneId = cmd.getZoneId();
+        final Account owner = accountService.getActiveAccountById(cmd.getEntityOwnerId());
+        final Long networkId = cmd.getNetworkId();
+        final String sshKeyPair = cmd.getSSHKeyPairName();
+        final String dockerRegistryUserName = cmd.getDockerRegistryUserName();
+        final String dockerRegistryPassword = cmd.getDockerRegistryPassword();
+        final String dockerRegistryUrl = cmd.getDockerRegistryUrl();
+        final Long nodeRootDiskSize = cmd.getNodeRootDiskSize();
+        final String externalLoadBalancerIpAddress = cmd.getExternalLoadBalancerIpAddress();
+
+        if (name == null || name.isEmpty()) {
+            throw new InvalidParameterValueException("Invalid name for the Kubernetes cluster name: " + name);
+        }
+
+        DataCenter zone = dataCenterDao.findById(zoneId);
+        if (zone == null) {
+            throw new InvalidParameterValueException("Unable to find zone by ID: " + zoneId);
+        }
+
+        if (zone.getAllocationState() == Grouping.AllocationState.Disabled) {
+            throw new PermissionDeniedException(String.format("Cannot perform this operation, zone ID: %s is currently disabled", zone.getUuid()));
+        }
 
-    private void validateKubernetesClusterCreateParameters(final CreateKubernetesClusterCmd cmd) throws CloudRuntimeException {
+        if (!StringUtils.isBlank(sshKeyPair)) {
+            SSHKeyPairVO sshKeyPairVO = sshKeyPairDao.findByName(owner.getAccountId(), owner.getDomainId(), sshKeyPair);
+            if (sshKeyPairVO == null) {
+                throw new InvalidParameterValueException(String.format("Given SSH key pair with name: %s was not found for the account %s", sshKeyPair, owner.getAccountName()));
+            }
+        }
+
+        if (nodeRootDiskSize != null && nodeRootDiskSize <= 0) {
+            throw new InvalidParameterValueException(String.format("Invalid value for %s", ApiConstants.NODE_ROOT_DISK_SIZE));
+        }
+
+        validateDockerRegistryParams(dockerRegistryUserName, dockerRegistryPassword, dockerRegistryUrl);
+
+        Network network = null;
+        if (networkId != null) {
+            network = networkService.getNetwork(networkId);
+            if (network == null) {
+                throw new InvalidParameterValueException("Unable to find network with given ID");
+            }
+        }
+
+        if (StringUtils.isNotEmpty(externalLoadBalancerIpAddress) && (!NetUtils.isValidIp4(externalLoadBalancerIpAddress) && !NetUtils.isValidIp6(externalLoadBalancerIpAddress))) {
+            throw new InvalidParameterValueException("Invalid external load balancer IP address");
+        }
+    }
+
+    private void validateManagedKubernetesClusterCreateParameters(final CreateKubernetesClusterCmd cmd) throws CloudRuntimeException {

Review Comment:
   yes, definately, thanks



-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1613903950

   <b>[SF] Trillian test result (tid-6899)</b>
   Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
   Total time taken: 44377 seconds
   Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr7515-t6899-kvm-centos7.zip
   Smoke tests completed. 111 look OK, 2 have errors, 0 did not run
   Only failed and skipped tests results shown below:
   
   
   Test | Result | Time (s) | Test File
   --- | --- | --- | ---
   test_08_upgrade_kubernetes_ha_cluster | `Failure` | 652.67 | test_kubernetes_clusters.py
   test_11_test_unmanaged_cluster_lifecycle | `Error` | 76.37 | test_kubernetes_clusters.py
   test_01_migrate_VM_and_root_volume | `Error` | 78.74 | test_vm_life_cycle.py
   test_02_migrate_VM_with_two_data_disks | `Error` | 52.33 | test_vm_life_cycle.py
   


-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1610722861

   @vishesh92 a [SF] Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests


-- 
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


[GitHub] [cloudstack] vishesh92 commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1609260202

   @blueorangutan package


-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1604841978

   @vishesh92 a [SF] Jenkins job has been kicked to build packages. It will be bundled with  KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.


-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1604948605

   Packaging result [SF]: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: el9 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 6324


-- 
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


[GitHub] [cloudstack] github-actions[bot] commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1606955023

   This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.


-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1608377850

   <b>[SF] Trillian Build Failed (tid-6869)<b/>


-- 
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


[GitHub] [cloudstack] github-actions[bot] commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1609101744

   This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.


-- 
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


[GitHub] [cloudstack] vishesh92 commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1571323403

   @blueorangutan test


-- 
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


[GitHub] [cloudstack] DaanHoogland commented on a diff in pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on code in PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#discussion_r1217616356


##########
plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java:
##########
@@ -607,8 +622,58 @@ private void validateEndpointUrl() {
             throw new InvalidParameterValueException(error);
         }
     }
+    private void validateUnmanagedKubernetesClusterCreateParameters(final CreateKubernetesClusterCmd cmd) throws CloudRuntimeException {

Review Comment:
   can these methods be disected into smaller, shared validations?



##########
plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java:
##########
@@ -607,8 +622,58 @@ private void validateEndpointUrl() {
             throw new InvalidParameterValueException(error);
         }
     }
+    private void validateUnmanagedKubernetesClusterCreateParameters(final CreateKubernetesClusterCmd cmd) throws CloudRuntimeException {
+        final String name = cmd.getName();
+        final Long zoneId = cmd.getZoneId();
+        final Account owner = accountService.getActiveAccountById(cmd.getEntityOwnerId());
+        final Long networkId = cmd.getNetworkId();
+        final String sshKeyPair = cmd.getSSHKeyPairName();
+        final String dockerRegistryUserName = cmd.getDockerRegistryUserName();
+        final String dockerRegistryPassword = cmd.getDockerRegistryPassword();
+        final String dockerRegistryUrl = cmd.getDockerRegistryUrl();
+        final Long nodeRootDiskSize = cmd.getNodeRootDiskSize();
+        final String externalLoadBalancerIpAddress = cmd.getExternalLoadBalancerIpAddress();
+
+        if (name == null || name.isEmpty()) {
+            throw new InvalidParameterValueException("Invalid name for the Kubernetes cluster name: " + name);
+        }
+
+        DataCenter zone = dataCenterDao.findById(zoneId);
+        if (zone == null) {
+            throw new InvalidParameterValueException("Unable to find zone by ID: " + zoneId);
+        }
+
+        if (zone.getAllocationState() == Grouping.AllocationState.Disabled) {
+            throw new PermissionDeniedException(String.format("Cannot perform this operation, zone ID: %s is currently disabled", zone.getUuid()));
+        }
 
-    private void validateKubernetesClusterCreateParameters(final CreateKubernetesClusterCmd cmd) throws CloudRuntimeException {
+        if (!StringUtils.isBlank(sshKeyPair)) {
+            SSHKeyPairVO sshKeyPairVO = sshKeyPairDao.findByName(owner.getAccountId(), owner.getDomainId(), sshKeyPair);
+            if (sshKeyPairVO == null) {
+                throw new InvalidParameterValueException(String.format("Given SSH key pair with name: %s was not found for the account %s", sshKeyPair, owner.getAccountName()));
+            }
+        }
+
+        if (nodeRootDiskSize != null && nodeRootDiskSize <= 0) {
+            throw new InvalidParameterValueException(String.format("Invalid value for %s", ApiConstants.NODE_ROOT_DISK_SIZE));
+        }
+
+        validateDockerRegistryParams(dockerRegistryUserName, dockerRegistryPassword, dockerRegistryUrl);
+
+        Network network = null;
+        if (networkId != null) {
+            network = networkService.getNetwork(networkId);
+            if (network == null) {
+                throw new InvalidParameterValueException("Unable to find network with given ID");
+            }
+        }
+
+        if (StringUtils.isNotEmpty(externalLoadBalancerIpAddress) && (!NetUtils.isValidIp4(externalLoadBalancerIpAddress) && !NetUtils.isValidIp6(externalLoadBalancerIpAddress))) {
+            throw new InvalidParameterValueException("Invalid external load balancer IP address");
+        }
+    }
+
+    private void validateManagedKubernetesClusterCreateParameters(final CreateKubernetesClusterCmd cmd) throws CloudRuntimeException {

Review Comment:
   can these methods be dissected into smaller, shared validations?
   see L625



##########
plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java:
##########
@@ -1342,6 +1507,71 @@ public boolean upgradeKubernetesCluster(UpgradeKubernetesClusterCmd cmd) throws
         return upgradeWorker.upgradeCluster();
     }
 
+    @Override
+    public boolean addVmsToCluster(AddVirtualMachinesToKubernetesClusterCmd cmd) {

Review Comment:
   I see no validation code for the actual VM, what are we trusting to the user and what is automagically done by the system?
   I understand that we require due diligence from the user. No issue there. We should be able to document that properly though.



##########
plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/command/user/kubernetes/cluster/RemoveVirtualMachinesFromKubernetesClusterCmd.java:
##########
@@ -0,0 +1,99 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.kubernetes.cluster;
+
+import com.cloud.kubernetes.cluster.KubernetesClusterService;
+import com.cloud.utils.exception.CloudRuntimeException;
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.KubernetesClusterResponse;
+import org.apache.cloudstack.api.response.SuccessResponse;
+import org.apache.cloudstack.api.response.UserVmResponse;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
+
+import javax.inject.Inject;
+import java.util.List;
+
+@APICommand(name = "removeVirtualMachinesFromKubernetesCluster",
+        description = "Remove VMs from a kubernetes cluster",
+        responseObject = SuccessResponse.class,
+        since = "4.19.0",
+        authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
+public class RemoveVirtualMachinesFromKubernetesClusterCmd extends BaseCmd {

Review Comment:
   What is the practical use of this command? Only for unmanage, or also for scaling? I'd like to see that documented here (or linked to)



##########
plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/command/user/kubernetes/cluster/StartKubernetesClusterCmd.java:
##########
@@ -99,6 +99,10 @@ public KubernetesCluster validateRequest() {
         if (kubernetesCluster == null) {
             throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Given Kubernetes cluster was not found");
         }
+        if (kubernetesCluster.getClusterType() == KubernetesCluster.ClusterType.ExternalManaged) {
+            throw new ServerApiException(ApiErrorCode.PARAM_ERROR,
+                    String.format("Start kubernetes cluster is not supported for an externally managed cluster (%s)", kubernetesCluster.getName()));
+        }

Review Comment:
   can you extract this (and maybe the other validations) for readability?



##########
test/integration/smoke/test_kubernetes_clusters.py:
##########
@@ -610,7 +615,84 @@ def test_10_vpc_tier_kubernetes_cluster(self):
         k8s_cluster = None
         return
 
-    def createKubernetesCluster(self, name, version_id, size=1, control_nodes=1):
+    @attr(tags=["advanced", "smoke"], required_hardware="false")
+    def test_11_test_unmanaged_cluster_lifecycle(self):
+        """Test all operations on unmanaged Kubernetes cluster
+
+        # Validate the following:
+        # 1. createKubernetesCluster should return valid info for new cluster
+        # 2. The Cloud Database contains the valid information
+        # 3. stopKubernetesCluster doesn't work
+        # 4. startKubernetesCluster doesn't work
+        # 5. upgradeKubernetesCluster doesn't work
+        # 6. Adding & removing vm from cluster works
+        # 7. deleteKubernetesCluster should delete an existing HA Kubernetes cluster
+        """
+        cluster = self.createKubernetesCluster("test-unmanaged-cluster", None,
+                                               cluster_type="ExternalManaged")

Review Comment:
   ```suggestion
           cluster = self.createKubernetesCluster("test-unmanaged-cluster", None,
                                                  cluster_type="ExternalManaged")
           self.cleanup.append(cluster)
   ```
   is this needed/feasable? It seems to be the way it should be done.
   Note that in `createKubernetesCluser()`, 
   ```
   if not clusterResponse:
       self.cleanup.append(clusterResponse)
   ```
   , is done. so only if no response the cluster is added???
   
   bit scope creeping here, but the current implementation does not seem right.



##########
plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/command/user/kubernetes/cluster/CreateKubernetesClusterCmd.java:
##########
@@ -144,6 +145,9 @@ public class CreateKubernetesClusterCmd extends BaseAsyncCreateCmd {
             description = "root disk size in GB for each node")
     private Long nodeRootDiskSize;
 
+    @Parameter(name = ApiConstants.CLUSTER_TYPE, type = CommandType.STRING, required = true, description = "type of the cluster: CloudManaged, ExternalManaged")

Review Comment:
   we could add a since parameter here:
   ```suggestion
       @Parameter(name = ApiConstants.CLUSTER_TYPE, type = CommandType.STRING, required = true, description = "type of the cluster: CloudManaged, ExternalManaged", since="4.19.0.0")
   ```



-- 
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


[GitHub] [cloudstack] DaanHoogland commented on a diff in pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on code in PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#discussion_r1217779012


##########
plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java:
##########
@@ -1342,6 +1507,71 @@ public boolean upgradeKubernetesCluster(UpgradeKubernetesClusterCmd cmd) throws
         return upgradeWorker.upgradeCluster();
     }
 
+    @Override
+    public boolean addVmsToCluster(AddVirtualMachinesToKubernetesClusterCmd cmd) {

Review Comment:
   I mean about the contents of the VM and its validity to perform its role in/for the cluster.
   
   It should be provisioned with kubernetes code and maybe even containers, should it?



-- 
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


[GitHub] [cloudstack] vishesh92 commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1578280951

   @blueorangutan package


-- 
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


[GitHub] [cloudstack] vishesh92 commented on a diff in pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on code in PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#discussion_r1221160969


##########
test/integration/smoke/test_kubernetes_clusters.py:
##########
@@ -622,11 +704,10 @@ def createKubernetesCluster(self, name, version_id, size=1, control_nodes=1):
         createKubernetesClusterCmd.noderootdisksize = 10
         createKubernetesClusterCmd.account = self.account.name
         createKubernetesClusterCmd.domainid = self.domain.id
+        createKubernetesClusterCmd.clustertype = cluster_type
         if self.default_network:
             createKubernetesClusterCmd.networkid = self.default_network.id
         clusterResponse = self.apiclient.createKubernetesCluster(createKubernetesClusterCmd)
-        if not clusterResponse:
-            self.cleanup.append(clusterResponse)

Review Comment:
   KubernetesCluster class is not implemented and the cleanup call on the response object would fail.



-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1578399515

   Packaging result [LL]: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: el9 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 6096


-- 
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


[GitHub] [cloudstack] vishesh92 commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1612795464

   @blueorangutan test


-- 
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


[GitHub] [cloudstack] vishesh92 commented on a diff in pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on code in PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#discussion_r1205416033


##########
plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java:
##########
@@ -783,15 +843,16 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
                 List<KubernetesClusterDetailsVO> details = new ArrayList<>();
                 long kubernetesClusterId = kubernetesCluster.getId();
 
-                if (Network.GuestType.Shared.equals(network.getGuestType())) {
+                if ((network != null && Network.GuestType.Shared.equals(network.getGuestType())) || !cmd.isManaged()) {

Review Comment:
   I want to allow whatever information the user wants to add to the un-managed clusters.



-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1598358111

   Packaging result [SF]: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: el9 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 6274


-- 
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


[GitHub] [cloudstack] weizhouapache commented on a diff in pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "weizhouapache (via GitHub)" <gi...@apache.org>.
weizhouapache commented on code in PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#discussion_r1203698220


##########
plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/command/user/kubernetes/cluster/StartKubernetesClusterCmd.java:
##########
@@ -99,6 +99,9 @@ public KubernetesCluster validateRequest() {
         if (kubernetesCluster == null) {
             throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Given Kubernetes cluster was not found");
         }
+        if (!kubernetesCluster.getManaged()) {
+            throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Given Kubernetes cluster is not managed by Apache CloudStack");

Review Comment:
   great @vishesh92 
   can you add `isManaged` to KubernetesClusterResponse, and show/hide actions on UI based on it ?



-- 
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


[GitHub] [cloudstack] weizhouapache closed pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "weizhouapache (via GitHub)" <gi...@apache.org>.
weizhouapache closed pull request #7515: Feature: Add unmanaged kubernetes cluster
URL: https://github.com/apache/cloudstack/pull/7515


-- 
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


[GitHub] [cloudstack] andrijapanicsb commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "andrijapanicsb (via GitHub)" <gi...@apache.org>.
andrijapanicsb commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1559016678

   @blueorangutan package


-- 
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


[GitHub] [cloudstack] Pearl1594 commented on a diff in pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "Pearl1594 (via GitHub)" <gi...@apache.org>.
Pearl1594 commented on code in PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#discussion_r1191250311


##########
plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java:
##########
@@ -600,8 +609,66 @@ private void validateEndpointUrl() {
             throw new InvalidParameterValueException(error);
         }
     }
+    private void validateUnmanagedKubernetesClusterCreateParameters(final CreateKubernetesClusterCmd cmd) throws CloudRuntimeException {
+        final String name = cmd.getName();
+        final Long zoneId = cmd.getZoneId();
+        final Account owner = accountService.getActiveAccountById(cmd.getEntityOwnerId());
+        final Long networkId = cmd.getNetworkId();
+        final String sshKeyPair = cmd.getSSHKeyPairName();
+        final String dockerRegistryUserName = cmd.getDockerRegistryUserName();
+        final String dockerRegistryPassword = cmd.getDockerRegistryPassword();
+        final String dockerRegistryUrl = cmd.getDockerRegistryUrl();
+        final Long nodeRootDiskSize = cmd.getNodeRootDiskSize();
+        final String externalLoadBalancerIpAddress = cmd.getExternalLoadBalancerIpAddress();
+
+        if (name == null || name.isEmpty()) {
+            throw new InvalidParameterValueException("Invalid name for the Kubernetes cluster name:" + name);
+        }
+
+        DataCenter zone = dataCenterDao.findById(zoneId);
+        if (zone == null) {
+            throw new InvalidParameterValueException("Unable to find zone by ID: " + zoneId);
+        }
+
+        if (zone.getAllocationState() == Grouping.AllocationState.Disabled) {
+            throw new PermissionDeniedException(String.format("Cannot perform this operation, zone ID: %s is currently disabled", zone.getUuid()));
+        }
+
+        if (sshKeyPair != null && !sshKeyPair.isEmpty()) {
+            SSHKeyPairVO sshKeyPairVO = sshKeyPairDao.findByName(owner.getAccountId(), owner.getDomainId(), sshKeyPair);
+            if (sshKeyPairVO == null) {
+                throw new InvalidParameterValueException(String.format("Given SSH key pair with name: %s was not found for the account %s", sshKeyPair, owner.getAccountName()));
+            }
+        }
+
+        if (nodeRootDiskSize != null && nodeRootDiskSize <= 0) {
+            throw new InvalidParameterValueException(String.format("Invalid value for %s", ApiConstants.NODE_ROOT_DISK_SIZE));
+        }
 
-    private void validateKubernetesClusterCreateParameters(final CreateKubernetesClusterCmd cmd) throws CloudRuntimeException {
+        validateDockerRegistryParams(dockerRegistryUserName, dockerRegistryPassword, dockerRegistryUrl);
+
+        Network network = null;
+        if (networkId != null) {
+            network = networkService.getNetwork(networkId);
+            if (network == null) {
+                throw new InvalidParameterValueException("Unable to find network with given ID");
+            }
+        }
+
+        if (StringUtils.isNotEmpty(externalLoadBalancerIpAddress)) {
+            if (!NetUtils.isValidIp4(externalLoadBalancerIpAddress) && !NetUtils.isValidIp6(externalLoadBalancerIpAddress)) {
+                throw new InvalidParameterValueException("Invalid external load balancer IP address");
+            }
+            if (network == null) {
+                throw new InvalidParameterValueException(String.format("%s parameter must be specified along with %s parameter", ApiConstants.EXTERNAL_LOAD_BALANCER_IP_ADDRESS, ApiConstants.NETWORK_ID));
+            }
+            if (Network.GuestType.Shared.equals(network.getGuestType())) {
+                throw new InvalidParameterValueException(String.format("%s parameter must be specified along with %s type of network", ApiConstants.EXTERNAL_LOAD_BALANCER_IP_ADDRESS, Network.GuestType.Shared.toString()));
+            }

Review Comment:
   Correct me if I'm wrong, but should this check be negated or the exception should be different?



##########
plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java:
##########
@@ -600,8 +609,66 @@ private void validateEndpointUrl() {
             throw new InvalidParameterValueException(error);
         }
     }
+    private void validateUnmanagedKubernetesClusterCreateParameters(final CreateKubernetesClusterCmd cmd) throws CloudRuntimeException {
+        final String name = cmd.getName();
+        final Long zoneId = cmd.getZoneId();
+        final Account owner = accountService.getActiveAccountById(cmd.getEntityOwnerId());
+        final Long networkId = cmd.getNetworkId();
+        final String sshKeyPair = cmd.getSSHKeyPairName();
+        final String dockerRegistryUserName = cmd.getDockerRegistryUserName();
+        final String dockerRegistryPassword = cmd.getDockerRegistryPassword();
+        final String dockerRegistryUrl = cmd.getDockerRegistryUrl();
+        final Long nodeRootDiskSize = cmd.getNodeRootDiskSize();
+        final String externalLoadBalancerIpAddress = cmd.getExternalLoadBalancerIpAddress();
+
+        if (name == null || name.isEmpty()) {
+            throw new InvalidParameterValueException("Invalid name for the Kubernetes cluster name:" + name);

Review Comment:
   nit: May be we could just say missing cluster name or something around those lines, coz this would just print null for the name



##########
plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java:
##########
@@ -1019,12 +1093,64 @@ protected boolean stateTransitTo(long kubernetesClusterId, KubernetesCluster.Eve
     }
 
     @Override
-    public KubernetesCluster createKubernetesCluster(CreateKubernetesClusterCmd cmd) throws CloudRuntimeException {
+    public KubernetesCluster createUnmanagedKubernetesCluster(CreateKubernetesClusterCmd cmd) throws CloudRuntimeException {
+        if (!KubernetesServiceEnabled.value()) {
+            logAndThrow(Level.ERROR, "Kubernetes Service plugin is disabled");
+        }
+
+        validateUnmanagedKubernetesClusterCreateParameters(cmd);
+
+        final DataCenter zone = dataCenterDao.findById(cmd.getZoneId());
+        final long controlNodeCount = cmd.getControlNodes();
+        final long clusterSize = Objects.requireNonNullElse(cmd.getClusterSize(), 0L);
+        final ServiceOffering serviceOffering = serviceOfferingDao.findById(cmd.getServiceOfferingId());
+        final Account owner = accountService.getActiveAccountById(cmd.getEntityOwnerId());
+        final KubernetesSupportedVersion clusterKubernetesVersion = kubernetesSupportedVersionDao.findById(cmd.getKubernetesVersionId());
+
+        final Network network = networkDao.findById(cmd.getNetworkId());
+        long cores;
+        long memory;
+        Long serviceOfferingId = null;
+        if (serviceOffering != null) {
+            serviceOfferingId = serviceOffering.getId();
+            cores = serviceOffering.getCpu() * (controlNodeCount + clusterSize);
+            memory = serviceOffering.getRamSize() * (controlNodeCount + clusterSize);
+        } else {
+            cores = 0;
+            memory = 0;
+        }
+
+        final Long finalServiceOfferingId = serviceOfferingId;
+        final Long defaultNetworkId = network == null ? null : network.getId();
+        final Long clusterKubernetesVersionId = clusterKubernetesVersion == null ? null : clusterKubernetesVersion.getId();
+        final KubernetesClusterVO cluster = Transaction.execute(new TransactionCallback<KubernetesClusterVO>() {
+            @Override
+            public KubernetesClusterVO doInTransaction(TransactionStatus status) {
+                KubernetesClusterVO newCluster = new KubernetesClusterVO(cmd.getName(), cmd.getDisplayName(), zone.getId(), clusterKubernetesVersionId,
+                        finalServiceOfferingId, null, defaultNetworkId, owner.getDomainId(),
+                        owner.getAccountId(), controlNodeCount, clusterSize, KubernetesCluster.State.Running, cmd.getSSHKeyPairName(), cores, memory,
+                        cmd.getNodeRootDiskSize(), "", false);
+                kubernetesClusterDao.persist(newCluster);
+                return newCluster;
+            }
+        });
+
+        addKubernetesClusterDetails(cluster, network, cmd);
+
+        if (LOGGER.isInfoEnabled()) {
+            LOGGER.info(String.format("Kubernetes cluster name: %s and ID: %s has been created", cluster.getName(), cluster.getUuid()));

Review Comment:
   ```suggestion
               LOGGER.info(String.format("Kubernetes cluster with name: %s and ID: %s has been created", cluster.getName(), cluster.getUuid()));
   ```



##########
plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java:
##########
@@ -1111,6 +1238,10 @@ public boolean startKubernetesCluster(long kubernetesClusterId, boolean onCreate
         if (kubernetesCluster == null) {
             throw new InvalidParameterValueException("Failed to find Kubernetes cluster with given ID");
         }
+        if (!kubernetesCluster.getManaged()) {
+            LOGGER.debug(String.format("Kubernetes cluster : %s is not managed by CloudStack", kubernetesCluster.getName()));
+            return true;

Review Comment:
   can we add what operation is not supported for un-managed clusters



##########
plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java:
##########
@@ -1329,6 +1479,82 @@ public boolean upgradeKubernetesCluster(UpgradeKubernetesClusterCmd cmd) throws
         return upgradeWorker.upgradeCluster();
     }
 
+    @Override
+    public boolean addVmsToCluster(AddVmsToKubernetesClusterCmd cmd) {
+        if (!KubernetesServiceEnabled.value()) {
+            logAndThrow(Level.ERROR, "Kubernetes Service plugin is disabled");
+        }
+        List<Long> vmIds = cmd.getVmIds();
+        Long clusterId = cmd.getId();
+
+        if (vmIds == null || vmIds.isEmpty() || clusterId == null) {
+            throw new InvalidParameterValueException("Invalid parameters specified");
+        }
+
+        KubernetesClusterVO kubernetesCluster = kubernetesClusterDao.findById(clusterId);
+        if (kubernetesCluster == null) {
+            throw new InvalidParameterValueException("Invalid Kubernetes cluster ID specified");
+        }
+        // User should have access to both VM and Kubernetes cluster
+        accountManager.checkAccess(CallContext.current().getCallingAccount(), SecurityChecker.AccessType.OperateEntry, false, kubernetesCluster);
+        for (Long vmId : vmIds) {
+            VMInstanceVO vmInstance = vmInstanceDao.findById(vmId);
+            if (vmInstance == null) {
+                throw new InvalidParameterValueException("Invalid VM ID specified");
+            }
+            accountManager.checkAccess(CallContext.current().getCallingAccount(), SecurityChecker.AccessType.OperateEntry, false, vmInstance);
+        }
+
+        if (kubernetesCluster.getManaged()) {
+            throw new InvalidParameterValueException("VM cannot be added to a managed Kubernetes cluster");
+        }
+
+        KubernetesClusterVmMapVO clusterVmMap = null;
+        List<KubernetesClusterVmMapVO> clusterVmMapList = kubernetesClusterVmMapDao.listByClusterIdAndVmIdsIn(clusterId, vmIds);
+        ArrayList<Long> alreadyExistingVmIds = new ArrayList<>();
+        for (KubernetesClusterVmMapVO clusterVmMapVO : clusterVmMapList) {
+            alreadyExistingVmIds.add(clusterVmMapVO.getVmId());
+        }
+
+        for (Long vmId : vmIds) {
+            if (alreadyExistingVmIds.contains(vmId)) {
+                continue;
+            }
+            clusterVmMap = new KubernetesClusterVmMapVO(clusterId, vmId, cmd.isControlNode());
+            kubernetesClusterVmMapDao.persist(clusterVmMap);
+        }
+        return true;
+    }
+
+    @Override
+    public boolean removeVmsFromCluster(RemoveVmsFromKubernetesClusterCmd cmd) {
+        if (!KubernetesServiceEnabled.value()) {
+            logAndThrow(Level.ERROR, "Kubernetes Service plugin is disabled");
+        }
+        List<Long> vmIds = cmd.getVmIds();
+        Long clusterId = cmd.getId();
+
+        if (vmIds == null || vmIds.isEmpty() || clusterId == null) {
+            throw new InvalidParameterValueException("Invalid parameters specified");
+        }

Review Comment:
   same here, may be worth specifying what argument is missing 



##########
plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java:
##########
@@ -832,6 +900,9 @@ private void validateKubernetesClusterScaleParameters(ScaleKubernetesClusterCmd
 
         Account caller = CallContext.current().getCallingAccount();
         accountManager.checkAccess(caller, SecurityChecker.AccessType.OperateEntry, false, kubernetesCluster);
+        if (!kubernetesCluster.getManaged()) {
+            throw new InvalidParameterValueException(String.format("Kubernetes cluster %s is not managed by Apache CloudStack", kubernetesCluster.getName()));

Review Comment:
   Should we move this check right up, so as to first check if it's a managed cluster or not and then proceed with checking other params? Also, would it make sense to add that Scaling an unmanaged cluster is not supported via Cloudstack?



##########
plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java:
##########
@@ -1329,6 +1479,82 @@ public boolean upgradeKubernetesCluster(UpgradeKubernetesClusterCmd cmd) throws
         return upgradeWorker.upgradeCluster();
     }
 
+    @Override
+    public boolean addVmsToCluster(AddVmsToKubernetesClusterCmd cmd) {
+        if (!KubernetesServiceEnabled.value()) {
+            logAndThrow(Level.ERROR, "Kubernetes Service plugin is disabled");
+        }
+        List<Long> vmIds = cmd.getVmIds();
+        Long clusterId = cmd.getId();
+
+        if (vmIds == null || vmIds.isEmpty() || clusterId == null) {
+            throw new InvalidParameterValueException("Invalid parameters specified");
+        }
+
+        KubernetesClusterVO kubernetesCluster = kubernetesClusterDao.findById(clusterId);
+        if (kubernetesCluster == null) {
+            throw new InvalidParameterValueException("Invalid Kubernetes cluster ID specified");
+        }
+        // User should have access to both VM and Kubernetes cluster
+        accountManager.checkAccess(CallContext.current().getCallingAccount(), SecurityChecker.AccessType.OperateEntry, false, kubernetesCluster);
+        for (Long vmId : vmIds) {
+            VMInstanceVO vmInstance = vmInstanceDao.findById(vmId);
+            if (vmInstance == null) {
+                throw new InvalidParameterValueException("Invalid VM ID specified");
+            }
+            accountManager.checkAccess(CallContext.current().getCallingAccount(), SecurityChecker.AccessType.OperateEntry, false, vmInstance);
+        }
+
+        if (kubernetesCluster.getManaged()) {
+            throw new InvalidParameterValueException("VM cannot be added to a managed Kubernetes cluster");
+        }
+
+        KubernetesClusterVmMapVO clusterVmMap = null;
+        List<KubernetesClusterVmMapVO> clusterVmMapList = kubernetesClusterVmMapDao.listByClusterIdAndVmIdsIn(clusterId, vmIds);
+        ArrayList<Long> alreadyExistingVmIds = new ArrayList<>();
+        for (KubernetesClusterVmMapVO clusterVmMapVO : clusterVmMapList) {
+            alreadyExistingVmIds.add(clusterVmMapVO.getVmId());
+        }
+
+        for (Long vmId : vmIds) {

Review Comment:
   nit: maybe we could use vmIds.removeAll(alreadyExistingVmIds) to get the VMs that aren't existing 



##########
plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java:
##########
@@ -1329,6 +1479,82 @@ public boolean upgradeKubernetesCluster(UpgradeKubernetesClusterCmd cmd) throws
         return upgradeWorker.upgradeCluster();
     }
 
+    @Override
+    public boolean addVmsToCluster(AddVmsToKubernetesClusterCmd cmd) {
+        if (!KubernetesServiceEnabled.value()) {
+            logAndThrow(Level.ERROR, "Kubernetes Service plugin is disabled");
+        }
+        List<Long> vmIds = cmd.getVmIds();
+        Long clusterId = cmd.getId();
+
+        if (vmIds == null || vmIds.isEmpty() || clusterId == null) {
+            throw new InvalidParameterValueException("Invalid parameters specified");

Review Comment:
   could be helpful to specify what parameter wasn't passed, i.e., vmIDs or clusterID



##########
plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java:
##########
@@ -1019,12 +1093,64 @@ protected boolean stateTransitTo(long kubernetesClusterId, KubernetesCluster.Eve
     }
 
     @Override
-    public KubernetesCluster createKubernetesCluster(CreateKubernetesClusterCmd cmd) throws CloudRuntimeException {
+    public KubernetesCluster createUnmanagedKubernetesCluster(CreateKubernetesClusterCmd cmd) throws CloudRuntimeException {
+        if (!KubernetesServiceEnabled.value()) {
+            logAndThrow(Level.ERROR, "Kubernetes Service plugin is disabled");
+        }
+
+        validateUnmanagedKubernetesClusterCreateParameters(cmd);
+
+        final DataCenter zone = dataCenterDao.findById(cmd.getZoneId());
+        final long controlNodeCount = cmd.getControlNodes();
+        final long clusterSize = Objects.requireNonNullElse(cmd.getClusterSize(), 0L);
+        final ServiceOffering serviceOffering = serviceOfferingDao.findById(cmd.getServiceOfferingId());
+        final Account owner = accountService.getActiveAccountById(cmd.getEntityOwnerId());
+        final KubernetesSupportedVersion clusterKubernetesVersion = kubernetesSupportedVersionDao.findById(cmd.getKubernetesVersionId());
+
+        final Network network = networkDao.findById(cmd.getNetworkId());
+        long cores;
+        long memory;
+        Long serviceOfferingId = null;
+        if (serviceOffering != null) {
+            serviceOfferingId = serviceOffering.getId();
+            cores = serviceOffering.getCpu() * (controlNodeCount + clusterSize);
+            memory = serviceOffering.getRamSize() * (controlNodeCount + clusterSize);
+        } else {

Review Comment:
   nit: can we initialize cores and memory to 0, and do away with the else block?



##########
plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/command/user/kubernetes/cluster/CreateKubernetesClusterCmd.java:
##########
@@ -76,13 +76,13 @@ public class CreateKubernetesClusterCmd extends BaseAsyncCreateCmd {
             description = "availability zone in which Kubernetes cluster to be launched")
     private Long zoneId;
 
-    @Parameter(name = ApiConstants.KUBERNETES_VERSION_ID, type = CommandType.UUID, entityType = KubernetesSupportedVersionResponse.class, required = true,
+    @Parameter(name = ApiConstants.KUBERNETES_VERSION_ID, type = CommandType.UUID, entityType = KubernetesSupportedVersionResponse.class,

Review Comment:
   I believe we can add since to parameters too.. 



##########
plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java:
##########
@@ -1329,6 +1479,82 @@ public boolean upgradeKubernetesCluster(UpgradeKubernetesClusterCmd cmd) throws
         return upgradeWorker.upgradeCluster();
     }
 
+    @Override
+    public boolean addVmsToCluster(AddVmsToKubernetesClusterCmd cmd) {
+        if (!KubernetesServiceEnabled.value()) {
+            logAndThrow(Level.ERROR, "Kubernetes Service plugin is disabled");
+        }
+        List<Long> vmIds = cmd.getVmIds();
+        Long clusterId = cmd.getId();
+
+        if (vmIds == null || vmIds.isEmpty() || clusterId == null) {
+            throw new InvalidParameterValueException("Invalid parameters specified");
+        }
+
+        KubernetesClusterVO kubernetesCluster = kubernetesClusterDao.findById(clusterId);
+        if (kubernetesCluster == null) {
+            throw new InvalidParameterValueException("Invalid Kubernetes cluster ID specified");
+        }
+        // User should have access to both VM and Kubernetes cluster
+        accountManager.checkAccess(CallContext.current().getCallingAccount(), SecurityChecker.AccessType.OperateEntry, false, kubernetesCluster);
+        for (Long vmId : vmIds) {
+            VMInstanceVO vmInstance = vmInstanceDao.findById(vmId);
+            if (vmInstance == null) {
+                throw new InvalidParameterValueException("Invalid VM ID specified");
+            }
+            accountManager.checkAccess(CallContext.current().getCallingAccount(), SecurityChecker.AccessType.OperateEntry, false, vmInstance);
+        }
+
+        if (kubernetesCluster.getManaged()) {
+            throw new InvalidParameterValueException("VM cannot be added to a managed Kubernetes cluster");

Review Comment:
   can we move this check before the VM ids check, to fail faster, in case the cluster is of managed type



##########
plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java:
##########
@@ -600,8 +609,66 @@ private void validateEndpointUrl() {
             throw new InvalidParameterValueException(error);
         }
     }
+    private void validateUnmanagedKubernetesClusterCreateParameters(final CreateKubernetesClusterCmd cmd) throws CloudRuntimeException {
+        final String name = cmd.getName();
+        final Long zoneId = cmd.getZoneId();
+        final Account owner = accountService.getActiveAccountById(cmd.getEntityOwnerId());
+        final Long networkId = cmd.getNetworkId();
+        final String sshKeyPair = cmd.getSSHKeyPairName();
+        final String dockerRegistryUserName = cmd.getDockerRegistryUserName();
+        final String dockerRegistryPassword = cmd.getDockerRegistryPassword();
+        final String dockerRegistryUrl = cmd.getDockerRegistryUrl();
+        final Long nodeRootDiskSize = cmd.getNodeRootDiskSize();
+        final String externalLoadBalancerIpAddress = cmd.getExternalLoadBalancerIpAddress();
+
+        if (name == null || name.isEmpty()) {
+            throw new InvalidParameterValueException("Invalid name for the Kubernetes cluster name:" + name);
+        }
+
+        DataCenter zone = dataCenterDao.findById(zoneId);
+        if (zone == null) {
+            throw new InvalidParameterValueException("Unable to find zone by ID: " + zoneId);
+        }
+
+        if (zone.getAllocationState() == Grouping.AllocationState.Disabled) {
+            throw new PermissionDeniedException(String.format("Cannot perform this operation, zone ID: %s is currently disabled", zone.getUuid()));
+        }
+
+        if (sshKeyPair != null && !sshKeyPair.isEmpty()) {

Review Comment:
   Strings.isNullOrEmpty()
   ```suggestion
           if (!Strings.isNullOrEmpty(sshKeyPair)) {
   ```



##########
plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java:
##########
@@ -1178,6 +1309,9 @@ public boolean stopKubernetesCluster(long kubernetesClusterId) throws CloudRunti
         if (kubernetesCluster == null) {
             throw new InvalidParameterValueException("Failed to find Kubernetes cluster with given ID");
         }
+        if (!kubernetesCluster.getManaged()) {
+            throw new InvalidParameterValueException(String.format("Kubernetes cluster : %s is not managed by CloudStack", kubernetesCluster.getName()));
+        }

Review Comment:
   can we add what operation is not supported for un-managed clusters



##########
plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java:
##########
@@ -961,6 +1032,9 @@ private void validateKubernetesClusterUpgradeParameters(UpgradeKubernetesCluster
             throw new InvalidParameterValueException("Invalid Kubernetes cluster ID");
         }
         accountManager.checkAccess(CallContext.current().getCallingAccount(), SecurityChecker.AccessType.OperateEntry, false, kubernetesCluster);
+        if (!kubernetesCluster.getManaged()) {
+            throw new InvalidParameterValueException(String.format("Kubernetes cluster : %s is not managed by Apache CloudStack", kubernetesCluster.getName()));
+        }

Review Comment:
   Same here, Should we move this check right up, so as to first check if it's a managed cluster or not and then proceed with checking other params? Also, may be worth adding the operation that isn't supported via CloudStack for unmanaged clusters?
    



-- 
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


[GitHub] [cloudstack] weizhouapache commented on a diff in pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "weizhouapache (via GitHub)" <gi...@apache.org>.
weizhouapache commented on code in PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#discussion_r1203700906


##########
plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/command/user/kubernetes/cluster/StartKubernetesClusterCmd.java:
##########
@@ -99,6 +99,9 @@ public KubernetesCluster validateRequest() {
         if (kubernetesCluster == null) {
             throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Given Kubernetes cluster was not found");
         }
+        if (!kubernetesCluster.getManaged()) {
+            throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Given Kubernetes cluster is not managed by Apache CloudStack");

Review Comment:
   @vishesh92 
   also on UI, you can add a new field and a filter in the list view.



-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1560752661

   Packaging result [SF]: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: el9 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 6140


-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1562629513

   Packaging result [SF]: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: el9 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 6148


-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1609336659

   Packaging result [SF]: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: el9 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 6353


-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1609392485

   @vishesh92 a [SF] Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests


-- 
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


[GitHub] [cloudstack] github-actions[bot] commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1606956818

   This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.


-- 
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


[GitHub] [cloudstack] vishesh92 commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1608300942

   @blueorangutan test


-- 
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


[GitHub] [cloudstack] Pearl1594 commented on a diff in pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "Pearl1594 (via GitHub)" <gi...@apache.org>.
Pearl1594 commented on code in PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#discussion_r1213112542


##########
ui/src/config/section/compute.js:
##########
@@ -458,10 +458,10 @@ export default {
         return fields
       },
       filters: () => {
-        const filters = ['managed', 'unmanaged']
+        const filters = ['cloud.managed', 'external.managed']
         return filters
       },
-      details: ['name', 'description', 'zonename', 'kubernetesversionname', 'autoscalingenabled', 'minsize', 'maxsize', 'size', 'controlnodes', 'cpunumber', 'memory', 'keypair', 'associatednetworkname', 'account', 'domain', 'zonename', 'managed', 'created'],
+      details: ['name', 'description', 'zonenclusame', 'kubernetesversionname', 'autoscalingenabled', 'minsize', 'maxsize', 'size', 'controlnodes', 'cpunumber', 'memory', 'keypair', 'associatednetworkname', 'account', 'domain', 'zonename', 'clustertype', 'created'],

Review Comment:
   sorry @vishesh92 just noticed this, is this a typo? `zonenclusame` ?



-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1571902838

   <b>[SF] Trillian test result (tid-6640)</b>
   Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
   Total time taken: 24533 seconds
   Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr7515-t6640-kvm-centos7.zip
   Smoke tests completed. 84 look OK, 2 have errors, 24 did not run
   Only failed and skipped tests results shown below:
   
   
   Test | Result | Time (s) | Test File
   --- | --- | --- | ---
   test_10_reboot_cpvm_forced | `Error` | 6.26 | test_ssvm.py
   test_10_test_unmanaged_cluster_lifecycle | `Error` | 35.62 | test_kubernetes_clusters.py
   ContextSuite context=TestKubernetesCluster>:teardown | `Error` | 141.09 | test_kubernetes_clusters.py
   all_test_safe_shutdown | `Skipped` | --- | test_safe_shutdown.py
   all_test_metrics_api | `Skipped` | --- | test_metrics_api.py
   all_test_outofbandmanagement | `Skipped` | --- | test_outofbandmanagement.py
   all_test_outofbandmanagement_nestedplugin | `Skipped` | --- | test_outofbandmanagement_nestedplugin.py
   all_test_routers_iptables_default_policy | `Skipped` | --- | test_routers_iptables_default_policy.py
   all_test_secondary_storage | `Skipped` | --- | test_secondary_storage.py
   all_test_service_offerings | `Skipped` | --- | test_service_offerings.py
   all_test_storage_policy | `Skipped` | --- | test_storage_policy.py
   all_test_templates | `Skipped` | --- | test_templates.py
   all_test_update_security_group | `Skipped` | --- | test_update_security_group.py
   all_test_usage_events | `Skipped` | --- | test_usage_events.py
   all_test_vm_autoscaling | `Skipped` | --- | test_vm_autoscaling.py
   all_test_vm_deployment_planner | `Skipped` | --- | test_vm_deployment_planner.py
   all_test_vm_life_cycle | `Skipped` | --- | test_vm_life_cycle.py
   all_test_vm_lifecycle_unmanage_import | `Skipped` | --- | test_vm_lifecycle_unmanage_import.py
   all_test_vm_snapshot_kvm | `Skipped` | --- | test_vm_snapshot_kvm.py
   all_test_vm_snapshots | `Skipped` | --- | test_vm_snapshots.py
   all_test_volumes | `Skipped` | --- | test_volumes.py
   all_test_vpc_ipv6 | `Skipped` | --- | test_vpc_ipv6.py
   all_test_vpc_redundant | `Skipped` | --- | test_vpc_redundant.py
   all_test_vpc_router_nics | `Skipped` | --- | test_vpc_router_nics.py
   all_test_vpc_vpn | `Skipped` | --- | test_vpc_vpn.py
   all_test_host_maintenance | `Skipped` | --- | test_host_maintenance.py
   all_test_hostha_kvm | `Skipped` | --- | test_hostha_kvm.py
   


-- 
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


[GitHub] [cloudstack] vishesh92 commented on a diff in pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on code in PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#discussion_r1218932926


##########
plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java:
##########
@@ -607,8 +622,58 @@ private void validateEndpointUrl() {
             throw new InvalidParameterValueException(error);
         }
     }
+    private void validateUnmanagedKubernetesClusterCreateParameters(final CreateKubernetesClusterCmd cmd) throws CloudRuntimeException {
+        final String name = cmd.getName();
+        final Long zoneId = cmd.getZoneId();
+        final Account owner = accountService.getActiveAccountById(cmd.getEntityOwnerId());
+        final Long networkId = cmd.getNetworkId();
+        final String sshKeyPair = cmd.getSSHKeyPairName();
+        final String dockerRegistryUserName = cmd.getDockerRegistryUserName();
+        final String dockerRegistryPassword = cmd.getDockerRegistryPassword();
+        final String dockerRegistryUrl = cmd.getDockerRegistryUrl();
+        final Long nodeRootDiskSize = cmd.getNodeRootDiskSize();
+        final String externalLoadBalancerIpAddress = cmd.getExternalLoadBalancerIpAddress();
+
+        if (name == null || name.isEmpty()) {
+            throw new InvalidParameterValueException("Invalid name for the Kubernetes cluster name: " + name);
+        }
+
+        DataCenter zone = dataCenterDao.findById(zoneId);
+        if (zone == null) {
+            throw new InvalidParameterValueException("Unable to find zone by ID: " + zoneId);
+        }
+
+        if (zone.getAllocationState() == Grouping.AllocationState.Disabled) {
+            throw new PermissionDeniedException(String.format("Cannot perform this operation, zone ID: %s is currently disabled", zone.getUuid()));
+        }
 
-    private void validateKubernetesClusterCreateParameters(final CreateKubernetesClusterCmd cmd) throws CloudRuntimeException {
+        if (!StringUtils.isBlank(sshKeyPair)) {
+            SSHKeyPairVO sshKeyPairVO = sshKeyPairDao.findByName(owner.getAccountId(), owner.getDomainId(), sshKeyPair);
+            if (sshKeyPairVO == null) {
+                throw new InvalidParameterValueException(String.format("Given SSH key pair with name: %s was not found for the account %s", sshKeyPair, owner.getAccountName()));
+            }
+        }
+
+        if (nodeRootDiskSize != null && nodeRootDiskSize <= 0) {
+            throw new InvalidParameterValueException(String.format("Invalid value for %s", ApiConstants.NODE_ROOT_DISK_SIZE));
+        }
+
+        validateDockerRegistryParams(dockerRegistryUserName, dockerRegistryPassword, dockerRegistryUrl);
+
+        Network network = null;
+        if (networkId != null) {
+            network = networkService.getNetwork(networkId);
+            if (network == null) {
+                throw new InvalidParameterValueException("Unable to find network with given ID");
+            }
+        }
+
+        if (StringUtils.isNotEmpty(externalLoadBalancerIpAddress) && (!NetUtils.isValidIp4(externalLoadBalancerIpAddress) && !NetUtils.isValidIp6(externalLoadBalancerIpAddress))) {
+            throw new InvalidParameterValueException("Invalid external load balancer IP address");
+        }
+    }
+
+    private void validateManagedKubernetesClusterCreateParameters(final CreateKubernetesClusterCmd cmd) throws CloudRuntimeException {

Review Comment:
   I kept the methods separate for code readability. I have extracted some shared validations into separate methods. Is this better now?



-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1604766787

   Packaging result [SF]: :heavy_multiplication_x: el7 :heavy_multiplication_x: el8 :heavy_multiplication_x: el9 :heavy_multiplication_x: debian :heavy_multiplication_x: suse15. SL-JID 6323


-- 
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


[GitHub] [cloudstack] vishesh92 commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1604683815

   @blueorangutan package


-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1607129214

   @vishesh92 a [SF] Jenkins job has been kicked to build packages. It will be bundled with  KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.


-- 
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


[GitHub] [cloudstack] vishesh92 commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1608204393

   @blueorangutan package


-- 
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


[GitHub] [cloudstack] vishesh92 commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1560666940

   @blueorangutan package


-- 
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


[GitHub] [cloudstack] weizhouapache commented on a diff in pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "weizhouapache (via GitHub)" <gi...@apache.org>.
weizhouapache commented on code in PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#discussion_r1205950709


##########
ui/src/views/compute/KubernetesServiceTab.vue:
##########
@@ -25,17 +25,14 @@
       <a-tab-pane :tab="$t('label.details')" key="details">
         <DetailsTab :resource="resource" :loading="loading" />
       </a-tab-pane>
-      <a-tab-pane :tab="$t('label.access')" key="access">
+      <a-tab-pane v-if="clusterConfig !== ''" :tab="$t('label.access')" key="access">

Review Comment:
   you can rollback the changes and use `managed` here



##########
plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java:
##########
@@ -783,15 +843,16 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
                 List<KubernetesClusterDetailsVO> details = new ArrayList<>();
                 long kubernetesClusterId = kubernetesCluster.getId();
 
-                if (Network.GuestType.Shared.equals(network.getGuestType())) {
+                if ((network != null && Network.GuestType.Shared.equals(network.getGuestType())) || !cmd.isManaged()) {

Review Comment:
   OK.
   it might be useful



##########
tools/marvin/marvin/deployDataCenter.py:
##########
@@ -1133,7 +1133,7 @@ def removeDataCenter(self):
             print("\n====DeployDC: CleanUp Started====")
             ret = FAILED
             if self.__dcCfgFile:
-                file_to_read = open(self.__dcCfgFile, 'rb')
+                file_to_read = open(self.__dcCfgFile, 'r')

Review Comment:
   this reverts #7521 , which seems wrong



-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1563589506

   Packaging result [SF]: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: el9 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 6152


-- 
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


[GitHub] [cloudstack] vishesh92 commented on a diff in pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on code in PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#discussion_r1213611667


##########
ui/src/config/section/compute.js:
##########
@@ -458,10 +458,10 @@ export default {
         return fields
       },
       filters: () => {
-        const filters = ['managed', 'unmanaged']
+        const filters = ['cloud.managed', 'external.managed']
         return filters
       },
-      details: ['name', 'description', 'zonename', 'kubernetesversionname', 'autoscalingenabled', 'minsize', 'maxsize', 'size', 'controlnodes', 'cpunumber', 'memory', 'keypair', 'associatednetworkname', 'account', 'domain', 'zonename', 'managed', 'created'],
+      details: ['name', 'description', 'zonenclusame', 'kubernetesversionname', 'autoscalingenabled', 'minsize', 'maxsize', 'size', 'controlnodes', 'cpunumber', 'memory', 'keypair', 'associatednetworkname', 'account', 'domain', 'zonename', 'clustertype', 'created'],

Review Comment:
   My bad. Nice catch @Pearl1594 



-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1570992545

   @vishesh92 a [SF] Jenkins job has been kicked to build packages. It will be bundled with  KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.


-- 
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


[GitHub] [cloudstack] vishesh92 commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1571319372

   @blueorangutan test


-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1612798976

   @vishesh92 a [SF] Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests


-- 
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


[GitHub] [cloudstack] vishesh92 commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1614143051

   @blueorangutan help


-- 
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


[GitHub] [cloudstack] andrijapanicsb commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "andrijapanicsb (via GitHub)" <gi...@apache.org>.
andrijapanicsb commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1558875538

   @blueorangutan LLpackage


-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1559060441

   Packaging result: :heavy_multiplication_x: el7 :heavy_multiplication_x: el8 :heavy_multiplication_x: el9 :heavy_multiplication_x: debian :heavy_multiplication_x: suse15. SL-JID 6126


-- 
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


[GitHub] [cloudstack] vishesh92 commented on a diff in pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on code in PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#discussion_r1218936584


##########
plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/command/user/kubernetes/cluster/RemoveVirtualMachinesFromKubernetesClusterCmd.java:
##########
@@ -0,0 +1,99 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.kubernetes.cluster;
+
+import com.cloud.kubernetes.cluster.KubernetesClusterService;
+import com.cloud.utils.exception.CloudRuntimeException;
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.KubernetesClusterResponse;
+import org.apache.cloudstack.api.response.SuccessResponse;
+import org.apache.cloudstack.api.response.UserVmResponse;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
+
+import javax.inject.Inject;
+import java.util.List;
+
+@APICommand(name = "removeVirtualMachinesFromKubernetesCluster",
+        description = "Remove VMs from a kubernetes cluster",
+        responseObject = SuccessResponse.class,
+        since = "4.19.0",
+        authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
+public class RemoveVirtualMachinesFromKubernetesClusterCmd extends BaseCmd {

Review Comment:
   This is for `ExternalManaged` kubernetes cluster only. Updating this in the API description & documentation should be good, right?



-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1578281612

   @vishesh92 a [LL] Jenkins job has been kicked to build packages. It will be bundled with  KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.


-- 
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


[GitHub] [cloudstack] shwstppr commented on a diff in pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "shwstppr (via GitHub)" <gi...@apache.org>.
shwstppr commented on code in PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#discussion_r1221161624


##########
test/integration/smoke/test_kubernetes_clusters.py:
##########
@@ -622,11 +704,10 @@ def createKubernetesCluster(self, name, version_id, size=1, control_nodes=1):
         createKubernetesClusterCmd.noderootdisksize = 10
         createKubernetesClusterCmd.account = self.account.name
         createKubernetesClusterCmd.domainid = self.domain.id
+        createKubernetesClusterCmd.clustertype = cluster_type
         if self.default_network:
             createKubernetesClusterCmd.networkid = self.default_network.id
         clusterResponse = self.apiclient.createKubernetesCluster(createKubernetesClusterCmd)
-        if not clusterResponse:
-            self.cleanup.append(clusterResponse)

Review Comment:
   I feel this code was unnecessary. Adding clusterResponse in cleanup won't work as we do not have code in marvin/lib/base to handle obj.delete() for a KubernetesCluster.
   Also, as far as I remember this test file tries to use the same k8s cluster across different test cases to preserve time to deploy a new k8s cluster so either we refactor the whole class or handle cleanup of created cluster depending on the testcase



-- 
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


[GitHub] [cloudstack] weizhouapache commented on a diff in pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "weizhouapache (via GitHub)" <gi...@apache.org>.
weizhouapache commented on code in PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#discussion_r1191318997


##########
plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/command/user/kubernetes/cluster/AddVmsToKubernetesClusterCmd.java:
##########
@@ -0,0 +1,108 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.kubernetes.cluster;
+
+import com.cloud.kubernetes.cluster.KubernetesClusterService;
+import com.cloud.utils.exception.CloudRuntimeException;
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.KubernetesClusterResponse;
+import org.apache.cloudstack.api.response.SuccessResponse;
+import org.apache.cloudstack.api.response.UserVmResponse;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
+
+import javax.inject.Inject;
+import java.util.List;
+
+
+@APICommand(name = "addVmsToKubernetesCluster",

Review Comment:
   @vishesh92 
   if the parameter is the id of a VM, should it be "Vm" not "Vms" ?
   
   and, would it be better to use "VirtualMachine" instead of "VM" ?



-- 
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


[GitHub] [cloudstack] weizhouapache commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "weizhouapache (via GitHub)" <gi...@apache.org>.
weizhouapache commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1567930975

   @blueorangutan LLtest


-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1598278608

   @kiranchavala a [SF] Jenkins job has been kicked to build packages. It will be bundled with  KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.


-- 
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


[GitHub] [cloudstack] vishesh92 commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1604837792

   @blueorangutan package


-- 
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


[GitHub] [cloudstack] vishesh92 commented on a diff in pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on code in PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#discussion_r1202176251


##########
plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/command/user/kubernetes/cluster/StartKubernetesClusterCmd.java:
##########
@@ -99,6 +99,9 @@ public KubernetesCluster validateRequest() {
         if (kubernetesCluster == null) {
             throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Given Kubernetes cluster was not found");
         }
+        if (!kubernetesCluster.getManaged()) {
+            throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Given Kubernetes cluster is not managed by Apache CloudStack");

Review Comment:
   I think I have added this as part of the validate parameters method. Let me verify for all APIs once again if I missed something.



-- 
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


[GitHub] [cloudstack] vishesh92 commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1560663884

   @blueorangutan package


-- 
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


[GitHub] [cloudstack] vishesh92 commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1607127519

   @blueorangutan package


-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1612351611

   <b>[SF] Trillian test result (tid-6888)</b>
   Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
   Total time taken: 76692 seconds
   Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr7515-t6888-kvm-centos7.zip
   Smoke tests completed. 88 look OK, 25 have errors, 0 did not run
   Only failed and skipped tests results shown below:
   
   
   Test | Result | Time (s) | Test File
   --- | --- | --- | ---
   test_11_test_unmanaged_cluster_lifecycle | `Error` | 68.25 | test_kubernetes_clusters.py
   ContextSuite context=TestAdapterTypeForNic>:setup | `Error` | 0.00 | test_nic_adapter_type.py
   ContextSuite context=TestDomainsServiceOfferings>:setup | `Error` | 3.60 | test_domain_service_offerings.py
   ContextSuite context=TestPrivateGwACL>:setup | `Error` | 0.00 | test_privategw_acl.py
   ContextSuite context=TestRouterDHCPHosts>:setup | `Error` | 0.00 | test_router_dhcphosts.py
   ContextSuite context=TestRouterDHCPOpts>:setup | `Error` | 0.00 | test_router_dhcphosts.py
   ContextSuite context=TestProjectSuspendActivate>:setup | `Error` | 8.51 | test_projects.py
   test_01_add_delete_kubernetes_supported_version | `Error` | 1801.83 | test_kubernetes_supported_versions.py
   ContextSuite context=TestListIdsParams>:setup | `Error` | 0.00 | test_list_ids_parameter.py
   ContextSuite context=TestMetrics>:setup | `Error` | 0.00 | test_metrics_api.py
   ContextSuite context=TestRouterDns>:setup | `Error` | 0.00 | test_router_dns.py
   ContextSuite context=TestLoadBalance>:setup | `Error` | 0.00 | test_loadbalance.py
   ContextSuite context=TestRouterDnsService>:setup | `Error` | 0.00 | test_router_dnsservice.py
   ContextSuite context=TestRouterServices>:setup | `Error` | 0.00 | test_routers.py
   ContextSuite context=TestIsolatedNetworks>:setup | `Error` | 0.00 | test_routers_network_ops.py
   ContextSuite context=TestRedundantIsolateNetworks>:setup | `Error` | 0.00 | test_routers_network_ops.py
   ContextSuite context=TestRouterIpTablesPolicies>:setup | `Error` | 0.00 | test_routers_iptables_default_policy.py
   ContextSuite context=TestVPCIpTablesPolicies>:setup | `Error` | 0.00 | test_routers_iptables_default_policy.py
   ContextSuite context=TestCpuCapServiceOfferings>:setup | `Error` | 0.00 | test_service_offerings.py
   ContextSuite context=TestServiceOfferings>:setup | `Error` | 0.21 | test_service_offerings.py
   ContextSuite context=TestVMWareStoragePolicies>:setup | `Error` | 0.00 | test_storage_policy.py
   test_01_create_template | `Error` | 9.35 | test_templates.py
   test_CreateTemplateWithDuplicateName | `Error` | 17.57 | test_templates.py
   test_02_create_template_with_checksum_sha1 | `Error` | 65.46 | test_templates.py
   test_03_create_template_with_checksum_sha256 | `Error` | 65.45 | test_templates.py
   test_04_create_template_with_checksum_md5 | `Error` | 65.48 | test_templates.py
   test_05_create_template_with_no_checksum | `Error` | 65.45 | test_templates.py
   test_03_delete_template | `Error` | 1.07 | test_templates.py
   test_04_extract_template | `Error` | 1.08 | test_templates.py
   test_09_list_templates_download_details | `Failure` | 0.07 | test_templates.py
   test_01_migrate_VM_and_root_volume | `Error` | 81.75 | test_vm_life_cycle.py
   test_02_migrate_VM_with_two_data_disks | `Error` | 55.46 | test_vm_life_cycle.py
   test_10_attachAndDetach_iso | `Error` | 0.07 | test_vm_life_cycle.py
   test_06_download_detached_volume | `Error` | 304.86 | test_volumes.py
   test_13_migrate_volume_and_change_offering | `Error` | 128.03 | test_volumes.py
   ContextSuite context=TestIpv6Vpc>:setup | `Error` | 0.00 | test_vpc_ipv6.py
   ContextSuite context=TestVPCRedundancy>:setup | `Error` | 0.00 | test_vpc_redundant.py
   ContextSuite context=TestVPCNics>:setup | `Error` | 0.00 | test_vpc_router_nics.py
   ContextSuite context=TestRVPCSite2SiteVpn>:setup | `Error` | 0.00 | test_vpc_vpn.py
   ContextSuite context=TestVPCSite2SiteVPNMultipleOptions>:setup | `Error` | 0.00 | test_vpc_vpn.py
   ContextSuite context=TestVpcRemoteAccessVpn>:setup | `Error` | 0.00 | test_vpc_vpn.py
   ContextSuite context=TestVpcSite2SiteVpn>:setup | `Error` | 0.00 | test_vpc_vpn.py
   test_disable_oobm_ha_state_ineligible | `Error` | 0.35 | test_hostha_kvm.py
   


-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1614181330

   Packaging result [SF]: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: el9 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 6371


-- 
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


[GitHub] [cloudstack] vishesh92 commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1609388500

   @blueorangutan test


-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1615043081

   <b>[SF] Trillian test result (tid-6912)</b>
   Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
   Total time taken: 42345 seconds
   Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr7515-t6912-kvm-centos7.zip
   Smoke tests completed. 111 look OK, 2 have errors, 0 did not run
   Only failed and skipped tests results shown below:
   
   
   Test | Result | Time (s) | Test File
   --- | --- | --- | ---
   test_01_migrate_VM_and_root_volume | `Error` | 80.75 | test_vm_life_cycle.py
   test_02_migrate_VM_with_two_data_disks | `Error` | 56.45 | test_vm_life_cycle.py
   test_05_vmschedule_test_e2e | `Failure` | 170.62 | test_vm_schedule.py
   


-- 
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


[GitHub] [cloudstack] Pearl1594 commented on a diff in pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "Pearl1594 (via GitHub)" <gi...@apache.org>.
Pearl1594 commented on code in PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#discussion_r1192357283


##########
plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/command/user/kubernetes/cluster/CreateKubernetesClusterCmd.java:
##########
@@ -76,13 +76,13 @@ public class CreateKubernetesClusterCmd extends BaseAsyncCreateCmd {
             description = "availability zone in which Kubernetes cluster to be launched")
     private Long zoneId;
 
-    @Parameter(name = ApiConstants.KUBERNETES_VERSION_ID, type = CommandType.UUID, entityType = KubernetesSupportedVersionResponse.class, required = true,
+    @Parameter(name = ApiConstants.KUBERNETES_VERSION_ID, type = CommandType.UUID, entityType = KubernetesSupportedVersionResponse.class,

Review Comment:
   may be not.. sorry, my bad.



-- 
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


[GitHub] [cloudstack] vishesh92 commented on a diff in pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on code in PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#discussion_r1191723460


##########
plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java:
##########
@@ -600,8 +609,66 @@ private void validateEndpointUrl() {
             throw new InvalidParameterValueException(error);
         }
     }
+    private void validateUnmanagedKubernetesClusterCreateParameters(final CreateKubernetesClusterCmd cmd) throws CloudRuntimeException {
+        final String name = cmd.getName();
+        final Long zoneId = cmd.getZoneId();
+        final Account owner = accountService.getActiveAccountById(cmd.getEntityOwnerId());
+        final Long networkId = cmd.getNetworkId();
+        final String sshKeyPair = cmd.getSSHKeyPairName();
+        final String dockerRegistryUserName = cmd.getDockerRegistryUserName();
+        final String dockerRegistryPassword = cmd.getDockerRegistryPassword();
+        final String dockerRegistryUrl = cmd.getDockerRegistryUrl();
+        final Long nodeRootDiskSize = cmd.getNodeRootDiskSize();
+        final String externalLoadBalancerIpAddress = cmd.getExternalLoadBalancerIpAddress();
+
+        if (name == null || name.isEmpty()) {
+            throw new InvalidParameterValueException("Invalid name for the Kubernetes cluster name:" + name);
+        }
+
+        DataCenter zone = dataCenterDao.findById(zoneId);
+        if (zone == null) {
+            throw new InvalidParameterValueException("Unable to find zone by ID: " + zoneId);
+        }
+
+        if (zone.getAllocationState() == Grouping.AllocationState.Disabled) {
+            throw new PermissionDeniedException(String.format("Cannot perform this operation, zone ID: %s is currently disabled", zone.getUuid()));
+        }
+
+        if (sshKeyPair != null && !sshKeyPair.isEmpty()) {
+            SSHKeyPairVO sshKeyPairVO = sshKeyPairDao.findByName(owner.getAccountId(), owner.getDomainId(), sshKeyPair);
+            if (sshKeyPairVO == null) {
+                throw new InvalidParameterValueException(String.format("Given SSH key pair with name: %s was not found for the account %s", sshKeyPair, owner.getAccountName()));
+            }
+        }
+
+        if (nodeRootDiskSize != null && nodeRootDiskSize <= 0) {
+            throw new InvalidParameterValueException(String.format("Invalid value for %s", ApiConstants.NODE_ROOT_DISK_SIZE));
+        }
 
-    private void validateKubernetesClusterCreateParameters(final CreateKubernetesClusterCmd cmd) throws CloudRuntimeException {
+        validateDockerRegistryParams(dockerRegistryUserName, dockerRegistryPassword, dockerRegistryUrl);
+
+        Network network = null;
+        if (networkId != null) {
+            network = networkService.getNetwork(networkId);
+            if (network == null) {
+                throw new InvalidParameterValueException("Unable to find network with given ID");
+            }
+        }
+
+        if (StringUtils.isNotEmpty(externalLoadBalancerIpAddress)) {
+            if (!NetUtils.isValidIp4(externalLoadBalancerIpAddress) && !NetUtils.isValidIp6(externalLoadBalancerIpAddress)) {
+                throw new InvalidParameterValueException("Invalid external load balancer IP address");
+            }
+            if (network == null) {
+                throw new InvalidParameterValueException(String.format("%s parameter must be specified along with %s parameter", ApiConstants.EXTERNAL_LOAD_BALANCER_IP_ADDRESS, ApiConstants.NETWORK_ID));
+            }
+            if (Network.GuestType.Shared.equals(network.getGuestType())) {
+                throw new InvalidParameterValueException(String.format("%s parameter must be specified along with %s type of network", ApiConstants.EXTERNAL_LOAD_BALANCER_IP_ADDRESS, Network.GuestType.Shared.toString()));
+            }

Review Comment:
   I am removing these checks. Since this is cluster is not managed by CKS, we can allow the user to add this information if they want.



##########
plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java:
##########
@@ -600,8 +609,66 @@ private void validateEndpointUrl() {
             throw new InvalidParameterValueException(error);
         }
     }
+    private void validateUnmanagedKubernetesClusterCreateParameters(final CreateKubernetesClusterCmd cmd) throws CloudRuntimeException {
+        final String name = cmd.getName();
+        final Long zoneId = cmd.getZoneId();
+        final Account owner = accountService.getActiveAccountById(cmd.getEntityOwnerId());
+        final Long networkId = cmd.getNetworkId();
+        final String sshKeyPair = cmd.getSSHKeyPairName();
+        final String dockerRegistryUserName = cmd.getDockerRegistryUserName();
+        final String dockerRegistryPassword = cmd.getDockerRegistryPassword();
+        final String dockerRegistryUrl = cmd.getDockerRegistryUrl();
+        final Long nodeRootDiskSize = cmd.getNodeRootDiskSize();
+        final String externalLoadBalancerIpAddress = cmd.getExternalLoadBalancerIpAddress();
+
+        if (name == null || name.isEmpty()) {
+            throw new InvalidParameterValueException("Invalid name for the Kubernetes cluster name:" + name);

Review Comment:
   Doesn't this give better information whether the `name` is `null` or an empty string?



##########
plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/command/user/kubernetes/cluster/CreateKubernetesClusterCmd.java:
##########
@@ -76,13 +76,13 @@ public class CreateKubernetesClusterCmd extends BaseAsyncCreateCmd {
             description = "availability zone in which Kubernetes cluster to be launched")
     private Long zoneId;
 
-    @Parameter(name = ApiConstants.KUBERNETES_VERSION_ID, type = CommandType.UUID, entityType = KubernetesSupportedVersionResponse.class, required = true,
+    @Parameter(name = ApiConstants.KUBERNETES_VERSION_ID, type = CommandType.UUID, entityType = KubernetesSupportedVersionResponse.class,

Review Comment:
   We are not adding a new parameter but making it not required. Should we still add since here?



-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1559017572

   @andrijapanicsb a [SF] Jenkins job has been kicked to build packages. It will be bundled with  KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.


-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1600705500

   Packaging result [SF]: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: el9 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 6289


-- 
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


[GitHub] [cloudstack] vishesh92 commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1576063707

   @blueorangutan help


-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1610394120

   <b>[SF] Trillian test result (tid-6885)</b>
   Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
   Total time taken: 41387 seconds
   Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr7515-t6885-kvm-centos7.zip
   Smoke tests completed. 80 look OK, 33 have errors, 0 did not run
   Only failed and skipped tests results shown below:
   
   
   Test | Result | Time (s) | Test File
   --- | --- | --- | ---
   ContextSuite context=TestDeployVMFromISO>:setup | `Error` | 0.00 | test_deploy_vm_iso.py
   test_delete_account | `Error` | 0.10 | test_network.py
   test_delete_network_while_vm_on_it | `Error` | 1.13 | test_network.py
   test_deploy_vm_l2network | `Error` | 1.13 | test_network.py
   test_l2network_restart | `Error` | 2.25 | test_network.py
   ContextSuite context=TestPortForwarding>:setup | `Error` | 3.46 | test_network.py
   ContextSuite context=TestPublicIP>:setup | `Error` | 3.81 | test_network.py
   test_reboot_router | `Failure` | 0.05 | test_network.py
   test_releaseIP | `Error` | 1.75 | test_network.py
   ContextSuite context=TestRouterRules>:setup | `Error` | 1.82 | test_network.py
   ContextSuite context=TestNetworkACL>:setup | `Error` | 0.00 | test_network_acl.py
   test_07_deploy_kubernetes_ha_cluster | `Failure` | 3612.90 | test_kubernetes_clusters.py
   test_08_upgrade_kubernetes_ha_cluster | `Failure` | 0.07 | test_kubernetes_clusters.py
   test_09_delete_kubernetes_ha_cluster | `Failure` | 0.04 | test_kubernetes_clusters.py
   test_11_test_unmanaged_cluster_lifecycle | `Error` | 44.83 | test_kubernetes_clusters.py
   ContextSuite context=TestKubernetesCluster>:teardown | `Error` | 100.16 | test_kubernetes_clusters.py
   ContextSuite context=TestRemoteDiagnostics>:setup | `Error` | 0.00 | test_diagnostics.py
   ContextSuite context=TestDeployVirtioSCSIVM>:setup | `Error` | 0.00 | test_deploy_virtio_scsi_vm.py
   test_nic_secondaryip_add_remove | `Error` | 0.10 | test_multipleips_per_nic.py
   ContextSuite context=TestNestedVirtualization>:setup | `Error` | 0.00 | test_nested_virtualization.py
   ContextSuite context=TestDeployVmWithUserData>:setup | `Error` | 0.00 | test_deploy_vm_with_userdata.py
   ContextSuite context=TestDeployVMsInParallel>:setup | `Error` | 0.00 | test_deploy_vms_in_parallel.py
   ContextSuite context=TestDeployVmWithVariedPlanners>:setup | `Error` | 0.00 | test_deploy_vms_with_varied_deploymentplanners.py
   ContextSuite context=TestRAMCPUResourceAccounting>:setup | `Error` | 0.00 | test_resource_accounting.py
   ContextSuite context=TestPortForwardingRules>:setup | `Error` | 0.00 | test_portforwardingrules.py
   ContextSuite context=TestIpv6Network>:setup | `Error` | 0.00 | test_network_ipv6.py
   ContextSuite context=TestAdapterTypeForNic>:setup | `Error` | 0.00 | test_nic_adapter_type.py
   ContextSuite context=TestDomainsServiceOfferings>:setup | `Error` | 3.53 | test_domain_service_offerings.py
   ContextSuite context=TestPrivateGwACL>:setup | `Error` | 0.00 | test_privategw_acl.py
   ContextSuite context=TestRouterDnsService>:setup | `Error` | 0.00 | test_router_dnsservice.py
   ContextSuite context=TestRouterDHCPHosts>:setup | `Error` | 0.00 | test_router_dhcphosts.py
   ContextSuite context=TestRouterDHCPOpts>:setup | `Error` | 0.00 | test_router_dhcphosts.py
   ContextSuite context=TestProjectSuspendActivate>:setup | `Error` | 8.51 | test_projects.py
   test_01_add_delete_kubernetes_supported_version | `Error` | 0.05 | test_kubernetes_supported_versions.py
   ContextSuite context=TestLoadBalance>:setup | `Error` | 0.00 | test_loadbalance.py
   ContextSuite context=TestListIdsParams>:setup | `Error` | 0.00 | test_list_ids_parameter.py
   ContextSuite context=TestRouterDns>:setup | `Error` | 0.00 | test_router_dns.py
   ContextSuite context=TestRouterServices>:setup | `Error` | 0.00 | test_routers.py
   ContextSuite context=TestMetrics>:setup | `Error` | 0.00 | test_metrics_api.py
   ContextSuite context=TestIsolatedNetworks>:setup | `Error` | 0.00 | test_routers_network_ops.py
   ContextSuite context=TestRedundantIsolateNetworks>:setup | `Error` | 0.00 | test_routers_network_ops.py
   ContextSuite context=TestRouterIpTablesPolicies>:setup | `Error` | 0.00 | test_routers_iptables_default_policy.py
   ContextSuite context=TestVPCIpTablesPolicies>:setup | `Error` | 0.00 | test_routers_iptables_default_policy.py
   ContextSuite context=TestCpuCapServiceOfferings>:setup | `Error` | 0.00 | test_service_offerings.py
   ContextSuite context=TestServiceOfferings>:setup | `Error` | 0.23 | test_service_offerings.py
   ContextSuite context=TestVMWareStoragePolicies>:setup | `Error` | 0.00 | test_storage_policy.py
   test_01_create_template | `Error` | 1.11 | test_templates.py
   test_CreateTemplateWithDuplicateName | `Error` | 1.11 | test_templates.py
   test_02_1_create_template_with_checksum_sha1_negative | `Error` | 0.11 | test_templates.py
   test_02_create_template_with_checksum_sha1 | `Error` | 0.08 | test_templates.py
   test_03_1_create_template_with_checksum_sha256_negative | `Error` | 0.07 | test_templates.py
   test_03_create_template_with_checksum_sha256 | `Error` | 0.07 | test_templates.py
   test_04_1_create_template_with_checksum_md5_negative | `Error` | 0.07 | test_templates.py
   test_04_create_template_with_checksum_md5 | `Error` | 0.08 | test_templates.py
   test_05_create_template_with_no_checksum | `Error` | 0.07 | test_templates.py
   ContextSuite context=TestTemplates>:setup | `Error` | 261.11 | test_templates.py
   test_01_migrate_VM_and_root_volume | `Error` | 83.12 | test_vm_life_cycle.py
   test_02_migrate_VM_with_two_data_disks | `Error` | 51.59 | test_vm_life_cycle.py
   test_10_attachAndDetach_iso | `Error` | 0.07 | test_vm_life_cycle.py
   test_05_vmschedule_test_e2e | `Failure` | 170.59 | test_vm_schedule.py
   


-- 
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


[GitHub] [cloudstack] vishesh92 commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1610721487

   @blueorangutan test


-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1604684775

   @vishesh92 a [SF] Jenkins job has been kicked to build packages. It will be bundled with  KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.


-- 
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


[GitHub] [cloudstack] vishesh92 commented on a diff in pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on code in PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#discussion_r1218934298


##########
test/integration/smoke/test_kubernetes_clusters.py:
##########
@@ -610,7 +615,84 @@ def test_10_vpc_tier_kubernetes_cluster(self):
         k8s_cluster = None
         return
 
-    def createKubernetesCluster(self, name, version_id, size=1, control_nodes=1):
+    @attr(tags=["advanced", "smoke"], required_hardware="false")
+    def test_11_test_unmanaged_cluster_lifecycle(self):
+        """Test all operations on unmanaged Kubernetes cluster
+
+        # Validate the following:
+        # 1. createKubernetesCluster should return valid info for new cluster
+        # 2. The Cloud Database contains the valid information
+        # 3. stopKubernetesCluster doesn't work
+        # 4. startKubernetesCluster doesn't work
+        # 5. upgradeKubernetesCluster doesn't work
+        # 6. Adding & removing vm from cluster works
+        # 7. deleteKubernetesCluster should delete an existing HA Kubernetes cluster
+        """
+        cluster = self.createKubernetesCluster("test-unmanaged-cluster", None,
+                                               cluster_type="ExternalManaged")

Review Comment:
   Agree. Let me setup the environment and test with & without this change.



-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1609262746

   @vishesh92 a [SF] Jenkins job has been kicked to build packages. It will be bundled with  KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.


-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1608303316

   @vishesh92 a [SF] Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests


-- 
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


[GitHub] [cloudstack] vishesh92 commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1572754323

   @blueorangutan test


-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1573381548

   <b>[SF] Trillian test result (tid-6661)</b>
   Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
   Total time taken: 41936 seconds
   Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr7515-t6661-kvm-centos7.zip
   Smoke tests completed. 109 look OK, 1 have errors, 0 did not run
   Only failed and skipped tests results shown below:
   
   
   Test | Result | Time (s) | Test File
   --- | --- | --- | ---
   test_02_upgrade_kubernetes_cluster | `Failure` | 509.38 | test_kubernetes_clusters.py
   test_10_test_unmanaged_cluster_lifecycle | `Error` | 46.78 | test_kubernetes_clusters.py
   ContextSuite context=TestKubernetesCluster>:teardown | `Error` | 156.28 | test_kubernetes_clusters.py
   


-- 
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


[GitHub] [cloudstack] DaanHoogland closed pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland closed pull request #7515: Feature: Add unmanaged kubernetes cluster
URL: https://github.com/apache/cloudstack/pull/7515


-- 
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


[GitHub] [cloudstack] vishesh92 commented on a diff in pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on code in PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#discussion_r1217750718


##########
plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java:
##########
@@ -1342,6 +1507,71 @@ public boolean upgradeKubernetesCluster(UpgradeKubernetesClusterCmd cmd) throws
         return upgradeWorker.upgradeCluster();
     }
 
+    @Override
+    public boolean addVmsToCluster(AddVirtualMachinesToKubernetesClusterCmd cmd) {

Review Comment:
   What kind of validation do you mean here? As per my understanding, the below code takes care of the VM validation (that the uuid of the VM exists). And later on we also check if the user has access to the VM or not.
   
   ```
       @Parameter(name = ApiConstants.VIRTUAL_MACHINE_IDS, type = CommandType.LIST,
               collectionType=CommandType.UUID,
               entityType = UserVmResponse.class,
               required = true,
               description = "the IDs of the VMs to add to the cluster")
   ```



-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1614145312

   @vishesh92 a [SF] Jenkins job has been kicked to build packages. It will be bundled with  KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.


-- 
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


[GitHub] [cloudstack] rohityadavcloud commented on a diff in pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "rohityadavcloud (via GitHub)" <gi...@apache.org>.
rohityadavcloud commented on code in PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#discussion_r1191200018


##########
plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/command/user/kubernetes/cluster/AddVmsToKubernetesClusterCmd.java:
##########
@@ -0,0 +1,108 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.kubernetes.cluster;
+
+import com.cloud.kubernetes.cluster.KubernetesClusterService;
+import com.cloud.utils.exception.CloudRuntimeException;
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.KubernetesClusterResponse;
+import org.apache.cloudstack.api.response.SuccessResponse;
+import org.apache.cloudstack.api.response.UserVmResponse;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
+
+import javax.inject.Inject;
+import java.util.List;
+
+
+@APICommand(name = "addVmsToKubernetesCluster",
+        description = "Add VM to a kubernetes cluster",
+        responseObject = SuccessResponse.class,
+        authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})

Review Comment:
   since/version missing



-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1607174630

   Packaging result [SF]: :heavy_multiplication_x: el7 :heavy_multiplication_x: el8 :heavy_multiplication_x: el9 :heavy_multiplication_x: debian :heavy_multiplication_x: suse15. SL-JID 6337


-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1608204928

   @vishesh92 a [SF] Jenkins job has been kicked to build packages. It will be bundled with  KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.


-- 
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


[GitHub] [cloudstack] rohityadavcloud commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "rohityadavcloud (via GitHub)" <gi...@apache.org>.
rohityadavcloud commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1617538324

   LGTM - smoketests intermittent failures are same as in https://github.com/apache/cloudstack/pull/7344#issuecomment-1616389173
   Merging this based on this and 2x lgtms from others


-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1558877242

   @andrijapanicsb a [LL] Jenkins job has been kicked to build packages. It will be bundled with  KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.


-- 
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


[GitHub] [cloudstack] DaanHoogland commented on a diff in pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on code in PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#discussion_r1205062619


##########
plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java:
##########
@@ -960,6 +1023,9 @@ private void validateKubernetesClusterUpgradeParameters(UpgradeKubernetesCluster
         if (kubernetesCluster == null || kubernetesCluster.getRemoved() != null) {
             throw new InvalidParameterValueException("Invalid Kubernetes cluster ID");
         }
+        if (!kubernetesCluster.getManaged()) {
+            throw new InvalidParameterValueException(String.format("Kubernetes cluster : %s is not managed by Apache CloudStack", kubernetesCluster.getName()));
+        }

Review Comment:
   repetition of the prior block



##########
plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java:
##########
@@ -832,6 +892,9 @@ private void validateKubernetesClusterScaleParameters(ScaleKubernetesClusterCmd
 
         Account caller = CallContext.current().getCallingAccount();
         accountManager.checkAccess(caller, SecurityChecker.AccessType.OperateEntry, false, kubernetesCluster);
+        if (!kubernetesCluster.getManaged()) {
+            throw new InvalidParameterValueException(String.format("Kubernetes cluster %s is not managed by Apache CloudStack", kubernetesCluster.getName()));
+        }

Review Comment:
   the exact same bit of code is used to throw the exact same exception later on. please extract to a method or chencge the messages.



-- 
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


[GitHub] [cloudstack] weizhouapache commented on a diff in pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "weizhouapache (via GitHub)" <gi...@apache.org>.
weizhouapache commented on code in PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#discussion_r1191321686


##########
plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/command/user/kubernetes/cluster/CreateKubernetesClusterCmd.java:
##########
@@ -232,6 +236,13 @@ public Long getNodeRootDiskSize() {
         }
     }
 
+    public boolean getManaged() {
+        if (managed == null) {
+            return true;
+        }
+        return managed;

Review Comment:
   this can be done by just one line



##########
plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/command/user/kubernetes/cluster/AddVirtualMachinesToKubernetesClusterCmd.java:
##########
@@ -0,0 +1,109 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.kubernetes.cluster;
+
+import com.cloud.kubernetes.cluster.KubernetesClusterService;
+import com.cloud.utils.exception.CloudRuntimeException;
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.KubernetesClusterResponse;
+import org.apache.cloudstack.api.response.SuccessResponse;
+import org.apache.cloudstack.api.response.UserVmResponse;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
+
+import javax.inject.Inject;
+import java.util.List;
+
+
+@APICommand(name = "addVirtualMachinesToKubernetesCluster",
+        description = "Add VM to a kubernetes cluster",
+        responseObject = SuccessResponse.class,
+        since = "4.19.0",
+        authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
+public class AddVirtualMachinesToKubernetesClusterCmd extends BaseCmd {
+    public static final Logger LOGGER = Logger.getLogger(AddVirtualMachinesToKubernetesClusterCmd.class.getName());
+
+    @Inject
+    public KubernetesClusterService kubernetesClusterService;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+    @Parameter(name = ApiConstants.ID, type = CommandType.UUID,
+            entityType = KubernetesClusterResponse.class,
+            required = true,
+            description = "the ID of the Kubernetes cluster")
+    private Long id;
+
+    @Parameter(name = ApiConstants.VIRTUAL_MACHINE_IDS, type = CommandType.LIST,
+            collectionType=CommandType.UUID,
+            entityType = UserVmResponse.class,
+            required = true,
+            description = "the ID of the Kubernetes cluster")
+    private List<Long> vmIds;
+
+    @Parameter(name = "isControlNode", type = CommandType.BOOLEAN,
+            description = "Is control node or not? Defaults to false.")
+    private Boolean isControlNode;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    public List<Long> getVmIds() {
+        return vmIds;
+    }
+
+    public boolean isControlNode() {

Review Comment:
   this can be done by just one line



##########
plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/command/user/kubernetes/cluster/RemoveVmsFromKubernetesClusterCmd.java:
##########
@@ -0,0 +1,98 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.kubernetes.cluster;
+
+import com.cloud.kubernetes.cluster.KubernetesClusterService;
+import com.cloud.utils.exception.CloudRuntimeException;
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.KubernetesClusterResponse;
+import org.apache.cloudstack.api.response.SuccessResponse;
+import org.apache.cloudstack.api.response.UserVmResponse;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
+
+import javax.inject.Inject;
+import java.util.List;
+
+
+@APICommand(name = "removeVmsFromKubernetesCluster",
+        description = "Remove VMs from a kubernetes cluster",
+        responseObject = SuccessResponse.class,
+        authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
+public class RemoveVmsFromKubernetesClusterCmd extends BaseCmd {
+    public static final Logger LOGGER = Logger.getLogger(RemoveVmsFromKubernetesClusterCmd.class.getName());
+
+    @Inject
+    public KubernetesClusterService kubernetesClusterService;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+    @Parameter(name = ApiConstants.ID, type = CommandType.UUID,
+            entityType = KubernetesClusterResponse.class,
+            required = true,
+            description = "the ID of the Kubernetes cluster")
+    private Long id;
+
+    @Parameter(name = ApiConstants.VIRTUAL_MACHINE_IDS, type = CommandType.LIST,
+            collectionType=CommandType.UUID,
+            entityType = UserVmResponse.class,
+            required = true,
+            description = "the ID of the Kubernetes cluster")

Review Comment:
   the description needs to be corrected



##########
plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/command/user/kubernetes/cluster/CreateKubernetesClusterCmd.java:
##########
@@ -232,6 +236,13 @@ public Long getNodeRootDiskSize() {
         }
     }
 
+    public boolean getManaged() {

Review Comment:
   it seems `isManaged` is more widely used than `getManaged`



##########
plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/command/user/kubernetes/cluster/RemoveVmsFromKubernetesClusterCmd.java:
##########
@@ -0,0 +1,98 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.user.kubernetes.cluster;
+
+import com.cloud.kubernetes.cluster.KubernetesClusterService;
+import com.cloud.utils.exception.CloudRuntimeException;
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.KubernetesClusterResponse;
+import org.apache.cloudstack.api.response.SuccessResponse;
+import org.apache.cloudstack.api.response.UserVmResponse;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
+
+import javax.inject.Inject;
+import java.util.List;
+
+
+@APICommand(name = "removeVmsFromKubernetesCluster",

Review Comment:
   I have same concern as addVmsToKubernetesCluster



##########
plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/command/user/kubernetes/cluster/StartKubernetesClusterCmd.java:
##########
@@ -99,6 +99,9 @@ public KubernetesCluster validateRequest() {
         if (kubernetesCluster == null) {
             throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Given Kubernetes cluster was not found");
         }
+        if (!kubernetesCluster.getManaged()) {
+            throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Given Kubernetes cluster is not managed by Apache CloudStack");

Review Comment:
   any update on other CKS apis ?
   
   [deleteKubernetesCluster (A)](https://cloudstack.apache.org/api/apidocs-4.18/apis/deleteKubernetesCluster.html)
   [getKubernetesClusterConfig](https://cloudstack.apache.org/api/apidocs-4.18/apis/getKubernetesClusterConfig.html)
   [listKubernetesClusters](https://cloudstack.apache.org/api/apidocs-4.18/apis/listKubernetesClusters.html)
   [scaleKubernetesCluster (A)](https://cloudstack.apache.org/api/apidocs-4.18/apis/scaleKubernetesCluster.html)[startKubernetesCluster (A)](https://cloudstack.apache.org/api/apidocs-4.18/apis/startKubernetesCluster.html)
   [startKubernetesCluster (A)](https://cloudstack.apache.org/api/apidocs-4.18/apis/startKubernetesCluster.html) (done)
   [stopKubernetesCluster (A)](https://cloudstack.apache.org/api/apidocs-4.18/apis/stopKubernetesCluster.html)
   [upgradeKubernetesCluster (A)](https://cloudstack.apache.org/api/apidocs-4.18/apis/upgradeKubernetesCluster.html)



##########
plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java:
##########
@@ -36,17 +37,20 @@
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
+import com.google.common.base.Strings;

Review Comment:
   normally we use StringUtils



-- 
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


[GitHub] [cloudstack] vishesh92 commented on a diff in pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on code in PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#discussion_r1205058477


##########
plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/command/user/kubernetes/cluster/StartKubernetesClusterCmd.java:
##########
@@ -99,6 +99,9 @@ public KubernetesCluster validateRequest() {
         if (kubernetesCluster == null) {
             throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Given Kubernetes cluster was not found");
         }
+        if (!kubernetesCluster.getManaged()) {
+            throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Given Kubernetes cluster is not managed by Apache CloudStack");

Review Comment:
   Done



-- 
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


[GitHub] [cloudstack] vishesh92 commented on a diff in pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on code in PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#discussion_r1205408466


##########
engine/schema/src/main/resources/META-INF/db/schema-41810to41900.sql:
##########
@@ -135,3 +135,7 @@ CREATE VIEW `cloud`.`async_job_view` AS
 UPDATE `cloud`.`console_session` SET removed=now();
 -- Modify acquired column in console_session to datetime type
 ALTER TABLE `cloud`.`console_session` DROP `acquired`, ADD `acquired` datetime COMMENT 'When the session was acquired' AFTER `host_id`;
+
+ALTER TABLE `cloud`.`kubernetes_cluster` ADD COLUMN is_managed tinyint(1) DEFAULT 1;
+
+ALTER TABLE `cloud`.`kubernetes_cluster` MODIFY COLUMN `kubernetes_version_id` bigint unsigned NULL;

Review Comment:
   It's removing the comment. let me fix that.



-- 
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


[GitHub] [cloudstack] vishesh92 commented on a diff in pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on code in PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#discussion_r1217825410


##########
plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java:
##########
@@ -1342,6 +1507,71 @@ public boolean upgradeKubernetesCluster(UpgradeKubernetesClusterCmd cmd) throws
         return upgradeWorker.upgradeCluster();
     }
 
+    @Override
+    public boolean addVmsToCluster(AddVirtualMachinesToKubernetesClusterCmd cmd) {

Review Comment:
   The feature is just to list down VMs which were created by an external kubernetes provider on CloudStack.
   I don't think we can we verify what a user is running within a VM.



-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1558992219

   Packaging result [LL]: :heavy_multiplication_x: el7 :heavy_multiplication_x: el8 :heavy_multiplication_x: el9 :heavy_multiplication_x: debian :heavy_multiplication_x: suse15. SL-JID 6052


-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1571324426

   @vishesh92 a [SF] Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests


-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1572752130

   @vishesh92 a [SF] Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests


-- 
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


[GitHub] [cloudstack] kiranchavala commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "kiranchavala (via GitHub)" <gi...@apache.org>.
kiranchavala commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1598276039

   @blueorangutan package


-- 
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


[GitHub] [cloudstack] DaanHoogland commented on a diff in pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on code in PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#discussion_r1221168973


##########
test/integration/smoke/test_kubernetes_clusters.py:
##########
@@ -622,11 +704,10 @@ def createKubernetesCluster(self, name, version_id, size=1, control_nodes=1):
         createKubernetesClusterCmd.noderootdisksize = 10
         createKubernetesClusterCmd.account = self.account.name
         createKubernetesClusterCmd.domainid = self.domain.id
+        createKubernetesClusterCmd.clustertype = cluster_type
         if self.default_network:
             createKubernetesClusterCmd.networkid = self.default_network.id
         clusterResponse = self.apiclient.createKubernetesCluster(createKubernetesClusterCmd)
-        if not clusterResponse:
-            self.cleanup.append(clusterResponse)

Review Comment:
   ok, makes sense, but 
   @shwstppr the cluster is created here and so it should be destroyed here, or its creation should be moved to class-scope or higher.
   @vishesh92 I think it might be worth adding a base.lib entry for clusters, but ... as said, this is a bit of scope creep. It might however explain the spurious failures on k8s we see in tests runs.



-- 
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


[GitHub] [cloudstack] DaanHoogland commented on a diff in pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on code in PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#discussion_r1221376215


##########
test/integration/smoke/test_kubernetes_clusters.py:
##########
@@ -622,11 +704,10 @@ def createKubernetesCluster(self, name, version_id, size=1, control_nodes=1):
         createKubernetesClusterCmd.noderootdisksize = 10
         createKubernetesClusterCmd.account = self.account.name
         createKubernetesClusterCmd.domainid = self.domain.id
+        createKubernetesClusterCmd.clustertype = cluster_type
         if self.default_network:
             createKubernetesClusterCmd.networkid = self.default_network.id
         clusterResponse = self.apiclient.createKubernetesCluster(createKubernetesClusterCmd)
-        if not clusterResponse:
-            self.cleanup.append(clusterResponse)

Review Comment:
   as discussed with @vishesh92 ofline, he created https://github.com/apache/cloudstack/issues/7604 to address this. cc @shwstppr 



-- 
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


[GitHub] [cloudstack] blueorangutan commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1560666891

   @vishesh92 a [SF] Jenkins job has been kicked to build packages. It will be bundled with  KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.


-- 
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


[GitHub] [cloudstack] vishesh92 commented on pull request #7515: Feature: Add unmanaged kubernetes cluster

Posted by "vishesh92 (via GitHub)" <gi...@apache.org>.
vishesh92 commented on PR #7515:
URL: https://github.com/apache/cloudstack/pull/7515#issuecomment-1563526286

   @blueorangutan package


-- 
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