Skip to content

Commit

Permalink
Update run-integration-tests.sh with init container support
Browse files Browse the repository at this point in the history
  • Loading branch information
Claes Mogren committed May 28, 2020
1 parent 47a1cd1 commit e6cc03b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

.PHONY: all dist check clean \
lint format check-format vet docker-vet \
build-linux docker init \
build-linux docker docker-init \
unit-test unit-test-race build-docker-test docker-func-test \
build-metrics docker-metrics \
metrics-unit-test docker-metrics-test
Expand Down Expand Up @@ -94,7 +94,7 @@ DOCKER_BUILD_FLAGS = --build-arg GOARCH="$(ARCH)" \
.DEFAULT_GOAL = build-linux

# Build both CNI and metrics helper container images.
all: docker init docker-metrics
all: docker docker-init docker-metrics

dist: all
mkdir -p $(DESTDIR)
Expand All @@ -118,7 +118,7 @@ docker:
.
@echo "Built Docker image \"$(IMAGE_NAME)\""

init:
docker-init:
docker build $(DOCKER_BUILD_FLAGS) \
-f scripts/dockerfiles/Dockerfile.init \
-t "$(INIT_IMAGE_NAME)" \
Expand Down
10 changes: 10 additions & 0 deletions scripts/run-integration-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ ensure_aws_k8s_tester
: "${AWS_ECR_REGISTRY:="$AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com"}"
: "${AWS_ECR_REPO_NAME:="amazon-k8s-cni"}"
: "${IMAGE_NAME:="$AWS_ECR_REGISTRY/$AWS_ECR_REPO_NAME"}"
: "${AWS_INIT_ECR_REPO_NAME:="amazon-k8s-cni-init"}"
: "${INIT_IMAGE_NAME:="$AWS_ECR_REGISTRY/$AWS_INIT_ECR_REPO_NAME"}"
: "${ROLE_CREATE:=true}"
: "${ROLE_ARN:=""}"

Expand All @@ -90,6 +92,7 @@ ensure_aws_k8s_tester
# shellcheck disable=SC2046
eval $(aws ecr get-login --region $AWS_DEFAULT_REGION --no-include-email) >/dev/null 2>&1
ensure_ecr_repo "$AWS_ACCOUNT_ID" "$AWS_ECR_REPO_NAME"
ensure_ecr_repo "$AWS_ACCOUNT_ID" "$AWS_INIT_ECR_REPO_NAME"

# Check to see if the image already exists in the Docker repository, and if
# not, check out the CNI source code for that image tag, build the CNI
Expand All @@ -108,6 +111,9 @@ else
fi
make docker IMAGE="$IMAGE_NAME" VERSION="$TEST_IMAGE_VERSION"
docker push "$IMAGE_NAME:$TEST_IMAGE_VERSION"
# Build matching init container
make docker-init INIT_IMAGE="$INIT_IMAGE_NAME" VERSION="$TEST_IMAGE_VERSION"
docker push "$INIT_IMAGE_NAME:$TEST_IMAGE_VERSION"
if [[ $TEST_IMAGE_VERSION != "$LOCAL_GIT_VERSION" ]]; then
popd
fi
Expand All @@ -122,6 +128,7 @@ echo "+ Kubeconfig: $KUBECONFIG_PATH"
echo "+ Cluster config: $CLUSTER_CONFIG"
echo "+ AWS Account ID: $AWS_ACCOUNT_ID"
echo "+ CNI image to test: $IMAGE_NAME:$TEST_IMAGE_VERSION"
echo "+ CNI init container: $INIT_IMAGE_NAME:$TEST_IMAGE_VERSION"

mkdir -p "$TEST_DIR"
mkdir -p "$REPORT_DIR"
Expand All @@ -139,6 +146,8 @@ cp "$BASE_CONFIG_PATH" "$TEST_CONFIG_PATH"
# Daemonset template
sed -i'.bak' "s,602401143452.dkr.ecr.us-west-2.amazonaws.com/amazon-k8s-cni,$IMAGE_NAME," "$TEST_CONFIG_PATH"
sed -i'.bak' "s,:$MANIFEST_IMAGE_VERSION,:$TEST_IMAGE_VERSION," "$TEST_CONFIG_PATH"
sed -i'.bak' "s,602401143452.dkr.ecr.us-west-2.amazonaws.com/amazon-k8s-cni-init,$INIT_IMAGE_NAME," "$TEST_CONFIG_PATH"
sed -i'.bak' "s,:$MANIFEST_IMAGE_VERSION,:$TEST_IMAGE_VERSION," "$TEST_CONFIG_PATH"

export KUBECONFIG=$KUBECONFIG_PATH
ADDONS_CNI_IMAGE=$($KUBECTL_PATH describe daemonset aws-node -n kube-system | grep Image | cut -d ":" -f 2-3 | tr -d '[:space:]')
Expand All @@ -154,6 +163,7 @@ popd

echo "*******************************************************************************"
echo "Updating CNI to image $IMAGE_NAME:$TEST_IMAGE_VERSION"
echo "Using init container $INIT_IMAGE_NAME:$TEST_IMAGE_VERSION"
$KUBECTL_PATH apply -f "$TEST_CONFIG_PATH"

# Delay based on 3 nodes, 30s grace period per CNI pod
Expand Down

0 comments on commit e6cc03b

Please sign in to comment.