Gowmi
Gowmi

Reputation: 611

AWS EKS custom AMI managed Node Group Bootstrap file not exists

Below are steps i preformed to use custom AMI EKS managed node group.

  1. bootstrap_user_data file has been created and its converted to base64 format as per the standard.
#!/bin/bash
set -ex
B64_CLUSTER_CA= <My eks cluster Certificate authority value>
API_SERVER_URL= <My EKS cluster API server URl>
/etc/eks/bootstrap.sh <cluster-name> --b64-cluster-ca $B64_CLUSTER_CA --apiserver-endpoint $API_SERVER_URL   
  1. cat bootstrap_user_data | base64
  2. Launch template created via custom-configuration.json file with below data
   cat config_custom_ami.json
{
  "LaunchTemplateData": {
  "EbsOptimized": false,
  "ImageId": "ami-0e00c1f097aff7fe8",
  "InstanceType": "t3.small",
  "UserData": "bootstrap_user_data",
    "SecurityGroupIds": [
     "sg-0e9b58499f42bcd4b"
   ]
 }
}
  1. Security group has been selected EKS cluster security group it was created automatically while creating EKS cluster first time.

  2. creating launch template using eksctl command

aws ec2 create-launch-template  --region eu-central-1  --launch-template-name my-template-name   --version-description "first version "  --cli-input-json file://custom.config.json
  1. creating node group using eksctl command
aws eks create-nodegroup --region eu-central-1 --cluster-name my-cluster  --nodegroup-name my-node-group   --subnets subnet-<subnet1> subnet-<subnet2>  --node-role 'arn:aws:iam::123456789:role/EKSNODEGROUP'   --launch-template name=my-template-name

  1. After executing node group creation command it was taking 20 min to create node group at the same time desired VM is created as part of auto scaling group but nodes group not able to join to the cluster after 20 min.

  2. Connect to your Amazon EKS worker node instance with SSH and check kubelet agent logs

ssh -i my.key [email protected]
sudo -i
cd /etc/eks/bootstrap.sh 
-bash: cd: /etc/eks: No such file or directory

could you please some one help why my bootstrap.sh file not exists inside the /etc/eks location in other hand in AWS console launch template - Advanced tab - i can able to see my user data in decoded format.

Upvotes: 4

Views: 2152

Answers (1)

sir_willy
sir_willy

Reputation: 31

What AMI (Amazon Machine Image) you are using?

If you want to build custom AMI for EKS worker nodes, you need to manually pack bootstrap script into your AMI. You can find the script and more detail on https://github.com/awslabs/amazon-eks-ami.

However, it's strongly not recommended to use custom AMIs since you need to maintain them by yourself. You need to handle security patches and version upgrade by yourself. Consider using Amazon EKS optimized Amazon Linux AMIs and customize it via Userdata or Daemonset.

Upvotes: 0

Related Questions