- Newest
- Most votes
- Most comments
Greeting
Hi Thanh,
It sounds like you've been working diligently to get your Amazon EKS cluster and node group set up. I understand how frustrating it can be to follow the documentation closely and still encounter roadblocks. Let’s break this down step by step and get your node registered successfully. 😊
Clarifying the Issue
From your description, you’ve:
- Created an EKS cluster and node group with nodes placed in a private subnet that has a route to a NAT Gateway.
- Configured the cluster with both public and private endpoints.
- Verified IAM roles for the cluster and node based on the provided AWS documentation.
When you log in to the EC2 instance and run a curl command to the cluster API endpoint, the response shows:
{ "kind": "Status", "apiVersion": "v1", "metadata": {}, "status": "Failure", "message": "forbidden: User \"system:anonymous\" cannot get path \"/\"", "reason": "Forbidden", "details": {}, "code": 403 }
This indicates the request is reaching the cluster, but authentication is failing. Let’s dive into the potential causes and fixes.
Why This Matters
Ensuring that your nodes are properly registered with your EKS cluster is crucial for workload orchestration and scaling. Without this, the cluster cannot schedule pods, and your applications will remain in a pending state. Fixing this issue will enable the nodes to join the cluster and participate in the workload.
Key Terms
- Node Registration: The process by which worker nodes authenticate and join the EKS cluster.
- IAM Instance Profile: An IAM role attached to the EC2 instance, allowing it to perform actions on AWS resources.
- Bootstrap Script: The script executed on worker nodes to configure them to join the EKS cluster.
- Cluster Endpoint: The API server endpoint used for communication between the control plane and worker nodes.
The Solution (Our Recipe)
Steps at a Glance:
- Verify the cluster endpoint and security group settings.
- Ensure the node IAM role is attached and correctly configured.
- Check the bootstrap script on the EC2 instance.
- Validate node group configuration and AWS CLI settings.
Step-by-Step Guide:
Step 1: Verify the Cluster Endpoint and Security Group Settings
Ensure that the security groups associated with your worker nodes allow the following:
- Outbound access to the NAT Gateway or internet via HTTPS (TCP port 443).
- Inbound access from the cluster's control plane to the nodes on port 10250 (for kubelet).
Run this command from your EC2 instance to confirm access to the endpoint:
curl -k https://<cluster-api-endpoint>
The response confirms connectivity, but you’ll need to ensure the cluster recognizes the node.
Step 2: Ensure the Node IAM Role is Attached and Correctly Configured
Verify that the EC2 instance has an IAM role attached with the necessary policies. You can create the required role with this JSON example:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "ec2:Describe*", "eks:DescribeCluster" ], "Resource": "*" }, { "Effect": "Allow", "Action": [ "ecr:GetAuthorizationToken", "ecr:BatchCheckLayerAvailability", "ecr:GetDownloadUrlForLayer", "ecr:BatchGetImage" ], "Resource": "*" } ] }
Attach this role to your EC2 instance via the AWS Management Console.
Step 3: Check the Bootstrap Script on the EC2 Instance
The bootstrap script ensures the worker node registers with the cluster. SSH into the node and verify the logs:
sudo cat /var/log/cloud-init-output.log
Ensure the script includes your cluster name. Example:
#!/bin/bash set -o xtrace /etc/eks/bootstrap.sh <cluster-name> --kubelet-extra-args '--node-labels=node.kubernetes.io/lifecycle=spot'
Replace <cluster-name> with your actual cluster name.
Step 4: Validate Node Group Configuration and AWS CLI Settings
Check the node group settings in the AWS Management Console:
- Ensure the node group is associated with the correct cluster.
- Verify the subnets have proper route tables pointing to the NAT Gateway.
Validate the cluster configuration using the AWS CLI:
aws eks update-kubeconfig --region <region> --name <cluster-name> kubectl get nodes
If the nodes are not listed, review the node group status in the EKS console for additional clues.
Closing Thoughts
Here are some helpful links to troubleshoot and configure your setup further:
- Troubleshooting Amazon EKS Worker Nodes
- Getting Started with Amazon EKS
- IAM Roles for Service Accounts
If these steps don’t resolve your issue, feel free to share the specific error logs, and I’d be happy to assist further. Let’s get this sorted out!
Farewell
Best of luck, Thanh! With these steps, you should be on the right path to resolving the issue. Don’t hesitate to reach out if you need more help. You’ve got this! 🚀😊
Cheers,
Aaron 😊
answered 2 years ago
Relevant content
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
