Skip to content
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

Back merge from main #2

Merged
merged 32 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
a0bfe8a
feat: Offer self-service IDE based on VSCode (#1044)
niallthomson Aug 26, 2024
cc232c3
fix: Add cluster admin when using Terraform (#1057)
pranitr Aug 29, 2024
8a3b435
add internal elb tag to vpc private subnets (#1055)
tzahimizrahi Aug 29, 2024
27a1d59
Fix default branch value in VSCode CFN
niallthomson Aug 29, 2024
3e5ab4a
New AIML Lab: Deploying Llama2 Chatbot using Ray Serve on Amazon EKS …
natmhnty Aug 29, 2024
26dba28
Fix MNG scale command missing $
niallthomson Aug 30, 2024
4386fc8
Update Neuron Device Plugin Deployment to Use Direct YAML URLs (#1060)
shivam-dubey-1 Aug 30, 2024
9dc3ef9
Remove 1.30 upgrade header
niallthomson Aug 30, 2024
4dd3c31
Switch out kubectl commands in navigating page
niallthomson Aug 30, 2024
872da6d
Fix lattice cleanup for incomplete sessions
niallthomson Aug 30, 2024
7ce7ca9
Changes to account for VSCode option
niallthomson Aug 30, 2024
e6f3e6c
Set EKS cluster name in CFN
niallthomson Aug 31, 2024
5c48874
Fix terminal copy on firefox
niallthomson Sep 3, 2024
d356278
chore: Auto-approve renovatebot PRs
niallthomson Sep 6, 2024
76abf90
Replacing codeowners with mergify
niallthomson Sep 6, 2024
1549513
Automerge regex managers
niallthomson Sep 6, 2024
93a5caa
Migrate automerge to mergify
niallthomson Sep 6, 2024
c6cc217
Tweak auto merge status check conditions
niallthomson Sep 6, 2024
16055fa
chore(deps): update helm release cost-analyzer to v2 (#1003)
renovate[bot] Sep 6, 2024
a43c1e1
chore(deps): update dependency amazon-rds-mysql to v8.0.39 (#1063)
renovate[bot] Sep 6, 2024
98bb145
chore(deps): update dependency kubernetes/kubernetes to v1.30.4 (#1074)
renovate[bot] Sep 6, 2024
d7fd9db
chore(deps): update helm release keda to v2.15.1 (#1077)
renovate[bot] Sep 6, 2024
58c7e4c
chore(deps): update dependency mikefarah/yq to v4.44.3 (#1075)
renovate[bot] Sep 6, 2024
e51a051
chore(deps): update helm release aws-load-balancer-controller to v1.8…
renovate[bot] Sep 6, 2024
b3ec36b
chore(deps): update dependency aws/karpenter-provider-aws to v0.37.2 …
renovate[bot] Sep 6, 2024
ab2f535
Reverting mergify auto merge
niallthomson Sep 6, 2024
2761959
Reinstate renovate auto merge
niallthomson Sep 6, 2024
6f5dc6b
chore(deps): update dependency helm/helm to v3.15.4 (#1068)
renovate[bot] Sep 6, 2024
00e0305
chore(deps): update dependency hashicorp/terraform to v1.9.5 (#1067)
renovate[bot] Sep 6, 2024
87d3109
chore(deps): update dependency argoproj/argo-cd to v2.12.3 (#1079)
renovate[bot] Sep 6, 2024
51de74b
Expand renovatebot to first week of the month
niallthomson Sep 6, 2024
5fd4b47
Revert schedule change
niallthomson Sep 6, 2024
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
11 changes: 0 additions & 11 deletions .github/workflows/module-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ jobs:
MODULE: ${{ inputs.module }}
GLOB: ${{ inputs.glob }}
AWS_REGION: "${{ secrets.AWS_REGION }}"
ASSUME_ROLE: "${{ secrets.AWS_ROLE_ARN }}"
DOCKER_DNS_OVERRIDE: "8.8.8.8"
run: |
export AWS_DEFAULT_REGION="$AWS_REGION"
Expand All @@ -102,7 +101,6 @@ jobs:
DOCKER_BUILDKIT: 1
DEV_MODE: 1
AWS_REGION: "${{ secrets.AWS_REGION }}"
ASSUME_ROLE: "${{ secrets.AWS_ROLE_ARN }}"
run: |
export AWS_DEFAULT_REGION="$AWS_REGION"
make test environment="$CLUSTER_ID" module="cleanup"
Expand All @@ -119,13 +117,4 @@ jobs:
env:
AWS_REGION: "${{ secrets.AWS_REGION }}"
run: |
export CLEANUP_ENVIRONMENT_NAME="eks-workshop-$CLUSTER_ID"
export AWS_DEFAULT_REGION="$AWS_REGION"

envsubst < hack/lib/filter.yml > filter.yml

cat filter.yml

awsweeper --force filter.yml

make destroy-infrastructure environment="$CLUSTER_ID"
13 changes: 13 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ jobs:
- name: Check out code
uses: actions/checkout@v4
- name: Make shell
env:
SKIP_CREDENTIALS: 1
run: |
bash hack/exec.sh '' 'ls -la'

Expand Down Expand Up @@ -70,3 +72,14 @@ jobs:
node-version: 18
- run: |
npx cspell lint "website/docs/**/*.md"

terraform-validate:
name: "Validate Terraform"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: "~1.9.0"
- run: |
bash hack/validate-terraform.sh
22 changes: 0 additions & 22 deletions .github/workflows/test-cleanup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,6 @@ jobs:
- name: Install utilities
run: |
sudo apt install -y gettext

mkdir -p ${HOME}/.local/bin
wget https://github.com/jckuester/awsweeper/releases/download/v0.12.0/awsweeper_0.12.0_linux_amd64.tar.gz
tar zxf awsweeper_0.12.0_linux_amd64.tar.gz
mv awsweeper_0.12.0_linux_amd64/awsweeper ${HOME}/.local/bin

wget https://github.com/eksctl-io/eksctl/releases/download/v0.169.0/eksctl_Linux_amd64.tar.gz
tar zxf eksctl_Linux_amd64.tar.gz
mv eksctl ${HOME}/.local/bin

chmod +x ${HOME}/.local/bin/*

echo "${HOME}/.local/bin" >> $GITHUB_PATH
- name: Get AWS credentials
uses: aws-actions/configure-aws-credentials@v4.0.2
with:
Expand All @@ -50,13 +37,4 @@ jobs:
CLUSTER_ID: ${{ github.event.inputs.clusterId }}
AWS_REGION: "${{ secrets.AWS_REGION }}"
run: |
export CLEANUP_ENVIRONMENT_NAME="$CLUSTER_ID"
export AWS_DEFAULT_REGION="$AWS_REGION"

envsubst < hack/lib/filter.yml > filter.yml

cat filter.yml

awsweeper --force filter.yml

make destroy-infrastructure environment="$CLUSTER_ID"
7 changes: 7 additions & 0 deletions .mergify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pull_request_rules:
- name: Automatically approve Renovate PRs
conditions:
- author = renovate[bot]
actions:
review:
type: APPROVE
1 change: 1 addition & 0 deletions .spelling
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,4 @@ mehta
sheetal
joshi
keda
AIML
2 changes: 0 additions & 2 deletions CODEOWNERS

This file was deleted.

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ delete-environment:

.PHONY: create-infrastructure
create-infrastructure:
bash hack/exec.sh $(environment) 'cat /cluster/eksctl/cluster.yaml | envsubst | eksctl create cluster -f -'
bash hack/create-infrastructure.sh $(environment)

.PHONY: destroy-infrastructure
destroy-infrastructure:
bash hack/exec.sh $(environment) 'cat /cluster/eksctl/cluster.yaml | envsubst | eksctl delete cluster --wait --force --disable-nodegroup-eviction --timeout 45m -f -'
bash hack/destroy-infrastructure.sh $(environment)
18 changes: 11 additions & 7 deletions cluster/terraform/eks.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ module "eks" {
source = "terraform-aws-modules/eks/aws"
version = "~> 20.0"

cluster_name = var.cluster_name
cluster_version = var.cluster_version
cluster_endpoint_public_access = true
cluster_name = var.cluster_name
cluster_version = var.cluster_version
cluster_endpoint_public_access = true
enable_cluster_creator_admin_permissions = true

cluster_addons = {
vpc-cni = {
Expand Down Expand Up @@ -32,9 +33,12 @@ module "eks" {

eks_managed_node_groups = {
default = {
instance_types = ["m5.large"]
force_update_version = true
release_version = var.ami_release_version
instance_types = ["m5.large"]
force_update_version = true
release_version = var.ami_release_version
use_name_prefix = false
iam_role_name = "${var.cluster_name}-ng-default"
iam_role_use_name_prefix = false

min_size = 3
max_size = 6
Expand All @@ -53,4 +57,4 @@ module "eks" {
tags = merge(local.tags, {
"karpenter.sh/discovery" = var.cluster_name
})
}
}
3 changes: 2 additions & 1 deletion cluster/terraform/vpc.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ module "vpc" {
"kubernetes.io/role/elb" = "1"
})
private_subnet_tags = merge(local.tags, {
"karpenter.sh/discovery" = var.cluster_name
"karpenter.sh/discovery" = var.cluster_name
"kubernetes.io/role/internal-elb" = "1"
})

tags = local.tags
Expand Down
6 changes: 5 additions & 1 deletion docs/reviewer_checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ See style guide for expanded explanations.
- [ ] `$EKS_CLUSTER_NAME` is used instead of hard-coded cluster names, including referencing other infrastructure that may use the cluster name
- [ ] Avoided use of interactive `kubectl exec` or multiple terminal windows (or tests skipped)

## AWS infrastructure

- [ ] All Terraform resources created have names that prefixed with the EKS cluster name (`var.addon_context.eks_cluster_id`)

## Tests

- [ ] `bash` blocks that run commands that are intended to error use `expectError=true`
Expand All @@ -34,5 +38,5 @@ See style guide for expanded explanations.
## Misc

- [ ] Generated lab timing has been created (new lab) or updated (updated lab) if needed
- [ ] All Terraform resources created have dynamic names
- [ ] Relevant updates have been made to the [lab IAM policy](../lab/iam-policy-labs.json)
- [ ] Images should be in `webp` format
23 changes: 23 additions & 0 deletions hack/build-ide-cfn.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

set -e

output_path=$1

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

source $SCRIPT_DIR/lib/common-env.sh

if [ -z "$output_path" ]; then
outfile=$(mktemp)
else
outfile=$output_path
fi

cd lab

export Env="${EKS_CLUSTER_NAME}"

cat cfn/eks-workshop-vscode-cfn.yaml | yq '(.. | select(has("file"))) |= (load(.file))' | envsubst '$Env' > $outfile

echo "Output file: $outfile"
24 changes: 24 additions & 0 deletions hack/create-infrastructure.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

environment=$1

set -Eeuo pipefail
set -u

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

source $SCRIPT_DIR/lib/common-env.sh

bash $SCRIPT_DIR/update-iam-role.sh $environment

sleep 5

cluster_exists=0
aws eks describe-cluster --name "${EKS_CLUSTER_NAME}" &> /dev/null || cluster_exists=$?

if [ $cluster_exists -eq 0 ]; then
echo "Cluster ${EKS_CLUSTER_NAME} already exists"
else
echo "Creating cluster ${EKS_CLUSTER_NAME}"
bash $SCRIPT_DIR/exec.sh "${environment}" 'cat /cluster/eksctl/cluster.yaml | envsubst | eksctl create cluster -f -'
fi
14 changes: 14 additions & 0 deletions hack/deploy-ide-cfn.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

set -e

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

source $SCRIPT_DIR/lib/common-env.sh

outfile=$(mktemp)

bash $SCRIPT_DIR/build-ide-cfn.sh $outfile

aws cloudformation deploy --stack-name eks-workshop-ide1 \
--capabilities CAPABILITY_NAMED_IAM --disable-rollback --template-file $outfile
24 changes: 24 additions & 0 deletions hack/destroy-infrastructure.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

environment=$1

set -Eeuo pipefail
set -u

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

source $SCRIPT_DIR/lib/common-env.sh

cluster_exists=0
aws eks describe-cluster --name "${EKS_CLUSTER_NAME}" &> /dev/null || cluster_exists=$?

if [ $cluster_exists -eq 0 ]; then
echo "Deleting cluster ${EKS_CLUSTER_NAME}"
bash $SCRIPT_DIR/shell.sh "${environment}" 'delete-environment || true'

bash $SCRIPT_DIR/exec.sh "${environment}" 'eksctl delete cluster --name ${EKS_CLUSTER_NAME} --region ${AWS_REGION} --wait --force --disable-nodegroup-eviction --timeout 45m'
else
echo "Cluster ${EKS_CLUSTER_NAME} does not exist"
fi

aws cloudformation delete-stack --stack-name ${EKS_CLUSTER_NAME}-ide-role || true
6 changes: 5 additions & 1 deletion hack/exec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ container_image='eks-workshop-environment'

(cd $SCRIPT_DIR/../lab && $CONTAINER_CLI build -q -t $container_image .)

source $SCRIPT_DIR/lib/generate-aws-creds.sh
if [ -z "$SKIP_CREDENTIALS" ]; then
source $SCRIPT_DIR/lib/generate-aws-creds.sh
else
aws_credential_args=""
fi

echo "Executing command in container..."

Expand Down
12 changes: 12 additions & 0 deletions hack/find-dangling-resources.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

environment=$1

set -Eeuo pipefail
set -u

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

source $SCRIPT_DIR/lib/common-env.sh

aws resourcegroupstaggingapi get-resources --tag-filters Key=env,Values=$EKS_CLUSTER_NAME --query 'ResourceTagMappingList[].ResourceARN'
9 changes: 9 additions & 0 deletions hack/lib/common-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,12 @@ if [ -z "$AWS_REGION" ]; then

export AWS_REGION="us-west-2"
fi

SKIP_CREDENTIALS=${SKIP_CREDENTIALS:-""}

if [ -z "$SKIP_CREDENTIALS" ]; then
ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)

IDE_ROLE_NAME="${EKS_CLUSTER_NAME}-ide-role"
IDE_ROLE_ARN="arn:aws:iam::${ACCOUNT_ID}:role/${IDE_ROLE_NAME}"
fi
28 changes: 13 additions & 15 deletions hack/lib/generate-aws-creds.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
aws_credential_args=""
echo "Generating temporary AWS credentials..."

ASSUME_ROLE=${ASSUME_ROLE:-""}
AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID:-""}
session_suffix=$(openssl rand -hex 4)

target_role=${IDE_ROLE_ARN}

if [ ! -z "$AWS_ACCESS_KEY_ID" ]; then
echo "Using environment AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY"
ASSUME_ROLE=${ASSUME_ROLE:-""}

aws_credential_args="-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY -e AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN"
elif [ ! -z "$ASSUME_ROLE" ]; then
echo "Generating temporary AWS credentials..."
if [ ! -z "$ASSUME_ROLE" ]; then
echo "Assuming role $ASSUME_ROLE"
target_role=$ASSUME_ROLE
fi

ACCESS_VARS=$(aws sts assume-role --role-arn $ASSUME_ROLE --role-session-name ${EKS_CLUSTER_NAME}-shell --output json | jq -r '.Credentials | "export AWS_ACCESS_KEY_ID=\(.AccessKeyId) AWS_SECRET_ACCESS_KEY=\(.SecretAccessKey) AWS_SESSION_TOKEN=\(.SessionToken)"')
ACCESS_VARS=$(aws sts assume-role --role-arn ${target_role} --role-session-name ${EKS_CLUSTER_NAME}-shell-${session_suffix} --output json | jq -r '.Credentials | "export AWS_ACCESS_KEY_ID=\(.AccessKeyId) AWS_SECRET_ACCESS_KEY=\(.SecretAccessKey) AWS_SESSION_TOKEN=\(.SessionToken)"')

# TODO: This should probably not use eval
eval "$ACCESS_VARS"
# TODO: This should probably not use eval
eval "$ACCESS_VARS"

aws_credential_args="-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY -e AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN"
else
echo "Inheriting credentials from instance profile"
fi
aws_credential_args="-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY -e AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN"
14 changes: 11 additions & 3 deletions hack/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,27 @@ RESOURCES_PRECREATED=${RESOURCES_PRECREATED:-""}

echo "Running test suite..."

exit_code=0

$CONTAINER_CLI run $background_args $dns_args \
--name $container_name \
-v $SCRIPT_DIR/../website/docs:/content \
-v $SCRIPT_DIR/../manifests:/manifests \
-e 'EKS_CLUSTER_NAME' -e 'AWS_REGION' -e 'RESOURCES_PRECREATED' \
$aws_credential_args $container_image -g "${actual_glob}" --hook-timeout 3600 --timeout 3600 $output_args ${AWS_EKS_WORKSHOP_TEST_FLAGS}
$aws_credential_args $container_image -g "${actual_glob}" --hook-timeout 3600 --timeout 3600 $output_args ${AWS_EKS_WORKSHOP_TEST_FLAGS} || exit_code=$?

if [ ! -z "$TEST_REPORT" ]; then
docker cp $container_name:/tmp/test-report.json $TEST_REPORT > /dev/null
if [ $exit_code -eq 0 ]; then
if [ ! -z "$TEST_REPORT" ]; then
docker cp $container_name:/tmp/test-report.json $TEST_REPORT > /dev/null
fi
fi

docker rm $container_name > /dev/null

if [ $exit_code -ne 0 ]; then
exit $exit_code
fi

if [ ! -z "$GENERATE_TIMINGS" ]; then
tmpfile=$(mktemp)

Expand Down
Loading