Skip to content

Commit

Permalink
ci: e2e aks
Browse files Browse the repository at this point in the history
  • Loading branch information
fra98 committed Feb 27, 2025
1 parent fd85e73 commit 017b9d4
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 28 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,14 @@ E2E_TARGETS = e2e-dir \
ctl \
e2e-infra \
installer/kyverno/install \
installer/liqoctl/setup \
installer/liqo/setup \
telemetry \
installer/liqoctl/peer \
installer/liqo/peer \
e2e/postinstall \
e2e/cruise \
metrics \
installer/liqoctl/unpeer \
installer/liqoctl/uninstall \
installer/liqo/unpeer \
installer/liqo/uninstall \
e2e/postuninstall

# Export these variables before to run the e2e tests
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/cruise/network/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ var _ = BeforeSuite(func() {

switch testContext.Infrastructure {
case "kubeadm":
overrideArgsClusterAPI(&defaultArgs)
overrideArgsKubeadm(&defaultArgs)
case "k3s":
overrideArgsK3s(&defaultArgs)
case "kind":
Expand Down Expand Up @@ -266,7 +266,7 @@ func overrideArgsFlannel(args *networkTestsArgs) {
args.nodePortNodes = networkflags.NodePortNodesWorkers
}

func overrideArgsClusterAPI(args *networkTestsArgs) {
func overrideArgsKubeadm(args *networkTestsArgs) {
args.loadBalancer = false
}

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

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

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


# Cleaning all remaining clusters

PIDS=()
for i in $(seq 1 "${CLUSTER_NUMBER}")
do
AKS_RESOURCE_GROUP="liqo${i}"
Expand All @@ -41,7 +49,7 @@ do
az aks delete --resource-group "${AKS_RESOURCE_GROUP}" --name "${CLUSTER_NAME}" --yes &
PIDS+=($!)
else
echo "Cluster ${CLUSTER_NAME}${i} does not exist"
echo "Cluster ${CLUSTER_NAME} does not exist"
fi
done

Expand All @@ -50,6 +58,8 @@ for PID in "${PIDS[@]}"; do
done

# Cleaning the resource group

PIDS=()
for i in $(seq 1 "${CLUSTER_NUMBER}")
do
AKS_RESOURCE_GROUP="liqo${i}"
Expand Down
18 changes: 3 additions & 15 deletions test/e2e/pipeline/infra/aks/pre-requirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,6 @@ install_kubectl "${OS}" "${ARCH}" "${K8S_VERSION}"

install_helm "${OS}" "${ARCH}"

# Install AZ cli
if ! command -v az &> /dev/null
then
echo "Azure CLI could not be found. Downloading and installing..."
if [[ "${OS}" == "linux" ]]
then
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
elif [[ "${OS}" == "darwin" ]]
then
brew update && brew install azure-cli
fi
fi

echo "Azure CLI version:"
az --version
install_az "${OS}"

login_az "${AZ_USERNAME}" "${AZ_KEY}" "${AZ_TENANT_ID}"
16 changes: 13 additions & 3 deletions test/e2e/pipeline/infra/aks/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ VM_TYPE="Standard_B2s"
REGIONS=("italynorth" "francecentral" "germanywestcentral" "switzerlandnorth")

POD_CIDR_OVERLAPPING=${POD_CIDR_OVERLAPPING:-"true"}
CNI=${CNI:-"azure"} # "azure", "kubenet", "none"
CNI=${CNI:-"azure-overlay"} # "azure-overlay", "azure-flat", "kubenet", "none"

if [[ "${CNI}" == "azure" ]]; then
if [[ "${CNI}" == "azure-flat" || "${CNI}" == "azure-overlay" ]]; then
POD_CIDR_OVERLAPPING="true"
fi

Expand Down Expand Up @@ -75,12 +75,22 @@ function aks_create_cluster() {
args+=("--tier free")
args+=("--generate-ssh-keys")

args+=("--network-plugin $CNI")
if [[ "${CNI}" == "azure-flat" || "${CNI}" == "azure-overlay" ]]; then
args+=("--network-plugin azure")
else
args+=("--network-plugin $CNI")
fi

if [[ "${CNI}" == "azure-overlay" ]]; then
args+=("--network-plugin-mode overlay")
fi

if [[ "${CNI}" == "kubenet" ]]; then
args+=("--pod-cidr $pod_cidr")
fi

ARGS="${args[*]}"
echo "Running: az aks create $ARGS"
eval "az aks create $ARGS"

az aks get-credentials \
Expand Down
33 changes: 31 additions & 2 deletions test/e2e/pipeline/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ function check_supported_arch_and_os(){

function forge_clustername() {
local index=$1
RUNNER_NAME=$(echo "${RUNNER_NAME}" | tr -d ' ' | tr '[:upper:]' '[:lower:]')
RUNNER_NAME=${RUNNER_NAME:-"test"}
RUNNER_NAME=${RUNNER_NAME#liqo-runner-*-}
local BASE_CLUSTER_NAME="cl-${RUNNER_NAME}-"
Expand All @@ -90,6 +91,7 @@ function install_kubectl() {
if ! command -v "${KUBECTL}" &> /dev/null
then
echo "WARNING: kubectl could not be found. Downloading and installing it locally..."
echo "Downloading https://dl.k8s.io/release/${version}/bin/${os}/${arch}/kubectl"
if ! curl --fail -Lo "${KUBECTL}" "https://dl.k8s.io/release/${version}/bin/${os}/${arch}/kubectl"; then
echo "Error: Unable to download kubectl for '${os}-${arch}'"
return 1
Expand Down Expand Up @@ -156,9 +158,36 @@ function install_gcloud() {
cd -

#Login to gcloud
echo "${GCLOUD_KEY}" | base64 -d > "${GCLOUD_KEY_FILE}"
echo "${GCLOUD_KEY}" | base64 -d > "${BINDIR}/gke_key_file.json"
"${GCLOUD}" auth activate-service-account --key-file="${BINDIR}/gke_key_file.json"
"${GCLOUD}" config set project "${GCLOUD_PROJECT_ID}" -q
"${GCLOUD}" components install gke-gcloud-auth-plugin
}

function install_az() {
local os=$1

if ! command -v az &> /dev/null
then
echo "Azure CLI could not be found. Downloading and installing..."
if [[ "${os}" == "linux" ]]
then
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
elif [[ "${os}" == "darwin" ]]
then
brew update && brew install azure-cli
fi
fi

echo "Azure CLI version:"
az --version
}

function login_az() {
local username=$1
local key=$2
local tenant_id=$3

az login --service-principal --username "${username}" --password "${key}" --tenant "${tenant_id}"
}

function install_kyverno() {
Expand Down

0 comments on commit 017b9d4

Please sign in to comment.