8000 [Test] e2e plugin for gke by cheina97 · Pull Request #2651 · liqotech/liqo · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[Test] e2e plugin for gke #2651

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions test/e2e/cruise/network/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ func overrideArgsGKE(args *networkTestsArgs) {
args.failfast = false
args.loadBalancer = true
args.nodePortExt = false // nodeport are not exposed by default // TODO: modify GKE plugin to open nodeport firewall
args.podNodePort = false
args.ip = false
}

func overrideArgsAKS(args *networkTestsArgs) {
Expand Down
13 changes: 4 additions & 9 deletions test/e2e/pipeline/infra/aks/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,18 @@ error() {
}
trap 'error "${BASH_SOURCE}" "${LINENO}"' ERR

CLUSTER_NAME=cluster
RUNNER_NAME=${RUNNER_NAME:-"test"}
CLUSTER_NAME="${RUNNER_NAME}-${CLUSTER_NAME}"

PIDS=()

# Cleaning all remaining clusters
for i in $(seq 1 "${CLUSTER_NUMBER}")
do
AKS_RESOURCE_GROUP="liqo${i}"
RUNNER_NAME=${RUNNER_NAME:-"test"}
AKS_CLUSTER_NAME="${RUNNER_NAME}-cluster${i}"
CLUSTER_NAME=$(forge_clustername "${i}")

# if the cluster exists, delete it
if az aks show --resource-group "${AKS_RESOURCE_GROUP}" --name "${AKS_CLUSTER_NAME}" &> /dev/null; then
echo "Deleting cluster ${CLUSTER_NAME}${i}"
az aks delete --resource-group "${AKS_RESOURCE_GROUP}" --name "${AKS_CLUSTER_NAME}" --yes &
if az aks show --resource-group "${AKS_RESOURCE_GROUP}" --name "${CLUSTER_NAME}" &> /dev/null; then
echo "Deleting cluster ${CLUSTER_NAME}"
az aks delete --resource-group "${AKS_RESOURCE_GROUP}" --name "${CLUSTER_NAME}" --yes &
PIDS+=($!)
else
echo "Cluster ${CLUSTER_NAME}${i} does not exist"
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/pipeline/infra/aks/pre-requirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ trap 'error "${BASH_SOURCE}" "${LINENO}"' ERR
FILEPATH=$(realpath "$0")
WORKDIR=$(dirname "$FILEPATH")

# shellcheck disable=SC1091
# shellcheck source=../../utils.sh
source "$WORKDIR/../../utils.sh"

setup_arch_and_os
Expand Down
5 changes: 3 additions & 2 deletions test/e2e/pipeline/infra/aks/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ trap 'error "${BASH_SOURCE}" "${LINENO}"' ERR
FILEPATH=$(realpath "$0")
WORKDIR=$(dirname "$FILEPATH")

# shellcheck disable=SC1091
# shellcheck source=../../utils.sh
source "$WORKDIR/../../utils.sh"

NUM_NODES="2"
Expand Down Expand Up @@ -93,8 +95,7 @@ PIDS=()
for i in $(seq 1 "${CLUSTER_NUMBER}");
do
AKS_RESOURCE_GROUP="liqo${i}"
RUNNER_NAME=${RUNNER_NAME:-"test"}
AKS_CLUSTER_NAME="${RUNNER_NAME}-cluster${i}"
AKS_CLUSTER_NAME=$(forge_clustername "${i}")
REGION=${REGIONS[$i-1]}
KUBECONFIG="${TMPDIR}/kubeconfigs/liqo_kubeconf_${i}"

Expand Down
12 changes: 8 additions & 4 deletions test/e2e/pipeline/infra/cluster-api/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@ error() {
}
trap 'error "${BASH_SOURCE}" "${LINENO}"' ERR

CLUSTER_NAME=cluster
RUNNER_NAME=${RUNNER_NAME:-"test"}
CAPI_CLUSTER_NAME="${RUNNER_NAME}-${CLUSTER_NAME}"
FILEPATH=$(realpath "$0")
WORKDIR=$(dirname "$FILEPATH")

# shellcheck disable=SC1091
# shellcheck source=../../utils.sh
source "$WORKDIR/../../utils.sh"

# Cleaning all remaining clusters
for i in $(seq 1 "${CLUSTER_NUMBER}")
do
${KUBECTL} delete clusters.cluster.x-k8s.io --namespace=liqo-ci "${CAPI_CLUSTER_NAME}${i}" --ignore-not-found
CAPI_CLUSTER_NAME=$(forge_clustername "${i}")
${KUBECTL} delete clusters.cluster.x-k8s.io --namespace=liqo-ci "${CAPI_CLUSTER_NAME}" --ignore-not-found
done
2 changes: 2 additions & 0 deletions test/e2e/pipeline/infra/cluster-api/cni.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
FILEPATH=$(realpath "$0")
WORKDIR=$(dirname "$FILEPATH")

# shellcheck disable=SC1091
# shellcheck source=./pre-requirements.sh
source "$WORKDIR/pre-requirements.sh"

# shellcheck disable=SC1091
# shellcheck source=../../utils.sh
source "$WORKDIR/../../utils.sh"

Expand Down
1 change: 1 addition & 0 deletions test/e2e/pipeline/infra/cluster-api/pre-requirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ trap 'error "${BASH_SOURCE}" "${LINENO}"' ERR
FILEPATH=$(realpath "$0")
WORKDIR=$(dirname "$FILEPATH")

# shellcheck disable=SC1091
# shellcheck source=../../utils.sh
source "$WORKDIR/../../utils.sh"

Expand Down
25 changes: 12 additions & 13 deletions test/e2e/pipeline/infra/cluster-api/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ trap 'error "${BASH_SOURCE}" "${LINENO}"' ERR
FILEPATH=$(realpath "$0")
WORKDIR=$(dirname "$FILEPATH")

# shellcheck disable=SC1091
# shellcheck source=../../utils.sh
source "$WORKDIR/../../utils.sh"

# shellcheck disable=SC1091
# shellcheck source=./cni.sh
source "$WORKDIR/cni.sh"

CLUSTER_NAME=cluster

export K8S_VERSION=${K8S_VERSION:-"1.29.7"}
K8S_VERSION=$(echo -n "$K8S_VERSION" | sed 's/v//g') # remove the leading v

Expand All @@ -56,20 +56,18 @@ export POD_CIDR_OVERLAPPING=${POD_CIDR_OVERLAPPING:-"false"}

TARGET_NAMESPACE="liqo-ci"

RUNNER_NAME=${RUNNER_NAME:-"test"}
CAPI_CLUSTER_NAME="${RUNNER_NAME}-${CLUSTER_NAME}"

for i in $(seq 1 "${CLUSTER_NUMBER}");
do
CAPI_CLUSTER_NAME=$(forge_clustername "${i}")
if [[ ${POD_CIDR_OVERLAPPING} != "true" ]]; then
# this should avoid the ipam to reserve a pod CIDR of another cluster as local external CIDR causing remapping
export POD_CIDR="10.$((i * 10)).0.0/16"
fi
echo "Creating cluster ${CLUSTER_NAME}${i}"
echo "Creating cluster ${CAPI_CLUSTER_NAME}"
POD_CIDR_ESC_1=$(echo $POD_CIDR | cut -d'/' -f1)
POD_CIDR_ESC_2=$(echo $POD_CIDR | cut -d'/' -f2)
POD_CIDR_ESC="${POD_CIDR_ESC_1}\/${POD_CIDR_ESC_2}"
clusterctl generate cluster "${CAPI_CLUSTER_NAME}${i}" \
clusterctl generate cluster "${CAPI_CLUSTER_NAME}" \
--kubernetes-version "$K8S_VERSION" \
--control-plane-machine-count 1 \
--worker-machine-count 2 \
Expand All @@ -79,21 +77,22 @@ done

for i in $(seq 1 "${CLUSTER_NUMBER}");
do
CAPI_CLUSTER_NAME=$(forge_clustername "${i}")
if [[ ${POD_CIDR_OVERLAPPING} != "true" ]]; then
# this should avoid the ipam to reserve a pod CIDR of another cluster as local external CIDR causing remapping
export POD_CIDR="10.$((i * 10)).0.0/16"
fi
echo "Waiting for cluster ${CLUSTER_NAME}${i} to be ready"
"${KUBECTL}" wait --for condition=Ready=true -n "$TARGET_NAMESPACE" "clusters.cluster.x-k8s.io/${CAPI_CLUSTER_NAME}${i}" --timeout=-1s
echo "Waiting for cluster ${CAPI_CLUSTER_NAME} to be ready"
"${KUBECTL}" wait --for condition=Ready=true -n "$TARGET_NAMESPACE" "clusters.cluster.x-k8s.io/${CAPI_CLUSTER_NAME}" --timeout=-1s

echo "Getting kubeconfig for cluster ${CLUSTER_NAME}${i}"
echo "Getting kubeconfig for cluster ${CAPI_CLUSTER_NAME}"
mkdir -p "${TMPDIR}/kubeconfigs"
clusterctl get kubeconfig -n "$TARGET_NAMESPACE" "${CAPI_CLUSTER_NAME}${i}" > "${TMPDIR}/kubeconfigs/liqo_kubeconf_${i}"
clusterctl get kubeconfig -n "$TARGET_NAMESPACE" "${CAPI_CLUSTER_NAME}" > "${TMPDIR}/kubeconfigs/liqo_kubeconf_${i}"

CURRENT_CONTEXT=$("${KUBECTL}" config current-context --kubeconfig "${TMPDIR}/kubeconfigs/liqo_kubeconf_${i}")
"${KUBECTL}" config set contexts."${CURRENT_CONTEXT}".namespace default --kubeconfig "${TMPDIR}/kubeconfigs/liqo_kubeconf_${i}"

echo "Installing ${CNI} for cluster ${CLUSTER_NAME}${i}"
echo "Installing ${CNI} for cluster ${CAPI_CLUSTER_NAME}"
"install_${CNI}" "${TMPDIR}/kubeconfigs/liqo_kubeconf_${i}"

# install local-path storage class
Expand All @@ -105,6 +104,6 @@ done

for i in $(seq 1 "${CLUSTER_NUMBER}");
do
echo "Waiting for cluster ${CLUSTER_NAME}${i} CNI to be ready"
echo "Waiting for cluster ${CAPI_CLUSTER_NAME} CNI to be ready"
"wait_${CNI}" "${TMPDIR}/kubeconfigs/liqo_kubeconf_${i}"
done
18 changes: 11 additions & 7 deletions test/e2e/pipeline/infra/eks/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,27 @@ error() {
}
trap 'error "${BASH_SOURCE}" "${LINENO}"' ERR

CLUSTER_NAME=cluster
RUNNER_NAME=${RUNNER_NAME:-"test"}
CLUSTER_NAME="${RUNNER_NAME}-${CLUSTER_NAME}"
FILEPATH=$(realpath "$0")
WORKDIR=$(dirname "$FILEPATH")

# shellcheck disable=SC1091
# shellcheck source=../../utils.sh
source "$WORKDIR/../../utils.sh"

PIDS=()

# Cleaning all remaining clusters
for i in $(seq 1 "${CLUSTER_NUMBER}")
do
CLUSTER_NAME=$(forge_clustername "${i}")
# if the cluster exists, delete it
if "${EKSCTL}" get cluster --name "${CLUSTER_NAME}${i}" --region "eu-central-1" &> /dev/null; then
echo "Deleting cluster ${CLUSTER_NAME}${i}"
if "${EKSCTL}" get cluster --name "${CLUSTER_NAME}" --region "eu-central-1" &> /dev/null; then
echo "Deleting cluster ${CLUSTER_NAME}"
else
echo "Cluster ${CLUSTER_NAME}${i} does not exist"
echo "Cluster ${CLUSTER_NAME} does not exist"
continue
fi
"${EKSCTL}" delete cluster --name "${CLUSTER_NAME}${i}" --region "eu-central-1" --wait --force &
"${EKSCTL}" delete cluster --name "${CLUSTER_NAME}" --region "eu-central-1" --wait --force &
PIDS+=($!)
done

Expand Down
1 change: 1 addition & 0 deletions test/e2e/pipeline/infra/eks/pre-requirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ trap 'error "${BASH_SOURCE}" "${LINENO}"' ERR
FILEPATH=$(realpath "$0")
WORKDIR=$(dirname "$FILEPATH")

# shellcheck disable=SC1091
# shellcheck source=../../utils.sh
source "$WORKDIR/../../utils.sh"

Expand Down
12 changes: 6 additions & 6 deletions test/e2e/pipeline/infra/eks/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ trap 'error "${BASH_SOURCE}" "${LINENO}"' ERR
FILEPATH=$(realpath "$0")
WORKDIR=$(dirname "$FILEPATH")

# shellcheck disable=SC1091
# shellcheck source=../../utils.sh
source "$WORKDIR/../../utils.sh"

Expand All @@ -43,19 +44,17 @@ CLUSTER_NAME=cluster
export POD_CIDR=10.200.0.0/16
export POD_CIDR_OVERLAPPING=${POD_CIDR_OVERLAPPING:-"false"}

RUNNER_NAME=${RUNNER_NAME:-"test"}
CLUSTER_NAME="${RUNNER_NAME}-${CLUSTER_NAME}"

PIDS=()

for i in $(seq 1 "${CLUSTER_NUMBER}");
do
CLUSTER_NAME=$(forge_clustername "${i}")
if [[ ${POD_CIDR_OVERLAPPING} != "true" ]]; then
export POD_CIDR="10.$((i * 10)).0.0/16"
fi
echo "Creating cluster ${CLUSTER_NAME}${i}"
echo "Creating cluster ${CLUSTER_NAME}"
"${EKSCTL}" create cluster \
--name "${CLUSTER_NAME}${i}" \
--name "${CLUSTER_NAME}" \
--region "eu-central-1" \
--instance-types c4.large,c5.large \
--nodes 2 \
Expand All @@ -73,6 +72,7 @@ done

for i in $(seq 1 "${CLUSTER_NUMBER}");
do
CLUSTER_NAME=$(forge_clustername "${i}")
CURRENT_CONTEXT=$("${KUBECTL}" config current-context --kubeconfig "${TMPDIR}/kubeconfigs/liqo_kubeconf_${i}")
"${KUBECTL}" config set contexts."${CURRENT_CONTEXT}".namespace default --kubeconfig "${TMPDIR}/kubeconfigs/liqo_kubeconf_${i}"

Expand All @@ -87,6 +87,6 @@ do
"${HELM}" repo update
"${HELM}" install aws-load-balancer-controller eks/aws-load-balancer-controller \
-n kube-system \
--set clusterName="${CLUSTER_NAME}${i}" \
--set clusterName="${CLUSTER_NAME}" \
--kubeconfig "${TMPDIR}/kubeconfigs/liqo_kubeconf_${i}"
done
57 changes: 57 additions & 0 deletions test/e2e/pipeline/infra/gke/clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash

# This scripts expects the following variables to be set:
# CLUSTER_NUMBER -> the number of liqo clusters
# K8S_VERSION -> the Kubernetes version
# CNI -> the CNI plugin used
# TMPDIR -> the directory where the test-related files are stored
# BINDIR -> the directory where the test-related binaries are stored
# TEMPLATE_DIR -> the directory where to read the cluster templates
# NAMESPACE -> the namespace where liqo is running
# KUBECONFIGDIR -> the directory where the kubeconfigs are stored
# LIQO_VERSION -> the liqo version to test
# INFRA -> the Kubernetes provider for the infrastructure
# LIQOCTL -> the path where liqoctl is stored
# KUBECTL -> the path where kubectl is stored
# POD_CIDR_OVERLAPPING -> the pod CIDR of the clusters is overlapping
# CLUSTER_TEMPLATE_FILE -> the file where the cluster template is stored

set -e # Fail in case of error
set -o nounset # Fail if undefined variables are used
set -o pipefail # Fail if one of the piped commands fails

error() {
local sourcefile=$1
local lineno=$2
echo "An error occurred at $sourcefile:$lineno."
}
trap 'error "${BASH_SOURCE}" "${LINENO}"' ERR

FILEPATH=$(realpath "$0")
WORKDIR=$(dirname "$FILEPATH")

# shellcheck disable=SC1091
# shellcheck source=../../utils.sh
source "$WORKDIR/../../utils.sh"

# shellcheck disable=SC1091
# shellcheck source=./const.sh
source "$WORKDIR/const.sh"

PIDS=()
for i in $(seq 1 "${CLUSTER_NUMBER}");
do
GKE_CLUSTER_ID=$(forge_clustername "${i}")
GKE_CLUSTER_ZONE=${GKE_ZONES[$i-1]}

echo "Deleting cluster ${GKE_CLUSTER_ID}"
if gcloud container clusters describe "${GKE_CLUSTER_ID}" --zone "${GKE_CLUSTER_ZONE}" --project "${GCLOUD_PROJECT_ID}" &> /dev/null; then
"${GCLOUD}" container clusters delete "${GKE_CLUSTER_ID}" --zone "${GKE_CLUSTER_ZONE}" --project "${GCLOUD_PROJECT_ID}" --quiet &
PIDS+=($!)
fi
done

# Delete GKE clusters
for PID in "${PIDS[@]}"; do
wait "$PID"
done
22 changes: 22 additions & 0 deletions test/e2e/pipeline/infra/gke/const.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

export GKE_REGIONS=(
"europe-west1"
"europe-west2"
"europe-west3"
)
export GKE_ZONES=(
"europe-west1-c"
"europe-west2-b"
"europe-west3-a"
)

# General
export GKE_NUM_NODES="2"
export GKE_MACHINE_TYPE="e2-standard-2" # "e2-micro", "e2-small", "e2-medium", "e2-standard-2", "e2-standard-4"
export GKE_IMAGE_TYPE="UBUNTU_CONTAINERD" # "COS_CONTAINERD", "UBUNTU_CONTAINERD"
export GKE_DISK_TYPE="pd-balanced"
export GKE_DISK_SIZE="10"
export GKE_DATAPLANE="v1" # "v1", "v2"

#####################
Loading
0