Skip to content

Commit c2d6f76

Browse files
ROunofFidlikejathavrRaj Athavaleniallthomson
authored
new: Learning Paths merging into main: Developer and Operator + Kubernetes Basic section. (#1785)
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: M A <1267879+idontlikej@users.noreply.github.com> Co-authored-by: Raj Athavale <58447454+athavr@users.noreply.github.com> Co-authored-by: Raj Athavale <athavr@amazon.com> Co-authored-by: Niall Thomson <thomson.niall@gmail.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Parth Pandit <34379542+parth-pandit@users.noreply.github.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: rrepka <46093591+r-repka@users.noreply.github.com> Co-authored-by: Sai Vennam <svennam92@gmail.com>
1 parent 9f2e00c commit c2d6f76

216 files changed

Lines changed: 9236 additions & 176 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/test-fastpaths.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Test - Fastpaths
33
on:
44
workflow_dispatch:
55
schedule:
6-
- cron: "0 17 * * 5"
6+
- cron: "0 7 * * 5"
77

88
permissions:
99
id-token: write

Makefile

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,28 @@ environment=''
44
shell_command=''
55
shell_simple_command=''
66
glob='-'
7+
cluster='all'
78

89
.PHONY: install
910
install:
1011
yarn install
1112

13+
.PHONY: build
14+
build: install
15+
yarn build
16+
17+
.PHONY: warning
18+
warning:
19+
@echo "Note: 'make serve' now does a full static build. For dev mode, use 'make start' instead."
20+
1221
.PHONY: serve
13-
serve: install
22+
serve: warning build
1423
yarn serve
1524

25+
.PHONY: start
26+
start: install
27+
yarn start
28+
1629
.PHONY: tf-fmt
1730
tf-fmt:
1831
cd ./terraform && terraform fmt --recursive
@@ -37,13 +50,17 @@ reset-environment:
3750
delete-environment:
3851
bash hack/shell.sh $(environment) delete-environment
3952

53+
.PHONY: pre-provision
54+
pre-provision:
55+
bash hack/pre-provision-resources.sh $(environment) $(action)
56+
4057
.PHONY: create-infrastructure
4158
create-infrastructure:
42-
bash hack/create-infrastructure.sh $(environment)
59+
bash hack/create-infrastructure.sh $(environment) $(cluster)
4360

4461
.PHONY: destroy-infrastructure
4562
destroy-infrastructure:
46-
bash hack/destroy-infrastructure.sh $(environment)
63+
bash hack/destroy-infrastructure.sh $(environment) $(cluster)
4764

4865
.PHONY: deploy-ide
4966
deploy-ide:
@@ -55,4 +72,5 @@ destroy-ide:
5572

5673
.PHONY: lint
5774
lint:
58-
yarn lint
75+
yarn lint
76+

cluster/eksctl/access-entries.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
accessEntries:
2+
- principalARN: ${RESOURCE_CODEBUILD_ROLE_ARN}
3+
accessPolicies:
4+
- policyARN: "arn:aws:eks::aws:cluster-access-policy/AmazonEKSClusterAdminPolicy"
5+
accessScope:
6+
type: cluster

cluster/eksctl/cluster-auto.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
apiVersion: eksctl.io/v1alpha5
2+
kind: ClusterConfig
3+
availabilityZones:
4+
- ${AWS_REGION}a
5+
- ${AWS_REGION}b
6+
- ${AWS_REGION}c
7+
metadata:
8+
name: ${EKS_CLUSTER_AUTO_NAME}
9+
region: ${AWS_REGION}
10+
version: "1.33"
11+
tags:
12+
karpenter.sh/discovery: ${EKS_CLUSTER_AUTO_NAME}
13+
created-by: eks-workshop-v2
14+
env: ${EKS_CLUSTER_AUTO_NAME}
15+
vpc:
16+
cidr: 10.43.0.0/16
17+
clusterEndpoints:
18+
privateAccess: true
19+
publicAccess: true
20+
autoModeConfig:
21+
enabled: true
22+
nodePools: [general-purpose, system]
23+
accessConfig:
24+
authenticationMode: API
25+
bootstrapClusterCreatorAdminPermissions: true

cluster/eksctl/cluster.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,7 @@ remoteNetworkConfig:
4040
remoteNodeNetworks:
4141
- cidrs: ["10.52.0.0/16"]
4242
remotePodNetworks:
43-
- cidrs: ["10.53.0.0/16"]
43+
- cidrs: ["10.53.0.0/16"]
44+
accessConfig:
45+
authenticationMode: API
46+
bootstrapClusterCreatorAdminPermissions: true

docs/style_guide.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ sidebar_custom_props: { "explore": "https://<external link here>" }
6464
---
6565
```
6666

67+
To mark your module as optional:
68+
```
69+
---
70+
...
71+
sidebar_custom_props: { "optional": "true" }
72+
---
73+
```
74+
6775
### Navigating the AWS console
6876

6977
There are instances where the user needs to navigate to specific screens in the AWS console. It is preferable to provide a link to the exact screen if possible, or a close as can be done.

hack/create-infrastructure.sh

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
#!/bin/bash
22

33
environment=$1
4+
cluster=${2:-all}
5+
export USE_CURRENT_USER=${USE_CURRENT_USER:-1} # We don't want to change the ARN in exec
6+
echo "Creating infrastructure for environment ${environment} and cluster ${cluster}"
47

58
set -Eeuo pipefail
69
set -u
10+
set -x
711

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

@@ -13,12 +17,30 @@ bash $SCRIPT_DIR/update-iam-role.sh $environment
1317

1418
sleep 5
1519

20+
pids=()
21+
1622
cluster_exists=0
1723
aws eks describe-cluster --name "${EKS_CLUSTER_NAME}" &> /dev/null || cluster_exists=$?
1824

19-
if [ $cluster_exists -eq 0 ]; then
25+
if [ $cluster_exists -ne 0 ] && [[ "$cluster" == "standard" || "$cluster" == "all" ]]; then
26+
echo "Creating cluster ${EKS_CLUSTER_NAME}"
27+
bash $SCRIPT_DIR/exec.sh "${environment}" 'cat /cluster/eksctl/cluster.yaml /cluster/eksctl/access-entries.yaml | envsubst | eksctl create cluster -f -' &
28+
pids+=($!)
29+
else
2030
echo "Cluster ${EKS_CLUSTER_NAME} already exists"
31+
fi
32+
33+
auto_cluster_exists=0
34+
aws eks describe-cluster --name "${EKS_CLUSTER_AUTO_NAME}" &> /dev/null || auto_cluster_exists=$?
35+
36+
if [ $auto_cluster_exists -ne 0 ] && [[ "$cluster" == "auto" || "$cluster" == "all" ]]; then
37+
echo "Creating auto mode cluster ${EKS_CLUSTER_AUTO_NAME}"
38+
bash $SCRIPT_DIR/exec.sh "${environment}" 'cat /cluster/eksctl/cluster-auto.yaml /cluster/eksctl/access-entries.yaml | envsubst | eksctl create cluster -f -' &
39+
pids+=($!)
2140
else
22-
echo "Creating cluster ${EKS_CLUSTER_NAME}"
23-
bash $SCRIPT_DIR/exec.sh "${environment}" 'cat /cluster/eksctl/cluster.yaml | envsubst | eksctl create cluster -f -'
24-
fi
41+
echo "Auto mode cluster ${EKS_CLUSTER_AUTO_NAME} already exists"
42+
fi
43+
44+
for pid in "${pids[@]}"; do
45+
wait "$pid" || exit 1
46+
done

hack/deploy-ide-cfn.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,21 @@ outfile=$(mktemp)
1010

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

13+
REPOSITORY_OWNER=${REPOSITORY_OWNER:-"aws-samples"}
14+
REPOSITORY_NAME=${REPOSITORY_NAME:-"eks-workshop-v2"}
15+
REPOSITORY_REF=${REPOSITORY_REF:-"main"}
16+
1317
source $SCRIPT_DIR/lib/resolve-source-ip.sh
1418

1519
STACK_NAME="$EKS_CLUSTER_NAME-cfn"
1620

1721
aws cloudformation deploy --stack-name "$STACK_NAME" \
1822
--capabilities CAPABILITY_NAMED_IAM --disable-rollback --template-file $outfile \
19-
--parameter-overrides InboundCIDR="$INBOUND_CIDRS"
23+
--parameter-overrides \
24+
RepositoryOwner="$REPOSITORY_OWNER" \
25+
RepositoryName="$REPOSITORY_NAME" \
26+
RepositoryRef="$REPOSITORY_REF" \
27+
InboundCIDR="$INBOUND_CIDRS"
2028

2129
if [ -z "$CI" ]; then
2230
IDE_URL=$(aws cloudformation describe-stacks --stack-name "$STACK_NAME" \
@@ -28,4 +36,4 @@ if [ -z "$CI" ]; then
2836
echo ""
2937
echo "IDE URL: $IDE_URL"
3038
echo "IDE Password: $IDE_PASSWORD"
31-
fi
39+
fi

hack/destroy-infrastructure.sh

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,43 @@
11
#!/bin/bash
22

33
environment=$1
4+
cluster=${2:-all}
5+
echo "Destroying infrastructure for environment ${environment} and cluster ${cluster}"
46

57
set -Eeuo pipefail
68
set -u
79

810
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
9-
11+
export USE_CURRENT_USER=${USE_CURRENT_USER:-1};
1012
source $SCRIPT_DIR/lib/common-env.sh
1113

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

15-
if [ $cluster_exists -eq 0 ]; then
17+
if [ $cluster_exists -eq 0 ] && [[ "$cluster" == "standard" || "$cluster" == "all" ]]; then
1618
echo "Deleting cluster ${EKS_CLUSTER_NAME}"
1719
bash $SCRIPT_DIR/shell.sh "${environment}" 'delete-environment' || true
20+
bash $SCRIPT_DIR/exec.sh "${environment}" 'eksctl delete cluster --name ${EKS_CLUSTER_NAME} --region ${AWS_REGION} --wait --force --disable-nodegroup-eviction --timeout 45m'&
21+
else
22+
echo "Cluster ${EKS_CLUSTER_NAME} does not exist or skipped"
23+
fi
1824

19-
bash $SCRIPT_DIR/exec.sh "${environment}" 'eksctl delete cluster --name ${EKS_CLUSTER_NAME} --region ${AWS_REGION} --wait --force --disable-nodegroup-eviction --timeout 45m'
25+
export EKS_CLUSTER_AUTO_NAME="${EKS_CLUSTER_AUTO_NAME}"
26+
auto_cluster_exists=0
27+
aws eks describe-cluster --name "${EKS_CLUSTER_AUTO_NAME}" &> /dev/null || auto_cluster_exists=$?
28+
29+
if [ $auto_cluster_exists -eq 0 ] && [[ "$cluster" == "auto" || "$cluster" == "all" ]]; then
30+
echo "Deleting auto mode cluster ${EKS_CLUSTER_AUTO_NAME}"
31+
#bash $SCRIPT_DIR/shell.sh "${environment}" 'delete-environment' || true # Needed ?
32+
bash $SCRIPT_DIR/exec.sh "${environment}" 'eksctl delete cluster --name ${EKS_CLUSTER_AUTO_NAME} --region ${AWS_REGION} --wait --force --disable-nodegroup-eviction --timeout 45m'
2033
else
21-
echo "Cluster ${EKS_CLUSTER_NAME} does not exist"
34+
echo "Auto mode cluster ${EKS_CLUSTER_AUTO_NAME} does not exist or skipped"
2235
fi
2336

24-
aws cloudformation delete-stack --stack-name ${EKS_CLUSTER_NAME}-ide-role || true
37+
wait
38+
39+
# Only delete ide-role if all clusters are deleted
40+
if [ "$cluster" == "all" ]; then
41+
aws cloudformation delete-stack --stack-name ${EKS_CLUSTER_NAME}-ide-role || true
42+
echo "Deleted role"
43+
fi

hack/exec.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,19 @@ container_image='eks-workshop-environment'
1919

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

22-
if [ -z "$SKIP_CREDENTIALS" ]; then
22+
23+
if [ "${SKIP_CREDENTIALS:-0}" = "0" ] && [ "${USE_CURRENT_USER:-0}" = "0" ]; then
24+
echo "Passing temp AWS credentials"
2325
source $SCRIPT_DIR/lib/generate-aws-creds.sh
26+
elif [ "${USE_CURRENT_USER:-0}" != "0" ]; then
27+
if [ -z "$AWS_ACCESS_KEY_ID" ]; then
28+
echo "No AWS_ACCESS_KEY_ID found, please check your AWS credentials"
29+
exit 1
30+
fi
31+
echo "Using USE_CURRENT_USER"
32+
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:-}"
2433
else
34+
echo "Using DEFAULT no credentials passed"
2535
aws_credential_args=""
2636
fi
2737

@@ -31,5 +41,6 @@ $CONTAINER_CLI run --rm \
3141
-v $SCRIPT_DIR/../manifests:/manifests \
3242
-v $SCRIPT_DIR/../cluster:/cluster \
3343
--entrypoint /bin/bash \
34-
-e 'EKS_CLUSTER_NAME' -e 'AWS_REGION' -e 'AWS_CONTAINER_CREDENTIALS_RELATIVE_URI' \
44+
-e "RESET_NO_DELETE=true" \
45+
-e 'EKS_CLUSTER_NAME' -e 'EKS_CLUSTER_AUTO_NAME' -e 'AWS_REGION' -e 'AWS_CONTAINER_CREDENTIALS_RELATIVE_URI' -e RESOURCE_CODEBUILD_ROLE_ARN \
3546
$aws_credential_args $container_image -c "$shell_command"

0 commit comments

Comments
 (0)