-
Notifications
You must be signed in to change notification settings - Fork 983
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate the command line commands in the getting started guide into …
…independent bash files (#1412) * Separates the CLI parts of the getting started guide into independent bash files and adds a run-all-steps.sh file that sequentially runs all those files. By running the run-all-steps.sh we can verify that all steps work * Turn steps into a loop, end execution if one step fails and add end of line to files * correct link and add end of file to layout * Take Karpenter version as an input to run-all-steps.sh * Fix the count and undo unwanted change to index.md
- Loading branch information
1 parent
eb0123b
commit 2396c10
Showing
10 changed files
with
100 additions
and
71 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
27 changes: 27 additions & 0 deletions
27
website/content/en/preview/getting-started/scripts/run-all-steps.sh
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,27 @@ | ||
#!/bin/bash | ||
set -euo pipefail #fail if one step fails | ||
|
||
if [ "$#" -ne 1 ] | ||
then | ||
echo "Missing required Karpenter version. Usage: run-all-steps.sh v0.0.1" | ||
exit 1 | ||
fi | ||
|
||
export KARPENTER_VERSION=$1 | ||
|
||
declare -a steps=( | ||
step01-config.sh | ||
step02-create-cluster.sh | ||
step03-iam-cloud-formation.sh | ||
step04-grant-access.sh | ||
step05-controller-iam.sh | ||
step06-install-helm-chart.sh | ||
step07-apply-helm-chart.sh | ||
) | ||
|
||
i=0 | ||
for step in "${steps[@]}"; do | ||
((i += 1)) | ||
echo "Step $i" | ||
source $step | ||
done |
3 changes: 3 additions & 0 deletions
3
website/content/en/preview/getting-started/scripts/step01-config.sh
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,3 @@ | ||
export CLUSTER_NAME="${USER}-karpenter-demo" | ||
export AWS_DEFAULT_REGION="us-west-2" | ||
export AWS_ACCOUNT_ID="$(aws sts get-caller-identity --query Account --output text)" |
22 changes: 22 additions & 0 deletions
22
website/content/en/preview/getting-started/scripts/step02-create-cluster.sh
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,22 @@ | ||
eksctl create cluster -f - << EOF | ||
--- | ||
apiVersion: eksctl.io/v1alpha5 | ||
kind: ClusterConfig | ||
metadata: | ||
name: ${CLUSTER_NAME} | ||
region: ${AWS_DEFAULT_REGION} | ||
version: "1.21" | ||
tags: | ||
karpenter.sh/discovery: ${CLUSTER_NAME} | ||
managedNodeGroups: | ||
- instanceType: m5.large | ||
amiFamily: AmazonLinux2 | ||
name: ${CLUSTER_NAME}-ng | ||
desiredCapacity: 1 | ||
minSize: 1 | ||
maxSize: 10 | ||
iam: | ||
withOIDC: true | ||
EOF | ||
|
||
export CLUSTER_ENDPOINT="$(aws eks describe-cluster --name ${CLUSTER_NAME} --query "cluster.endpoint" --output text)" |
8 changes: 8 additions & 0 deletions
8
website/content/en/preview/getting-started/scripts/step03-iam-cloud-formation.sh
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,8 @@ | ||
TEMPOUT=$(mktemp) | ||
|
||
curl -fsSL https://karpenter.sh/"${KARPENTER_VERSION}"/getting-started/cloudformation.yaml > $TEMPOUT \ | ||
&& aws cloudformation deploy \ | ||
--stack-name "Karpenter-${CLUSTER_NAME}" \ | ||
--template-file "${TEMPOUT}" \ | ||
--capabilities CAPABILITY_NAMED_IAM \ | ||
--parameter-overrides "ClusterName=${CLUSTER_NAME}" |
6 changes: 6 additions & 0 deletions
6
website/content/en/preview/getting-started/scripts/step04-grant-access.sh
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,6 @@ | ||
eksctl create iamidentitymapping \ | ||
--username system:node:{{EC2PrivateDNSName}} \ | ||
--cluster "${CLUSTER_NAME}" \ | ||
--arn "arn:aws:iam::${AWS_ACCOUNT_ID}:role/KarpenterNodeRole-${CLUSTER_NAME}" \ | ||
--group system:bootstrappers \ | ||
--group system:nodes |
8 changes: 8 additions & 0 deletions
8
website/content/en/preview/getting-started/scripts/step05-controller-iam.sh
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,8 @@ | ||
eksctl create iamserviceaccount \ | ||
--cluster "${CLUSTER_NAME}" --name karpenter --namespace karpenter \ | ||
--role-name "${CLUSTER_NAME}-karpenter" \ | ||
--attach-policy-arn "arn:aws:iam::${AWS_ACCOUNT_ID}:policy/KarpenterControllerPolicy-${CLUSTER_NAME}" \ | ||
--role-only \ | ||
--approve | ||
|
||
export KARPENTER_IAM_ROLE_ARN="arn:aws:iam::${AWS_ACCOUNT_ID}:role/${CLUSTER_NAME}-karpenter" |
2 changes: 2 additions & 0 deletions
2
website/content/en/preview/getting-started/scripts/step06-install-helm-chart.sh
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,2 @@ | ||
helm repo add karpenter https://charts.karpenter.sh/ | ||
helm repo update |
8 changes: 8 additions & 0 deletions
8
website/content/en/preview/getting-started/scripts/step07-apply-helm-chart.sh
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,8 @@ | ||
helm upgrade --install --namespace karpenter --create-namespace \ | ||
karpenter karpenter/karpenter \ | ||
--version ${KARPENTER_VERSION} \ | ||
--set serviceAccount.annotations."eks\.amazonaws\.com/role-arn"=${KARPENTER_IAM_ROLE_ARN} \ | ||
--set clusterName=${CLUSTER_NAME} \ | ||
--set clusterEndpoint=${CLUSTER_ENDPOINT} \ | ||
--set aws.defaultInstanceProfile=KarpenterNodeInstanceProfile-${CLUSTER_NAME} \ | ||
--wait # for the defaulting webhook to install before creating a Provisioner |
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,3 @@ | ||
{{ $file := .Get "file" | readFile }} | ||
{{ $lang := .Get "language" }} | ||
{{ (print "```" $lang "\n" $file "```") | markdownify }} |