From 1692df421c94eed4a40e5a03a3f7f8794b359464 Mon Sep 17 00:00:00 2001 From: Pearl Dsilva Date: Thu, 19 Nov 2020 04:51:57 +0530 Subject: [PATCH 1/5] cks: Fix destroying k8s cluster on shared networks (#4461) * Fix destroying k8s cluster on shared networks * Extracted code Co-authored-by: Pearl Dsilva --- .../actionworkers/KubernetesClusterDestroyWorker.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterDestroyWorker.java b/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterDestroyWorker.java index 41de39fddc2..c9f42d87134 100644 --- a/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterDestroyWorker.java +++ b/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterDestroyWorker.java @@ -37,6 +37,7 @@ import com.cloud.kubernetes.cluster.KubernetesClusterVO; import com.cloud.kubernetes.cluster.KubernetesClusterVmMap; import com.cloud.kubernetes.cluster.KubernetesClusterVmMapVO; import com.cloud.network.IpAddress; +import com.cloud.network.Network; import com.cloud.network.dao.NetworkVO; import com.cloud.network.rules.FirewallRule; import com.cloud.user.Account; @@ -187,6 +188,13 @@ public class KubernetesClusterDestroyWorker extends KubernetesClusterResourceMod } } + private void checkForRulesToDelete() throws ManagementServerException { + NetworkVO kubernetesClusterNetwork = networkDao.findById(kubernetesCluster.getNetworkId()); + if (kubernetesClusterNetwork != null && kubernetesClusterNetwork.getGuestType() != Network.GuestType.Shared) { + deleteKubernetesClusterNetworkRules(); + } + } + public boolean destroy() throws CloudRuntimeException { init(); validateClusterSate(); @@ -238,7 +246,7 @@ public class KubernetesClusterDestroyWorker extends KubernetesClusterResourceMod } } else { try { - deleteKubernetesClusterNetworkRules(); + checkForRulesToDelete(); } catch (ManagementServerException e) { String msg = String.format("Failed to remove network rules of Kubernetes cluster ID: %s", kubernetesCluster.getUuid()); LOGGER.warn(msg, e); From a3f2ee431f1a4e91729cbb435dad0ed3322204f7 Mon Sep 17 00:00:00 2001 From: davidjumani Date: Fri, 20 Nov 2020 13:39:41 +0530 Subject: [PATCH 2/5] Fixing misleading HostMetricsResponse param description (#4485) --- .../org/apache/cloudstack/response/HostMetricsResponse.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/metrics/src/main/java/org/apache/cloudstack/response/HostMetricsResponse.java b/plugins/metrics/src/main/java/org/apache/cloudstack/response/HostMetricsResponse.java index a7446af98a5..484cd068945 100644 --- a/plugins/metrics/src/main/java/org/apache/cloudstack/response/HostMetricsResponse.java +++ b/plugins/metrics/src/main/java/org/apache/cloudstack/response/HostMetricsResponse.java @@ -48,15 +48,15 @@ public class HostMetricsResponse extends HostResponse { private Double loadAverage; @SerializedName("memorytotalgb") - @Param(description = "the total cpu capacity in GiB") + @Param(description = "the total memory capacity in GiB") private String memTotal; @SerializedName("memoryusedgb") - @Param(description = "the total cpu used in GiB") + @Param(description = "the total memory used in GiB") private String memUsed; @SerializedName("memoryallocatedgb") - @Param(description = "the total cpu allocated in GiB") + @Param(description = "the total memory allocated in GiB") private String memAllocated; @SerializedName("networkread") From 1398dfff65df5251cf378ae9f752fbe04787c4a0 Mon Sep 17 00:00:00 2001 From: davidjumani Date: Fri, 20 Nov 2020 13:49:26 +0530 Subject: [PATCH 3/5] createkubertetesbinariesiso: Saving images in network and dashboard yaml (#4459) --- .../util/create-kubernetes-binaries-iso.sh | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/scripts/util/create-kubernetes-binaries-iso.sh b/scripts/util/create-kubernetes-binaries-iso.sh index d7d9c16310d..e8ad0e57366 100755 --- a/scripts/util/create-kubernetes-binaries-iso.sh +++ b/scripts/util/create-kubernetes-binaries-iso.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -x # 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 @@ -16,9 +16,11 @@ # specific language governing permissions and limitations # under the License. +set -e + if [ $# -lt 6 ]; then - echo "Invalid input. Valid usage: ./create-kubernetes-binaries-iso.sh OUTPUT_PATH KUBERNETES_VERSION CNI_VERSION CRICTL_VERSION WEAVENET_NETWORK_YAML_CONFIG DASHBOARD_YAML_CONFIG" - echo "eg: ./create-kubernetes-binaries-iso.sh ./ 1.11.4 0.7.1 1.11.1 https://github.com/weaveworks/weave/releases/download/latest_release/weave-daemonset-k8s-1.11.yaml https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.0/src/deploy/recommended/kubernetes-dashboard.yaml" + echo "Invalid input. Valid usage: ./create-kubernetes-binaries-iso.sh OUTPUT_PATH KUBERNETES_VERSION CNI_VERSION CRICTL_VERSION WEAVENET_NETWORK_YAML_CONFIG DASHBOARD_YAML_CONFIG BUILD_NAME" + echo "eg: ./create-kubernetes-binaries-iso.sh ./ 1.11.4 0.7.1 1.11.1 https://github.com/weaveworks/weave/releases/download/latest_release/weave-daemonset-k8s-1.11.yaml https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.0/src/deploy/recommended/kubernetes-dashboard.yaml setup-v1.11.4" exit 1 fi @@ -28,6 +30,8 @@ start_dir="$PWD" iso_dir="/tmp/iso" working_dir="${iso_dir}/" mkdir -p "${working_dir}" +build_name="${7}.iso" +[ -z "${build_name}" ] && build_name="setup-${RELEASE}.iso" CNI_VERSION="v${3}" echo "Downloading CNI ${CNI_VERSION}..." @@ -50,7 +54,7 @@ kubeadm_file_permissions=`stat --format '%a' kubeadm` chmod +x kubeadm echo "Downloading kubelet.service ${RELEASE}..." -cd $start_dir +cd "${start_dir}" kubelet_service_file="${working_dir}/kubelet.service" touch "${kubelet_service_file}" curl -sSL "https://raw.githubusercontent.com/kubernetes/kubernetes/${RELEASE}/build/debs/kubelet.service" | sed "s:/usr/bin:/opt/bin:g" > ${kubelet_service_file} @@ -87,6 +91,14 @@ if [ $? -ne 0 ]; then fi mkdir -p "${working_dir}/docker" output=`${k8s_dir}/kubeadm config images list --kubernetes-version=${RELEASE}` + +# Don't forget about the yaml images ! +for i in ${network_conf_file} ${dashboard_conf_file} +do + images=`grep "image:" $i | cut -d ':' -f2- | tr -d ' ' | tr -d "'"` + output=`printf "%s\n" ${output} ${images}` +done + while read -r line; do echo "Downloading docker image $line ---" sudo docker pull "$line" @@ -96,11 +108,11 @@ while read -r line; do done <<< "$output" echo "Restore kubeadm permissions..." -if [ "${kubeadm_file_permissions}" -eq "" ]; then +if [ -z "${kubeadm_file_permissions}" ]; then kubeadm_file_permissions=644 fi chmod ${kubeadm_file_permissions} "${working_dir}/k8s/kubeadm" -mkisofs -o "${output_dir}/setup-${RELEASE}.iso" -J -R -l "${iso_dir}" +mkisofs -o "${output_dir}/${build_name}" -J -R -l "${iso_dir}" rm -rf "${iso_dir}" From 584fc3a3389135d6ad7dd0d655ff72844d88f015 Mon Sep 17 00:00:00 2001 From: davidjumani Date: Fri, 20 Nov 2020 13:58:06 +0530 Subject: [PATCH 4/5] accountresponse: Fix domainpath description (#4487) --- .../org/apache/cloudstack/api/response/AccountResponse.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/src/main/java/org/apache/cloudstack/api/response/AccountResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/AccountResponse.java index e39aaca3767..d22ee52b5c0 100644 --- a/api/src/main/java/org/apache/cloudstack/api/response/AccountResponse.java +++ b/api/src/main/java/org/apache/cloudstack/api/response/AccountResponse.java @@ -55,15 +55,15 @@ public class AccountResponse extends BaseResponse implements ResourceLimitAndCou private String roleName; @SerializedName(ApiConstants.DOMAIN_ID) - @Param(description = "id of the Domain the account belongs too") + @Param(description = "id of the Domain the account belongs to") private String domainId; @SerializedName(ApiConstants.DOMAIN) - @Param(description = "name of the Domain the account belongs too") + @Param(description = "name of the Domain the account belongs to") private String domainName; @SerializedName(ApiConstants.DOMAIN_PATH) - @Param(description = "name of the Domain the account belongs too", since = "4.13") + @Param(description = "path of the Domain the account belongs to", since = "4.13") private String domainPath; @SerializedName(ApiConstants.DEFAULT_ZONE_ID) From daec77f2ef9aa2dc1aa115fbdc517c4a96fb972b Mon Sep 17 00:00:00 2001 From: Pearl Dsilva Date: Fri, 20 Nov 2020 14:03:06 +0530 Subject: [PATCH 5/5] Fix k8s cluster upgrade in shared networks (#4458) Co-authored-by: Pearl Dsilva --- .../cluster/actionworkers/KubernetesClusterUpgradeWorker.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterUpgradeWorker.java b/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterUpgradeWorker.java index eb9058d765d..0ef624ab56a 100644 --- a/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterUpgradeWorker.java +++ b/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterUpgradeWorker.java @@ -78,7 +78,7 @@ public class KubernetesClusterUpgradeWorker extends KubernetesClusterActionWorke index == 0 ? "true" : "false", KubernetesVersionManagerImpl.compareSemanticVersions(upgradeVersion.getSemanticVersion(), "1.15.0") < 0 ? "true" : "false", Hypervisor.HypervisorType.VMware.equals(vm.getHypervisorType())); - return SshHelper.sshExecute(publicIpAddress, nodeSshPort, CLUSTER_NODE_VM_USER, sshKeyFile, null, + return SshHelper.sshExecute(nodeAddress, nodeSshPort, CLUSTER_NODE_VM_USER, sshKeyFile, null, cmdStr, 10000, 10000, 10 * 60 * 1000); }