-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added helper script to run e2e tests Avoid abrupt script termination if there is an exception in ginkgo tests Fixed logging minor change * renamed file Addressed PR comments * removed unnecessary code * Add VPC_ID as its needed to run ginkgo tests * fixed typo * Cordon off windows nodes * Add timeout for deletion of resources
- Loading branch information
Showing
1 changed file
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#!/bin/bash | ||
|
||
# This script runs e2e tests on the AWS Load Balancer Controller | ||
|
||
set -e | ||
|
||
SECONDS=0 | ||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
echo "Running AWS Load Balancer Controller e2e tests with the following variables | ||
KUBE CONFIG: $KUBE_CONFIG_PATH | ||
CLUSTER_NAME: $CLUSTER_NAME | ||
REGION: $REGION | ||
OS_OVERRIDE: $OS_OVERRIDE" | ||
|
||
function toggle_windows_scheduling(){ | ||
schedule=$1 | ||
nodes=$(kubectl get nodes -l kubernetes.io/os=windows | tail -n +2 | cut -d' ' -f1) | ||
for n in $nodes | ||
do | ||
kubectl $schedule $n | ||
done | ||
} | ||
|
||
if [[ -z "${OS_OVERRIDE}" ]]; then | ||
OS_OVERRIDE=linux | ||
fi | ||
|
||
GET_CLUSTER_INFO_CMD="aws eks describe-cluster --name $CLUSTER_NAME --region $REGION" | ||
|
||
if [[ -z "${ENDPOINT}" ]]; then | ||
CLUSTER_INFO=$($GET_CLUSTER_INFO_CMD) | ||
else | ||
CLUSTER_INFO=$($GET_CLUSTER_INFO_CMD --endpoint $ENDPOINT) | ||
fi | ||
|
||
echo "Cordon off windows nodes" | ||
toggle_windows_scheduling "cordon" | ||
|
||
VPC_ID=$(echo $CLUSTER_INFO | jq -r '.cluster.resourcesVpcConfig.vpcId') | ||
ACCOUNT_ID=$(aws sts get-caller-identity | jq -r '.Account') | ||
|
||
echo "VPC ID: $VPC_ID" | ||
|
||
eksctl utils associate-iam-oidc-provider \ | ||
--region $REGION \ | ||
--cluster $CLUSTER_NAME \ | ||
--approve | ||
|
||
echo "Creating AWSLoadbalancerController IAM Policy" | ||
curl -o iam-policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.2.1/docs/install/iam_policy.json | ||
|
||
aws iam create-policy \ | ||
--policy-name AWSLoadBalancerControllerIAMPolicy \ | ||
--policy-document file://iam-policy.json || true | ||
|
||
echo "Creating IAM serviceaccount" | ||
eksctl create iamserviceaccount \ | ||
--cluster=$CLUSTER_NAME \ | ||
--namespace=kube-system \ | ||
--name=aws-load-balancer-controller \ | ||
--attach-policy-arn=arn:aws:iam::$ACCOUNT_ID:policy/AWSLoadBalancerControllerIAMPolicy \ | ||
--override-existing-serviceaccounts \ | ||
--approve || true | ||
|
||
echo "Update helm repo eks" | ||
helm repo add eks https://aws.github.io/eks-charts | ||
|
||
helm repo update | ||
|
||
echo "Install TargetGroupBinding CRDs" | ||
kubectl apply -k "github.com/aws/eks-charts/stable/aws-load-balancer-controller//crds?ref=master" | ||
|
||
echo "Install aws-load-balancer-controller" | ||
helm upgrade -i aws-load-balancer-controller eks/aws-load-balancer-controller -n kube-system --set clusterName=$CLUSTER_NAME --set serviceAccount.create=false --set serviceAccount.name=aws-load-balancer-controller | ||
|
||
#Start the test | ||
echo "Starting the ginkgo test suite" | ||
|
||
(cd $SCRIPT_DIR && CGO_ENABLED=0 GOOS=$OS_OVERRIDE ginkgo -v -r --timeout 60m --failOnPending -- --kubeconfig=$KUBE_CONFIG_PATH --cluster-name=$CLUSTER_NAME --aws-region=$REGION --aws-vpc-id=$VPC_ID || true) | ||
|
||
echo "Delete aws-load-balancer-controller" | ||
helm delete aws-load-balancer-controller -n kube-system --timeout=10m || true | ||
|
||
echo "Delete iamserviceaccount" | ||
eksctl delete iamserviceaccount --name aws-load-balancer-controller --namespace kube-system --cluster $CLUSTER_NAME --timeout=10m || true | ||
|
||
echo "Delete TargetGroupBinding CRDs" | ||
kubectl delete -k "github.com/aws/eks-charts/stable/aws-load-balancer-controller//crds?ref=master" --timeout=10m || true | ||
|
||
echo "Uncordon windows nodes" | ||
toggle_windows_scheduling "uncordon" | ||
|
||
echo "Successfully finished the test suite $(($SECONDS / 60)) minutes and $(($SECONDS % 60)) seconds" |