From ba2dd9853a401ad0a04b7860a5294643a0c5585d Mon Sep 17 00:00:00 2001 From: sushrk Date: Mon, 26 Aug 2024 19:35:20 +0000 Subject: [PATCH 1/3] Add security group pods scale test in ginkgo --- scripts/test/create-cluster-karpenter.sh | 147 ++++++++++++++++++ scripts/test/delete-cluster-karpenter.sh | 23 +++ test/framework/resource/aws/ec2/manager.go | 17 ++ test/framework/utils/resource.go | 1 + .../perpodsg/perpodsg_suite_test.go | 25 +-- test/integration/scale/pod_scale_test.go | 89 +++++++++++ test/integration/scale/scale_suite_test.go | 57 +++++++ 7 files changed, 338 insertions(+), 21 deletions(-) create mode 100755 scripts/test/create-cluster-karpenter.sh create mode 100755 scripts/test/delete-cluster-karpenter.sh create mode 100644 test/integration/scale/pod_scale_test.go create mode 100644 test/integration/scale/scale_suite_test.go diff --git a/scripts/test/create-cluster-karpenter.sh b/scripts/test/create-cluster-karpenter.sh new file mode 100755 index 00000000..07880452 --- /dev/null +++ b/scripts/test/create-cluster-karpenter.sh @@ -0,0 +1,147 @@ +#!/usr/bin/env bash + +# Create EKS cluster with Karpenter using eksctl +set -eo pipefail + +SCRIPTS_DIR=$(cd "$(dirname "$0")" || exit 1; pwd) +source "$SCRIPTS_DIR/lib/common.sh" +check_is_installed eksctl +check_is_installed helm +check_is_installed aws + + +export KARPENTER_NAMESPACE="kube-system" +export KARPENTER_VERSION="1.0.1" +export K8S_VERSION="1.30" + +export AWS_PARTITION="aws" # if you are not using standard partitions, you may need to configure to aws-cn / aws-us-gov +export CLUSTER_NAME="${USER}-sgp-scaletest" +export AWS_DEFAULT_REGION="us-west-2" +export AWS_ACCOUNT_ID="$(aws sts get-caller-identity --query Account --output text)" +export TEMPOUT="$(mktemp)" + +# Deploy CFN stack to enable Karpenter to create and manage nodes +echo "Deploying Karpenter CFN stack" +curl -fsSL https://raw.githubusercontent.com/aws/karpenter-provider-aws/v"${KARPENTER_VERSION}"/website/content/en/preview/getting-started/getting-started-with-karpenter/cloudformation.yaml > "${TEMPOUT}" \ +&& aws cloudformation deploy \ + --stack-name "Karpenter-${CLUSTER_NAME}" \ + --template-file "${TEMPOUT}" \ + --capabilities CAPABILITY_NAMED_IAM \ + --parameter-overrides "ClusterName=${CLUSTER_NAME}" + +# Create EKS cluster +echo "Creating EKS cluster" +eksctl create cluster -f - < Date: Tue, 27 Aug 2024 19:39:38 +0000 Subject: [PATCH 2/3] Add instructions to run scale tests manually --- test/README.md | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/test/README.md b/test/README.md index bb9aa28c..b9b66c61 100644 --- a/test/README.md +++ b/test/README.md @@ -82,7 +82,42 @@ The Integration test suite provides the following focuses. This is intended for the purposes of local development, testing and CI Setup. For more details refer the steps are provided in `scripts/test/README.md` -### Future Work -- Once we have more test suites, we can provide a script instead of invoking each suite manually. -- Add Windows tests to the list once the support is enabled. -- Move the script based tests in `integration-test` to Ginkgo Based integration/e2e test. +### Running Scale Tests + +#### Test Pod startup latency +For each release, verify that pod startup latency is comparable to the previous release. This helps to detect regression issues which impact controller performance in the new release. + +To run the test manually: + +##### 1. Create EKS cluster and install Karpenter. + +Karpenter provides node lifecycle management for Kubernetes clusters. It automates provisioning and deprovisioning of nodes based on the scheduling needs of pods, allowing efficient scaling and cost optimization. + +The script will provision all required resources for the test: +1. Deploy CFN stack to set up EKS cluster infrasstructure +2. Create EKS cluster using eksctl +3. Install Karpenter on the cluster via helm +4. Deploy default NodePool and EC2NodeClass. NodePool sets constraints on the nodes that can be created by Karpenter and the pods that can run on those nodes. EC2NodeClass is used to configure AWS-specific settings such as AMI type, AMI ID, EC2 security groups. +Refer to the Karpenter documentation for further details. +``` +./scripts/test/create-cluster-karpenter.sh +``` +The scripts are located in the `scripts/test` directory. + +##### 2. Run the scale tests. + +The scale tests are located in `test/integration/scale` directory. The test will create a deployment with 1000 pods and measures the pod startup latency. It asserts that all 1000 pods be ready within 5 minutes. The test is run three times on repeat and must pass each time. +``` +KUBE_CONFIG_PATH= # Update the kube-config path +ginkgo -v --timeout 30m -- --cluster-kubeconfig=$KUBE_CONFIG_PATH --cluster-name=$CLUSTER_NAME --aws-region=$AWS_REGION --aws-vpc-id=$VPC_ID +``` + +##### 3. Delete EKS cluster and other resources. + +The below script uninstalls Karpenter on the clusters, deletes the CFN stack, and finally deletes the EKS cluster. +``` +./scripts/test/delete-cluster-karpenter.sh +``` + +References: +1. Karpenter Getting Started Guide: https://karpenter.sh/docs/getting-started/getting-started-with-karpenter/ \ No newline at end of file From b35bbbfda155b9f31e90bd38f0271834d134c405 Mon Sep 17 00:00:00 2001 From: sushrk Date: Thu, 29 Aug 2024 01:57:40 +0000 Subject: [PATCH 3/3] fix typo in README --- test/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/README.md b/test/README.md index b9b66c61..47c236ab 100644 --- a/test/README.md +++ b/test/README.md @@ -94,7 +94,7 @@ To run the test manually: Karpenter provides node lifecycle management for Kubernetes clusters. It automates provisioning and deprovisioning of nodes based on the scheduling needs of pods, allowing efficient scaling and cost optimization. The script will provision all required resources for the test: -1. Deploy CFN stack to set up EKS cluster infrasstructure +1. Deploy CFN stack to set up EKS cluster infrastructure 2. Create EKS cluster using eksctl 3. Install Karpenter on the cluster via helm 4. Deploy default NodePool and EC2NodeClass. NodePool sets constraints on the nodes that can be created by Karpenter and the pods that can run on those nodes. EC2NodeClass is used to configure AWS-specific settings such as AMI type, AMI ID, EC2 security groups.