Skip to content

Intermediate · Containers in the cloud · topic 33 of 50 · 30 min

Managed Kubernetes: EKS, AKS and GKE

Explanation

Kubernetes is an open-source container orchestrator: a control plane decides where pods (groups of containers) run on worker nodes, and Deployments and Services describe what you want. Managed Kubernetes means the cloud runs and upgrades the control plane for you: Amazon EKS, Azure Kubernetes Service (AKS) and Google Kubernetes Engine (GKE). GKE Autopilot and EKS with Fargate go further and manage the nodes too.

Why Kubernetes?

ECS works only on AWS. Kubernetes (often written K8s) is an open-source orchestrator that runs the same way on every cloud and in your own data centre. The same manifests (YAML files that describe your app) work on EKS, AKS and GKE with small changes. It has a huge ecosystem of tools, but it is also complex. The DevOps course goes deep; this lesson gives you the one picture you need for the cloud.

Kubernetes in one picture

  • Control plane: the brain. The API server receives every request, etcd stores the cluster state, the scheduler picks a node for each new pod, and controllers keep fixing the difference between what you asked for and what is running.
  • Worker nodes: the machines (usually VMs) that run your containers. Each runs a kubelet agent and a container runtime.
  • Pod: the smallest unit Kubernetes runs, one or more containers that share a network address.
  • Deployment: says "keep 3 copies of this pod running, with this image" and handles rolling updates.
  • Service: a stable name and IP address in front of a changing set of pods, so other apps can find them.
Think of it like this: Think of a railway control room. The control plane is the control room: it knows where every train is and decides which platform each new train uses. The nodes are the platforms. The pods are the trains. A Deployment is the timetable that says "three trains on this route at all times". If a train breaks down, the control room sends another.

The key idea is desired state. You do not say "start a container on node 2". You declare what you want, and the control plane keeps making reality match it, all day.

yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: orders-api
spec:
  replicas: 3
  selector:
    matchLabels:
      app: orders-api
  template:
    metadata:
      labels:
        app: orders-api
    spec:
      containers:
        - name: api
          image: asia-south1-docker.pkg.dev/shop-prod/apps/orders-api:1.0.0
          ports:
            - containerPort: 8080
          resources:
            requests:
              cpu: 250m
              memory: 256Mi
            limits:
              memory: 512Mi
---
apiVersion: v1
kind: Service
metadata:
  name: orders-api
spec:
  selector:
    app: orders-api
  ports:
    - port: 80
      targetPort: 8080
A Deployment of 3 pods and a Service in front of them. 250m means 250 millicores, a quarter of a CPU.
bash
kubectl apply -f orders-api.yaml           # create or update everything in the file
kubectl get pods -l app=orders-api         # list the pods
kubectl rollout status deployment/orders-api
kubectl logs deployment/orders-api         # logs from one of its pods
kubectl is the Kubernetes command-line tool. The same commands work on EKS, AKS and GKE.

What "managed control plane" means

Running the control plane yourself means keeping etcd backed up, the API server highly available, and every part patched and upgraded. With managed Kubernetes, the cloud provider runs the control plane, keeps it available, patches it and helps you upgrade it. You still own your workloads, and in most modes you still own the worker nodes.

Kubernetes releases a new minor version roughly three times a year, and each version is supported for a limited time. Plan upgrades: usually the control plane first, then the nodes. Read the release notes for removed APIs. Staying on an old version can cost extra or force an upgrade at a bad time.

The three managed services

Amazon EKSAzure AKSGoogle GKE
Control plane costPer-cluster hourly fee (higher for versions in extended support)Free tier, or paid Standard and Premium tiers with an uptime SLAPer-cluster management fee, with a monthly credit that covers one zonal or Autopilot cluster per billing account
NodesManaged node groups (EC2), self-managed nodes, or Fargate profilesNode pools built on VM Scale SetsStandard: node pools you manage; Autopilot: Google manages nodes
You pay forCluster fee plus EC2 or FargateTier fee (if any) plus node VMsStandard: fee plus node VMs; Autopilot: fee plus the CPU and memory your pods request
Connect kubectlaws eks update-kubeconfigaz aks get-credentialsgcloud container clusters get-credentials

EKS managed node groups create and update the EC2 instances for you. A Fargate profile says which pods (by namespace and labels) run on Fargate instead of nodes, so there is no server to manage for them. AWS also offers EKS Auto Mode, which manages nodes for you. In GKE, a regional cluster spreads the control plane and nodes across three zones, so the loss of one zone does not stop the cluster. Pricing details change, so check each provider's current pricing page.

bash
gcloud container clusters create-auto shop --region asia-south1
gcloud container clusters get-credentials shop --region asia-south1
aws eks update-kubeconfig --name shop --region ap-south-1
az aks get-credentials --resource-group shop-rg --name shop-aks
Create a GKE Autopilot cluster, then point kubectl at a cluster on each cloud.

Common mistakes and how to fix them

  • Pods without resource requests. The scheduler cannot place them well and Autopilot cannot bill them sensibly. Fix: set CPU and memory requests on every container.
  • Using the latest image tag. Fix: use version tags or digests so rollouts and rollbacks are predictable.
  • A single-zone cluster for production. Fix: use a regional cluster or spread nodes across zones.
  • Skipping upgrades until the version leaves support. Fix: upgrade on a schedule, test in staging first.
  • Giving every Service type LoadBalancer. Each one creates a cloud load balancer that costs money. Fix: use one Ingress or Gateway for many services.
  • Many tiny clusters, each paying a control plane fee. Fix: use namespaces to share a cluster where it is safe.

Need help?

Stuck on a word or an idea? Search this course, or every course, and jump straight to the explanation or a worked question.

Try:

Watch the lesson

Managed Kubernetes: EKS, AKS and GKE · 1/8

Kubernetes

Kubernetes is an open source container orchestrator that runs the same way on every cloud.

Prefer a video by a teacher? Find free videos on “managed kubernetes eks aks gke comparison tutorial” on YouTube ↗

In real life: A logistics company in Bengaluru moves to GKE Autopilot

A logistics company in Bengaluru runs 25 microservices for tracking parcels. The platform team of three ran a self-managed Kubernetes cluster on VMs and spent most weekends patching it. They moved to a regional GKE Autopilot cluster in asia-south1. Google now runs the control plane and the nodes; the team sets CPU and memory requests on each Deployment and pays for what the pods request. Upgrades happen in maintenance windows they choose. The same YAML manifests still work in their local test cluster, so developers did not have to learn anything new.

Practice (0/3 done)

Task 1 · Code · Python

Estimate how many identical nodes a set of pods needs. pods is a list of dicts with "cpu_m" (millicores requested per pod), "mem_mi" (MiB requested per pod) and "replicas". node_cpu_m and node_mem_mi are what ONE node can give to pods. Write nodes_needed(pods, node_cpu_m, node_mem_mi): add up total CPU and total memory over all replicas, divide each by one node's capacity rounding UP, and return the larger number. If any single pod needs more CPU or memory than one node has, return -1, because it can never be scheduled. (Real schedulers pack pod by pod, so treat this as a lower bound.)

Task 2 · Question

In GKE Autopilot mode, what do you mainly pay for besides the cluster fee?

Task 3 · Practice

Deploy the orders-api example (or any small web image) to a Kubernetes cluster: a local one (kind or minikube) or a small managed cluster on a free trial. Apply a Deployment with 3 replicas and a Service, change the image tag to roll out a new version, then roll it back. Delete any cloud cluster when you finish.

Quick quiz

Question 1

1.In Kubernetes, which part picks a node for each new pod?

Question 2

2.What does "managed control plane" mean in EKS, AKS and GKE?

Question 3

3.Which EKS feature runs selected pods without any EC2 nodes to manage?

Question 4

4.What does a GKE regional cluster give you compared with a zonal one?

Question 5

5.Which command points kubectl at an AKS cluster?

Read more (free)

Open a question to see the answer and why. The first ones are this topic's own quiz, so try the quiz above before you peek.

In Kubernetes, which part picks a node for each new pod?

Answer: The scheduler in the control plane

The scheduler is a control plane component that assigns pods to nodes.

What does "managed control plane" mean in EKS, AKS and GKE?

Answer: The provider runs, patches and keeps the control plane available; you manage workloads

The provider operates the control plane; your Deployments, Services and usually nodes remain yours.

Which EKS feature runs selected pods without any EC2 nodes to manage?

Answer: Fargate profiles

A Fargate profile selects pods by namespace and labels and runs them on Fargate.

What does a GKE regional cluster give you compared with a zonal one?

Answer: A control plane and nodes spread across three zones in the region

Regional clusters replicate the control plane and nodes across zones, so one zone failing does not stop the cluster.

Which command points kubectl at an AKS cluster?

Answer: az aks get-credentials

az aks get-credentials writes the AKS cluster details into your kubeconfig.

Which component decides which node a new pod should run on?Related

Answer: kube-scheduler

The scheduler watches for pods with no node assigned and picks a node based on resources and rules.

From Why Kubernetes, and how a cluster works

When is managed Kubernetes usually worth its extra complexity?Related

Answer: For many services, with platform skills and a need for Kubernetes tools

Kubernetes pays off at scale and with the people to run it.

From Choosing where to run a container

When would the EC2 launch type make more sense than Fargate?Related

Answer: For a steady, heavy workload that needs GPUs or special instance types

The EC2 launch type gives you control of instance types such as GPUs, and can be cheaper for steady, tightly packed load.

From Amazon ECS and AWS Fargate

Which service runs your container, scales with traffic and can scale down to zero?Related

Answer: Cloud Run

Cloud Run is serverless containers with scale to zero.

From Core Google Cloud services

Pass the quiz (60% or more) or mark this topic as done when you are ready.

Your progress is saved on this device only.

Next steps

  1. 1 more topic in “Containers in the cloud” before its exam: Choosing where to run a container.
  2. Module 8 exam: Containers in the cloud · 12 questions · 20 min, without help. 4 topics of this module still to finish first.
  3. Then the next module, Infrastructure as code. 50 topics left in the course before the final exam.

← Previous: Amazon ECS and AWS Fargate