Bird
Raised Fist0
AWScloud~10 mins

EKS cluster creation in AWS - Commands & Configuration

Choose your learning style10 modes available
Introduction
Creating an EKS cluster lets you run and manage containerized applications on AWS easily. It solves the problem of setting up and managing Kubernetes infrastructure by automating the control plane and worker nodes.
When you want to deploy containerized applications on AWS with Kubernetes without managing the control plane yourself
When you need a scalable and secure environment for running microservices
When you want to integrate your Kubernetes workloads with other AWS services like IAM and CloudWatch
When you want to avoid the complexity of setting up Kubernetes masters and focus on your applications
When you want a managed Kubernetes service that handles upgrades and availability automatically
Config File - cluster.yaml
cluster.yaml
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
  name: example-cluster
  region: us-east-1
nodeGroups:
  - name: ng-1
    instanceType: t3.medium
    desiredCapacity: 2
    ssh:
      allow: true
      publicKeyName: example-key

This file defines the EKS cluster configuration using eksctl format.

  • metadata.name: The cluster name.
  • metadata.region: AWS region to create the cluster.
  • nodeGroups: Defines worker nodes with instance type and count.
  • ssh: Allows SSH access to nodes using the specified key.
Commands
This command creates the EKS cluster and worker nodes as defined in the cluster.yaml file. It automates the setup of control plane and node groups.
Terminal
eksctl create cluster -f cluster.yaml
Expected OutputExpected
[ℹ] eksctl version 0.140.0 [ℹ] using region us-east-1 [ℹ] setting availability zones to [us-east-1a us-east-1b us-east-1c] [ℹ] nodegroup "ng-1" will use "ami-0c55b159cbfafe1f0" [AmazonLinux2/1.21] [ℹ] creating EKS cluster "example-cluster" in "us-east-1" region [ℹ] 1 nodegroup(s) (ng-1) were included (based on the include/exclude rules) [ℹ] will create a CloudFormation stack for cluster itself and 1 nodegroup(s) [✔] all cluster resource for "example-cluster" created [ℹ] nodegroup "ng-1" has 2 node(s) [✔] EKS cluster "example-cluster" in "us-east-1" region is ready
→
-f - Specifies the cluster configuration file to use
This command verifies that the worker nodes are registered and ready in the Kubernetes cluster.
Terminal
kubectl get nodes
Expected OutputExpected
NAME STATUS ROLES AGE VERSION ip-192-168-10-1.us-east-1.compute.internal Ready <none> 5m v1.21.2-eks-0389ca3 ip-192-168-10-2.us-east-1.compute.internal Ready <none> 5m v1.21.2-eks-0389ca3
This command updates your local kubeconfig file to connect kubectl to the new EKS cluster.
Terminal
aws eks update-kubeconfig --name example-cluster --region us-east-1
Expected OutputExpected
Added new context arn:aws:eks:us-east-1:123456789012:cluster/example-cluster to /home/user/.kube/config
→
--name - Specifies the EKS cluster name
→
--region - Specifies the AWS region of the cluster
Key Concept

If you remember nothing else from this pattern, remember: eksctl simplifies EKS cluster creation by automating control plane and node setup with a simple config file.

Common Mistakes
Not updating kubeconfig after cluster creation
kubectl commands will fail because they don't know how to connect to the new cluster
Run 'aws eks update-kubeconfig --name example-cluster --region us-east-1' to configure kubectl
Using an incorrect or missing SSH key name in the config file
You won't be able to SSH into worker nodes if needed
Ensure the SSH key name exists in your AWS account and matches the 'publicKeyName' in the config
Skipping verification of node status with 'kubectl get nodes'
You won't know if worker nodes are ready and connected to the cluster
Always run 'kubectl get nodes' to confirm nodes are in Ready status
Summary
Create an EKS cluster using eksctl with a YAML config file defining cluster and node details.
Update your local kubeconfig to connect kubectl to the new cluster.
Verify worker nodes are ready using 'kubectl get nodes' to ensure the cluster is operational.

Practice

(1/5)
1.

What is the main purpose of creating an Amazon EKS cluster?

easy
A. To store large amounts of data in the cloud
B. To run Kubernetes applications without managing the underlying servers
C. To create virtual machines for running Windows applications
D. To manage user access and permissions in AWS

Solution

  1. Step 1: Understand EKS cluster purpose

    Amazon EKS is a managed Kubernetes service that lets you run containerized applications without managing servers.
  2. Step 2: Compare options

    Options A, B, and D describe other AWS services or functions unrelated to EKS clusters.
  3. Final Answer:

    To run Kubernetes applications without managing the underlying servers -> Option B
  4. Quick Check:

    EKS = Managed Kubernetes service [OK]
Hint: EKS runs Kubernetes without server management [OK]
Common Mistakes:
  • Confusing EKS with EC2 virtual machines
  • Thinking EKS is for data storage
  • Mixing EKS with IAM user management
2.

Which of the following is the correct AWS CLI command to create an EKS cluster named my-cluster with role ARN arn:aws:iam::123456789012:role/EKSRole and subnets subnet-abc123 and subnet-def456?

easy
A. aws eks create-cluster --cluster-name my-cluster --role arn:aws:iam::123456789012:role/EKSRole --vpc-config subnets=subnet-abc123,subnet-def456
B. aws eks create-cluster --name my-cluster --role-arn arn:aws:iam::123456789012:role/EKSRole --resources-vpc-config subnetIds=subnet-abc123 subnet-def456
C. aws eks create-cluster --name my-cluster --role-arn arn:aws:iam::123456789012:role/EKSRole --resources-vpc-config subnetIds=subnet-abc123,subnet-def456
D. aws eks create-cluster --name my-cluster --role arn:aws:iam::123456789012:role/EKSRole --resources-vpc-config subnetIds=subnet-abc123,subnet-def456

Solution

  1. Step 1: Check AWS CLI syntax for EKS cluster creation

    The correct command uses --name for cluster name, --role-arn for IAM role, and --resources-vpc-config subnetIds=... for subnet IDs separated by commas.
  2. Step 2: Identify correct option

    aws eks create-cluster --name my-cluster --role-arn arn:aws:iam::123456789012:role/EKSRole --resources-vpc-config subnetIds=subnet-abc123,subnet-def456 matches the correct syntax exactly. Options A and D use incorrect flags (--cluster-name, --role). aws eks create-cluster --name my-cluster --role-arn arn:aws:iam::123456789012:role/EKSRole --resources-vpc-config subnetIds=subnet-abc123 subnet-def456 misses a comma between subnet IDs.
  3. Final Answer:

    aws eks create-cluster --name my-cluster --role-arn arn:aws:iam::123456789012:role/EKSRole --resources-vpc-config subnetIds=subnet-abc123,subnet-def456 -> Option C
  4. Quick Check:

    Correct CLI syntax = aws eks create-cluster --name my-cluster --role-arn arn:aws:iam::123456789012:role/EKSRole --resources-vpc-config subnetIds=subnet-abc123,subnet-def456 [OK]
Hint: Use --name, --role-arn, and comma-separated subnetIds [OK]
Common Mistakes:
  • Using --role instead of --role-arn
  • Missing commas between subnet IDs
  • Using wrong flag names like --cluster-name
3.

Given this AWS CLI command to create an EKS cluster:

aws eks create-cluster --name test-cluster --role-arn arn:aws:iam::123456789012:role/EKSRole --resources-vpc-config subnetIds=subnet-11111111,subnet-22222222,securityGroupIds=sg-12345678

What will happen after running this command?

medium
A. The command will fail due to incorrect subnet ID format
B. The command will fail because security groups cannot be specified during cluster creation
C. The cluster will be created but only in one subnet ignoring the second subnet
D. The cluster test-cluster will be created using the specified subnets and security group

Solution

  1. Step 1: Understand parameters in the command

    The command specifies cluster name, IAM role, subnet IDs, and security group IDs correctly using --resources-vpc-config.
  2. Step 2: Check if security groups are allowed

    Security groups can be specified during cluster creation to control network access. The subnet IDs are comma-separated and valid format.
  3. Final Answer:

    The cluster test-cluster will be created using the specified subnets and security group -> Option D
  4. Quick Check:

    Valid subnet and security group syntax = The cluster test-cluster will be created using the specified subnets and security group [OK]
Hint: Security groups allowed in --resources-vpc-config [OK]
Common Mistakes:
  • Thinking security groups can't be set at creation
  • Assuming only one subnet is allowed
  • Confusing subnet ID format with invalid syntax
4.

You tried to create an EKS cluster with this command:

aws eks create-cluster --name mycluster --role-arn arn:aws:iam::123456789012:role/EKSRole --resources-vpc-config subnetIds=subnet-12345 subnet-67890

The command failed. What is the most likely cause?

medium
A. Missing comma between subnet IDs in subnetIds parameter
B. Incorrect IAM role ARN format
C. Cluster name mycluster is invalid
D. Subnets are in different availability zones

Solution

  1. Step 1: Review subnetIds parameter format

    The subnet IDs must be comma-separated inside the subnetIds= value. Here, a space separates them, which is invalid syntax.
  2. Step 2: Check other parameters

    The IAM role ARN format looks correct, cluster name is valid, and subnets in different zones are recommended, not an error.
  3. Final Answer:

    Missing comma between subnet IDs in subnetIds parameter -> Option A
  4. Quick Check:

    Comma separates subnet IDs [OK]
Hint: Comma separate subnet IDs, not spaces [OK]
Common Mistakes:
  • Using spaces instead of commas between subnet IDs
  • Assuming cluster name rules cause failure
  • Confusing subnet zones with errors
5.

You want to create a highly available EKS cluster. Which setup is best practice for the network configuration?

  • Use a single subnet in one availability zone
  • Use multiple subnets in different availability zones
  • Use only public subnets
  • Use subnets without any security groups
hard
A. Use multiple subnets in different availability zones
B. Use a single subnet in one availability zone
C. Use only public subnets
D. Use subnets without any security groups

Solution

  1. Step 1: Understand high availability in EKS

    High availability means the cluster stays up even if one zone fails. Using multiple subnets in different availability zones achieves this.
  2. Step 2: Evaluate other options

    Single subnet risks zone failure. Only public subnets expose resources unnecessarily. Subnets without security groups lack network protection.
  3. Final Answer:

    Use multiple subnets in different availability zones -> Option A
  4. Quick Check:

    Multi-AZ subnets = High availability [OK]
Hint: Spread subnets across zones for reliability [OK]
Common Mistakes:
  • Using only one subnet risking downtime
  • Exposing cluster on public subnets unnecessarily
  • Ignoring security groups for network safety
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard