forked from awslabs/amazon-eks-ami
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update get-ecr-uri.sh with ca-west-1 account (awslabs#1542)
- Loading branch information
Showing
4 changed files
with
440 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,129 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
VERSION=1.28 | ||
|
||
CURRENT_DIR=$(pwd) | ||
BOOTSTRAP_PROJECT_DIR=$(pwd)/nodeadm | ||
|
||
cd $BOOTSTRAP_PROJECT_DIR | ||
make clean build | ||
go test ./... | ||
make dist | ||
cd $CURRENT_DIR | ||
|
||
build() { | ||
output=$(PACKER_TEMPLATE_FILE=./eks-worker-al2023.json \ | ||
PACKER_DEFAULT_VARIABLE_FILE=./eks-worker-al2023-variables.json \ | ||
make $VERSION | tee /dev/tty || true) | ||
ami_id=$(echo $output | grep 'ami-\w\+' | tail -1 | sed "s/.*\(ami-\w\+\).*/\1/g") | ||
} | ||
|
||
if [ -z "${1:-}" ]; then | ||
build | ||
|
||
if [[ $output = *"used by an existing AMI"* ]]; then | ||
echo "removing existing ami $ami_id..." | ||
aws ec2 deregister-image --image-id $ami_id | ||
build | ||
fi | ||
|
||
echo "ami-id=$ami_id" | ||
else | ||
ami_id=$1 | ||
fi | ||
|
||
# deploy the nodegroup | ||
|
||
if [ ! -z "${NODEPLOY:-}" ]; then | ||
exit | ||
fi | ||
|
||
TEST_DIR=$(mktemp -d) | ||
echo "temp dir: $TEST_DIR" | ||
|
||
# Generated | ||
TEST_CONFIG_PATH=$TEST_DIR/bootstrap-v2-config.yaml | ||
LT_DATA_PATH=$TEST_DIR/bootstrap-v2-launch-template.json | ||
|
||
CLUSTER_NAME=bootstrap-v2-cluster | ||
NODEGROUP_NAME=bootstrap-v2-nodegroup | ||
LT_NAME=bootstrap-v2-launch-template | ||
|
||
API_SERVER_ENDPOINT=$(aws eks describe-cluster --name $CLUSTER_NAME --query cluster.endpoint --output text) | ||
CERTIFICATE_AUTHORITY=$(aws eks describe-cluster --name $CLUSTER_NAME --query cluster.certificateAuthority.data --output text) | ||
|
||
# Dependency | ||
tempfile=$(mktemp) | ||
cat > $tempfile << EOF | ||
MIME-Version: 1.0 | ||
Content-Type: multipart/mixed; boundary="==MYBOUNDARY==" | ||
--==MYBOUNDARY== | ||
Content-Type: text/x-shellscript; charset=us-ascii | ||
#!/bin/bash | ||
/usr/bin/nodeadm init | ||
--==MYBOUNDARY== | ||
Content-Type: application/node.eks.aws | ||
--- | ||
apiVersion: node.eks.aws/v1alpha1 | ||
kind: NodeConfig | ||
metadata: | ||
name: example | ||
spec: | ||
cluster: | ||
name: $CLUSTER_NAME | ||
apiServerEndpoint: $API_SERVER_ENDPOINT | ||
certificateAuthority: $CERTIFICATE_AUTHORITY | ||
region: us-west-2 | ||
ipFamily: ipv4 | ||
--==MYBOUNDARY==-- | ||
EOF | ||
|
||
echo -e ">>> UserData <<<\n$(cat $tempfile)" | ||
userdata=$(cat $tempfile | base64 -w 0) | ||
echo -e ">>> UserDataB64 <<<\n$userdata" | ||
|
||
# launch a nodegroup using this ami and make sure that is properly configured | ||
cat > $LT_DATA_PATH << EOF | ||
{ | ||
"ImageId": "$ami_id", | ||
"InstanceType": "m5.large", | ||
"UserData": "$userdata" | ||
} | ||
EOF | ||
|
||
aws ec2 delete-launch-template --launch-template-name $LT_NAME 2>&1>/dev/null || true | ||
|
||
LT_ID=$(aws ec2 create-launch-template \ | ||
--launch-template-name $LT_NAME \ | ||
--launch-template-data file://$LT_DATA_PATH \ | ||
--query LaunchTemplate.LaunchTemplateId \ | ||
--output text) | ||
echo "LT_ID=$LT_ID" | ||
|
||
cat > $TEST_CONFIG_PATH << EOF | ||
--- | ||
apiVersion: eksctl.io/v1alpha5 | ||
kind: ClusterConfig | ||
metadata: | ||
name: $CLUSTER_NAME | ||
region: us-west-2 | ||
managedNodeGroups: | ||
- name: $NODEGROUP_NAME | ||
desiredCapacity: 1 | ||
launchTemplate: | ||
id: $LT_ID | ||
EOF | ||
|
||
eksctl create nodegroup -f $TEST_CONFIG_PATH || true | ||
read -t 3600 -p "pausing for 1 hour.." || true | ||
eksctl delete nodegroup -f $TEST_CONFIG_PATH --approve --wait | ||
|
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,39 @@ | ||
{ | ||
"additional_yum_repos": "", | ||
"ami_component_description": "(k8s: {{ user `kubernetes_version` }}, containerd: {{ user `containerd_version` }})", | ||
"ami_description": "EKS-optimized Kubernetes node based on Amazon Linux 2023", | ||
"ami_regions": "", | ||
"ami_users": "", | ||
"associate_public_ip_address": "", | ||
"aws_access_key_id": "{{env `AWS_ACCESS_KEY_ID`}}", | ||
"aws_region": "us-west-2", | ||
"aws_secret_access_key": "{{env `AWS_SECRET_ACCESS_KEY`}}", | ||
"aws_session_token": "{{env `AWS_SESSION_TOKEN`}}", | ||
"binary_bucket_name": "amazon-eks", | ||
"binary_bucket_region": "us-west-2", | ||
"cache_container_images": "false", | ||
"cni_plugin_version": "v1.2.0", | ||
"containerd_version": "*", | ||
"creator": "{{env `USER`}}", | ||
"docker_version": "", | ||
"enable_fips": "false", | ||
"encrypted": "false", | ||
"kernel_version": "", | ||
"kms_key_id": "", | ||
"launch_block_device_mappings_volume_size": "4", | ||
"pause_container_version": "3.5", | ||
"pull_cni_from_github": "true", | ||
"remote_folder": "/tmp", | ||
"runc_version": "*", | ||
"security_group_id": "", | ||
"source_ami_filter_name": "al2023-ami-minimal-2023.*-kernel-6.1-x86_64", | ||
"source_ami_id": "", | ||
"source_ami_owners": "137112412989", | ||
"ssh_interface": "", | ||
"ssh_username": "ec2-user", | ||
"ssm_agent_version": "", | ||
"subnet_id": "", | ||
"temporary_security_group_source_cidrs": "", | ||
"volume_type": "gp3", | ||
"working_dir": "{{user `remote_folder`}}/worker" | ||
} |
Oops, something went wrong.