Deploying workloads on EKS in AWS - Time & Space Complexity
When deploying workloads on EKS, it is important to understand how the time to deploy grows as you add more workloads.
We want to know how the number of deployments affects the total time and operations needed.
Analyze the time complexity of the following operation sequence.
aws eks create-cluster --name my-cluster --role-arn role-arn --resources-vpc-config subnetIds=subnet-123,subnet-456
aws eks create-nodegroup --cluster-name my-cluster --nodegroup-name nodegroup1 --subnets subnet-123 subnet-456 --instance-types t3.medium
aws eks update-kubeconfig --name my-cluster
kubectl apply -f workload1.yaml
kubectl apply -f workload2.yaml
kubectl apply -f workloadN.yaml
This sequence creates an EKS cluster, adds a node group, configures access, and deploys multiple workloads.
Identify the API calls, resource provisioning, data transfers that repeat.
- Primary operation: Applying each workload manifest with
kubectl apply. - How many times: Once per workload, so it repeats for each workload deployed.
Each workload requires a separate apply operation, so as you add more workloads, the number of operations grows directly with the number of workloads.
| Input Size (n) | Approx. Api Calls/Operations |
|---|---|
| 10 | 10 apply operations |
| 100 | 100 apply operations |
| 1000 | 1000 apply operations |
Pattern observation: The total operations increase in a straight line as workloads increase.
Time Complexity: O(n)
This means the time to deploy grows directly in proportion to the number of workloads you deploy.
[X] Wrong: "Deploying multiple workloads happens all at once, so time stays the same no matter how many workloads."
[OK] Correct: Each workload requires its own deployment step, so more workloads mean more steps and more time.
Understanding how deployment time grows with workload count helps you plan and explain scaling in cloud environments confidently.
"What if we deployed all workloads using a single combined manifest file? How would the time complexity change?"
Practice
Solution
Step 1: Understand EKS functionality
Amazon EKS is a managed Kubernetes service that lets you run containers without managing the underlying servers.Step 2: Compare options
Storing data relates to services like S3, creating VMs to EC2, and managing permissions to IAM--none of which is EKS's core purpose.Final Answer:
To run containerized applications using Kubernetes without managing servers -> Option AQuick Check:
EKS = Managed Kubernetes for containers [OK]
- Confusing EKS with storage services like S3
- Thinking EKS manages virtual machines directly
- Mixing EKS with IAM user management
app-deployment.yaml on EKS?Solution
Step 1: Identify the kubectl command for applying YAML
The correct command to deploy resources defined in a YAML file iskubectl apply -f filename.Step 2: Evaluate other options
kubectl run app-deployment.yamlis for running individual pods, not applying YAML manifests.eksctl create app app-deployment.yamlmisuses eksctl, which is primarily for EKS cluster creation.aws eks deploy app-deployment.yamlis not a valid AWS CLI command.Final Answer:
kubectl apply -f app-deployment.yaml -> Option DQuick Check:
Deploy YAML with kubectl apply -f [OK]
- Using eksctl for direct YAML deployment
- Confusing kubectl run with apply
- Trying AWS CLI commands that don't exist
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
spec:
replicas: 3
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: myapp-container
image: nginx:latest
What will be the number of running pods after applying this deployment?
Solution
Step 1: Read the replicas field in the Deployment spec
The YAML specifiesreplicas: 3, which means Kubernetes will create 3 pods for this deployment.Step 2: Understand pod creation behavior
Unless there is a scheduling issue, Kubernetes will run 3 pods as requested.Final Answer:
3 -> Option BQuick Check:
replicas = number of pods running [OK]
- Assuming only 1 pod runs by default
- Thinking pods depend on node capacity without error
- Confusing selector labels with pod count
kubectl apply -f deployment.yaml, but got an error: error: unable to recognize "deployment.yaml": no matches for kind "Deploy". What is the likely cause?Solution
Step 1: Analyze the error message
The error says no matches for kind "Deploy", which means Kubernetes does not recognize this resource kind.Step 2: Check the YAML kind field
The correct kind for workload deployment is "Deployment", not "Deploy". This typo causes the error.Final Answer:
The YAML file has a typo in the kind field; it should be 'Deployment' not 'Deploy' -> Option CQuick Check:
Kind field must be exact Kubernetes resource name [OK]
- Ignoring error details about resource kind
- Assuming cluster or kubectl issues without checking YAML
- Blaming image name for syntax errors
Solution
Step 1: Identify resource for managing pod replicas with scaling
A Deployment manages stateless pods and can be combined with a Horizontal Pod Autoscaler (HPA) to scale pods based on CPU.Step 2: Understand autoscaling setup
Set Deployment replicas to minimum 2, and HPA to scale up to max 5 pods based on CPU usage.Step 3: Evaluate other options
StatefulSet is for stateful apps, DaemonSet runs pods on all nodes (not scaling pods), fixed replicas do not autoscale.Final Answer:
A Deployment with replicas set to 2 and a Horizontal Pod Autoscaler targeting CPU usage with max replicas 5 -> Option AQuick Check:
Deployment + HPA = autoscaling pods [OK]
- Using StatefulSet for stateless apps
- Confusing DaemonSet with autoscaling pods
- Setting fixed replicas without autoscaler
Ready to prove it?
Pass the test and this pattern moves unknown
