Columns › 6. Deploying the system › Part 34
Deploying on AWS: EKS and Elastic Scaling
在 AWS 上部署:EKS 與彈性伸縮
Move the shop onto AWS: a VPC across three Availability Zones, EKS, ECR, ALB, RDS PostgreSQL Multi-AZ, ElastiCache and Secrets Manager, built with Terraform, with Pod Identity for permissions, GitHub Actions pushing images over OIDC and Argo CD deploying; then elastic scaling in three layers (pods, nodes, data) with HPA, KEDA, Karpenter, connection budgets, scheduled peaks, cost and failure cases.
In this article
- What this article solves
- Step 1: Choose a platform: EKS, ECS Fargate or EC2 Auto Scaling Groups
- Step 2: The architecture on AWS: VPC, Availability Zones and managed services
- Step 3: Build the infrastructure with Terraform
- Step 4: Give pods AWS permissions: Pod Identity and IRSA
- Step 5: Entry point and delivery: ALB, ECR, Argo CD
- Step 6: The three layers of elastic scaling
- Step 7: The pod layer: HPA on CPU, KEDA on lag and time
- Step 8: The node layer: Karpenter
- Step 9: The data layer: connection budgets, proxies, read replicas and caching
- Step 10: Set targets from load tests, so scale-out keeps up
- Step 11: Cost controls and failure cases
- Common pitfalls
- Key takeaways
- References
- Next
The previous article, “Deploying on AWS: Running Container Services on ECS Fargate”, ran containers on AWS with ECS Fargate without touching Kubernetes; when the services grow to need Kubernetes itself, its ecosystem and portability, this article takes over. “Blue-Green and Canary Releases: Doing Them Right and What to Watch For” covered how to shift traffic to a new version safely, and “GitOps with Argo CD: Let the Cluster Follow git on Its Own” had the cluster pull, compare and apply from the config repository by itself. But where that cluster lives, how it gets built, and where nodes come from when traffic spikes are questions the earlier articles deliberately left alone. This article puts the shop on AWS for real: EKS is the main path, wired to AWS networking, databases, caching, secrets and certificates; then “elastic scaling” is split into three layers (pods, nodes and data) and explained one layer at a time. Release strategies (blue-green, canary) apply on AWS unchanged and are not repeated here.
What this article solves
The shop runs a flash sale every Friday at 8 p.m. Normally api-gateway handles a few hundred requests per second; in the first minute of the sale that goes up tenfold. Last time, this is what happened:
- HPA quickly raised
orderto its maximum, but the new pods sat inPendingfor four minutes: there weren’t enough nodes, and the node group had to grow, boot and join the cluster. - When the pods finally came up, database connections ran out: twenty
orderpods with a pool of twenty-five connections each, pluspaymentandinventory, exceeded PostgreSQL’smax_connections, and every new request failed. inventorycouldn’t keep up withorder.placedevents. Tens of thousands of messages piled up in JetStream, but its CPU stayed low, so HPA never moved.- After the sale, a dozen nodes ran empty all night.
None of these is solved by “just add more machines”. Step by step, this article covers:
- Choosing a platform: what EKS, ECS Fargate and EC2 Auto Scaling Groups each fit.
- The architecture on AWS: a VPC, three Availability Zones, public and private subnets, and the role of each managed service.
- Building the VPC, EKS, Karpenter’s permissions, RDS and ECR with Terraform.
- Giving pods AWS permissions: EKS Pod Identity and IRSA, and connecting Secrets Manager.
- The entry point (ALB, ACM, Route 53) and the delivery flow (GitHub Actions pushing to ECR over OIDC, Argo CD deploying).
- The three layers of elastic scaling: what signal each one watches and how quickly it reacts.
- The pod layer: HPA on CPU, KEDA on queue lag and schedules.
- The node layer: Karpenter versus Cluster Autoscaler, Spot versus On-Demand, consolidation and disruption budgets.
- The data layer: connection budgets, RDS Proxy or PgBouncer, read replicas and caching.
- Setting targets from load tests, so that scale-out keeps up with the peak.
- Cost controls and failure cases: scaling too slowly, connection storms, PDBs blocking, an AZ outage.
Step 1: Choose a platform: EKS, ECS Fargate or EC2 Auto Scaling Groups
There is more than one way to run containers on AWS. First, what each of three common options fits:
| Option | What you manage | Fits | Doesn’t fit |
|---|---|---|---|
| EKS (Kubernetes) | Cluster add-ons, node strategy, YAML | Already on Kubernetes, multi-cloud or hybrid, need the Operator and GitOps ecosystem | A team of one or two, few services, nobody wants to learn Kubernetes |
| ECS on Fargate | Task definitions and services; no nodes | Few services, minimal operations wanted, AWS lock-in is acceptable | Need DaemonSets, custom scheduling, Kubernetes-ecosystem tools |
| EC2 + Auto Scaling Group | Machine images, boot scripts, deployment | One large program, special hardware or kernel settings, legacy systems not containerised | Many small services that scale separately, frequent deploys |
The shop picks EKS for a simple reason: everything in “Deploying a Microservice System on Kubernetes”, “A Kubernetes Configuration Reference: What to Write in Each Field, and Why” and the Argo CD setup is a Kubernetes resource, and moves to EKS almost unchanged; NATS, External Secrets and KEDA are all Kubernetes components too.
When would you pick ECS Fargate instead? With only one or two services and nobody willing to maintain Kubernetes add-ons, Fargate lets you write just task definitions, and scaling is ECS Service Auto Scaling (on CPU, memory or ALB requests per target), with no node layer to worry about. An EC2 Auto Scaling Group suits “one program, one machine type, clone the whole box” systems: the unit of scaling is a whole VM, and boot-to-serving is usually slower than for containers, but the model is the simplest.
EKS itself has two node modes worth knowing: manage nodes yourself with Karpenter (this article’s approach), or turn on EKS Auto Mode and let AWS manage node creation, updates and scale-in. Auto Mode removes installing and upgrading Karpenter, but leaves fewer knobs; if you want to go live first and tune later, start with Auto Mode. This article uses self-managed Karpenter because every setting is visible, and the principles carry over to Auto Mode.
Step 2: The architecture on AWS: VPC, Availability Zones and managed services
Figure: internet traffic enters through Route 53 and the ALB; EKS nodes sit in private subnets across three Availability Zones; the RDS primary and standby are in two different zones; outbound traffic goes through each zone’s own NAT gateway.
Read the diagram from the outside in:
- The VPC has three kinds of subnet, one of each per Availability Zone. Public subnets hold only the ALB and NAT gateways; private subnets hold the EKS nodes (and therefore every pod); database subnets hold RDS and ElastiCache and only accept connections from the nodes’ security group. Pods have no public IP, so nothing outside can reach them; outbound traffic goes through NAT.
- Three Availability Zones (AZs). An AZ is a group of data centres with independent power and networking. Service replicas, nodes and the database standby are spread across zones, so when one zone fails the others keep serving.
- One NAT gateway per AZ. A single one is cheaper, but if its zone fails, pods in the other zones lose outbound connectivity too (calls to the payment provider and image pulls all fail). Production gets one per zone; development can make do with one.
The role of each managed service in the shop:
| Component | What it does in the shop | Why use it | When not to |
|---|---|---|---|
| EKS | Runs the four services, NATS and platform components | AWS operates the control plane and keeps it highly available | See Step 1 |
| ECR | Stores the shop/<service> images | Integrated with IAM, so nodes pull without extra credentials; scan on push | You already have a company registry with acceptable latency |
| ALB (AWS Load Balancer Controller) | The public HTTPS entry point, forwarding to api-gateway | Created and updated automatically from an HTTPRoute or Ingress in the cluster | Plain TCP/gRPC pass-through: use an NLB |
| RDS PostgreSQL Multi-AZ | Each service’s own database | AWS handles backups, patching and failover; the standby is in another zone | You need superuser access or unusual extensions |
| ElastiCache (Redis OSS or Valkey) | Caching, rate-limit counters, idempotency keys | No need to run Redis replication and failover yourself | Development only: one pod in the cluster is enough |
| NATS (in cluster) or Amazon MSK (Kafka) | Events: order.placed, payment.completed | The series uses NATS JetStream, installed from the official Helm chart in nats | If you switch to Kafka, let MSK run the brokers and storage |
| Secrets Manager + External Secrets | Database passwords, payment-provider keys | The ExternalSecret from the Argo CD article stays; only the backend changes | — |
| Route 53 + ACM | DNS and the TLS certificate for shop.example.com | ACM certificates renew automatically and attach directly to the ALB | DNS hosted elsewhere: use only ACM and point the record at the ALB there |
| CloudWatch | Metrics and alarms for RDS, ALB and NAT; node and container logs | Metrics for AWS managed services only live here | Application metrics still go to Prometheus (in cluster or Amazon Managed Prometheus) |
Why RDS rather than a PostgreSQL Operator in the cluster? Step 4 of “Deploying a Microservice System on Kubernetes” already made the comparison: production data needs someone responsible for backups, patching and failover. On AWS, RDS turns those into a few parameters. NATS stays in the cluster because it was built for Kubernetes: three nodes in a StatefulSet, with JetStream data on EBS volumes. If you switch to Kafka, running Kafka yourself costs far more, and MSK is worth it.
Step 3: Build the infrastructure with Terraform
AWS resources (VPC, EKS, RDS, IAM) should, like Kubernetes resources, be described in code, kept in git and reviewed before they are applied. Two common tools:
| Tool | What it builds | Fits |
|---|---|---|
| eksctl | EKS clusters, node groups, add-ons, Pod Identity | Building a cluster quickly, experiments, teaching |
| Terraform | Any AWS resource, plus DNS, monitoring and other services | RDS, caches and IAM to manage alongside the cluster |
Besides the cluster, the shop has databases, a cache, ECR and a pile of IAM roles, so it uses Terraform, with the community-maintained terraform-aws-modules modules rather than writing every resource from scratch. Here is an excerpt of production (pin the modules’ major versions and read their changelogs when upgrading):
# infra/prod/main.tf (excerpt: VPC, EKS, Karpenter IAM, RDS, ECR)
locals {
name = "shop-prod"
vpc_cidr = "10.20.0.0/16"
azs = ["ap-northeast-1a", "ap-northeast-1c", "ap-northeast-1d"]
}
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "~> 6.0"
name = local.name
cidr = local.vpc_cidr
azs = local.azs
private_subnets = [for i, az in local.azs : cidrsubnet(local.vpc_cidr, 4, i)]
public_subnets = [for i, az in local.azs : cidrsubnet(local.vpc_cidr, 8, i + 48)]
database_subnets = [for i, az in local.azs : cidrsubnet(local.vpc_cidr, 8, i + 52)]
enable_nat_gateway = true
one_nat_gateway_per_az = true # one AZ failing doesn't take down outbound traffic in the others
public_subnet_tags = {
"kubernetes.io/role/elb" = 1 # the ALB lives in public subnets
}
private_subnet_tags = {
"kubernetes.io/role/internal-elb" = 1
"karpenter.sh/discovery" = local.name # Karpenter finds subnets by this tag
}
}
module "eks" {
source = "terraform-aws-modules/eks/aws"
version = "~> 21.0"
name = local.name
kubernetes_version = var.kubernetes_version # pinned; upgrading is an ordinary change
endpoint_public_access = true
endpoint_public_access_cidrs = ["203.0.113.0/24"] # only the company's egress IPs
enable_cluster_creator_admin_permissions = true
addons = {
coredns = {}
kube-proxy = {}
vpc-cni = { before_compute = true }
eks-pod-identity-agent = { before_compute = true }
}
vpc_id = module.vpc.vpc_id
subnet_ids = module.vpc.private_subnets
# a small managed node group that only runs Karpenter, CoreDNS and other system components
eks_managed_node_groups = {
system = {
instance_types = ["m6i.large"]
min_size = 2
max_size = 3
desired_size = 2
labels = { "karpenter.sh/controller" = "true" }
}
}
node_security_group_tags = {
"karpenter.sh/discovery" = local.name # nodes created by Karpenter use this security group
}
}
# IAM roles, interruption queue and Pod Identity needed by Karpenter
module "karpenter" {
source = "terraform-aws-modules/eks/aws//modules/karpenter"
version = "~> 21.0"
cluster_name = module.eks.cluster_name
node_iam_role_use_name_prefix = false
node_iam_role_name = "${local.name}-karpenter-node"
create_pod_identity_association = true
}
resource "aws_db_instance" "order" {
identifier = "shop-prod-order"
engine = "postgres"
engine_version = "17"
instance_class = "db.r6g.large"
allocated_storage = 100
max_allocated_storage = 500 # upper limit for storage autoscaling
multi_az = true
db_subnet_group_name = module.vpc.database_subnet_group_name
vpc_security_group_ids = [aws_security_group.order_db.id] # only the node security group may reach 5432 (omitted)
db_name = "order"
username = "shop_admin"
manage_master_user_password = true # RDS keeps the master password in Secrets Manager and rotates it
storage_encrypted = true
backup_retention_period = 14
deletion_protection = true
performance_insights_enabled = true
}
resource "aws_ecr_repository" "shop" {
for_each = toset(["api-gateway", "order", "payment", "inventory"])
name = "shop/${each.key}"
image_tag_mutability = "IMMUTABLE" # a tag can never be pushed again
image_scanning_configuration {
scan_on_push = true
}
}A few decisions worth explaining:
- The control plane’s public endpoint is open only to company IPs. With GitOps, CI no longer needs to reach the cluster (the point of the Argo CD article), so the only API clients are engineers and Argo CD inside the cluster. Stricter still: turn off the public endpoint and allow access only through a VPN.
- A small managed node group runs system components. Karpenter must not manage the node it runs on, or consolidation could evict it; so it and CoreDNS run on a fixed pair of nodes, and every other workload is left to Karpenter.
manage_master_user_password. The master password never appears in Terraform variables or state. Each service’s application account (order_app) is created separately, stored in Secrets Manager undershop/prod/order, and fetched by External Secrets (Step 4).- ECR tags are immutable. “A Kubernetes Configuration Reference: What to Write in Each Field, and Why” asks for git SHAs as tags;
IMMUTABLEmakes the registry guarantee it, so nobody can replace what3f2c1a9e4b7dpoints to. - Terraform state lives in S3 (versioned and encrypted) with locking, never on someone’s laptop; state holds resource details, so access to it must be as strict as access to production.
ElastiCache and the other three services’ databases follow the same shape and aren’t repeated here.
Step 4: Give pods AWS permissions: Pod Identity and IRSA
Two components in the shop call AWS APIs: External Secrets Operator reads Secrets Manager, and payment’s reconciliation CronJob downloads the payment provider’s settlement files from S3. The worst approach is to create an IAM user’s long-lived keys and put them in a Secret: if they leak, everything must be rotated, and every pod holding them has the same permissions.
EKS offers two mechanisms for “this ServiceAccount maps to that IAM role”:
Figure: the pod runs as ServiceAccount payment; EKS injects a dedicated token based on the association; the SDK asks the Pod Identity Agent on the node for credentials, and the agent exchanges them through EKS Auth for temporary credentials of the role.
| Aspect | EKS Pod Identity | IRSA (IAM Roles for Service Accounts) |
|---|---|---|
| Where it’s set up | An EKS “Pod Identity association” (cluster, namespace, SA, role) | An OIDC identity provider per cluster, plus an annotation on the SA |
| Role trust policy | Always trusts pods.eks.amazonaws.com; one policy shared by clusters | Must name one cluster’s OIDC URL and the SA; changing cluster means editing |
| Requires | The eks-pod-identity-agent add-on | The cluster’s OIDC provider |
| Not supported on | Pods on Fargate; Kubernetes outside EKS | — |
| Fits | New setups on EKS (recommended) | Fargate, existing setups, reusing the same approach outside EKS |
The shop uses Pod Identity. The role’s trust policy trusts only the EKS Pod Identity service, and its permission covers only the one S3 path it needs:
# infra/prod/iam-payment.tf
resource "aws_iam_role" "payment" {
name = "shop-prod-payment"
assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [{
Effect = "Allow"
Principal = { Service = "pods.eks.amazonaws.com" }
Action = ["sts:AssumeRole", "sts:TagSession"]
}]
})
}
resource "aws_iam_role_policy" "payment_settlements" {
name = "read-settlement-files"
role = aws_iam_role.payment.id
policy = jsonencode({
Version = "2012-10-17"
Statement = [{
Effect = "Allow"
Action = ["s3:GetObject"]
Resource = "arn:aws:s3:::shop-prod-settlements/*"
}]
})
}
resource "aws_eks_pod_identity_association" "payment" {
cluster_name = module.eks.cluster_name
namespace = "shop"
service_account = "payment"
role_arn = aws_iam_role.payment.arn
}Nothing changes on the Kubernetes side: the payment ServiceAccount was created back in the configuration reference, and automountServiceAccountToken: false stays. Pod Identity injects a separate, dedicated token (whose only use is EKS Auth), not the Kubernetes API token. After deploying, check with kubectl describe pod that the container has the two environment variables AWS_CONTAINER_CREDENTIALS_FULL_URI and AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE; code that uses the AWS SDK’s default credential chain then gets the permissions automatically, with no keys anywhere.
With IRSA, the difference is an extra annotation on the ServiceAccount, and a trust policy that names this cluster’s OIDC provider:
# only needed with IRSA
apiVersion: v1
kind: ServiceAccount
metadata:
name: payment
annotations:
eks.amazonaws.com/role-arn: arn:aws:iam::111122223333:role/shop-prod-payment
automountServiceAccountToken: falseDon’t let pods reach the node’s role. Nodes have their own IAM role (to pull images and join the cluster); if a pod can read the node’s Instance Metadata Service (IMDS), it can borrow the node’s permissions. Nodes created by Karpenter default to IMDSv2 with a response hop limit of 1, so containers can’t reach it; check that managed node groups have the same setting.
Connecting Secrets Manager. External Secrets Operator gets a role the same way, one that can only read shop/prod/* (associated with its own ServiceAccount, whose name depends on how it was installed). The ExternalSecret from the Argo CD article references a ClusterSecretStore named prod-secrets; now point it at AWS:
# platform/external-secrets/cluster-secret-store.yaml
apiVersion: external-secrets.io/v1
kind: ClusterSecretStore
metadata:
name: prod-secrets
spec:
provider:
aws:
service: SecretsManager
region: ap-northeast-1
# no auth: use the controller pod's default credentials, i.e. the Pod Identity role
conditions:
- namespaces: ['shop']conditions restricts this store to ExternalSecrets in the shop namespace, so other namespaces can’t use this role to read the shop’s secrets. Take the actions ESO’s role needs from its documentation (reading needs at least secretsmanager:GetSecretValue and DescribeSecret), with resources limited to shop/prod/*.
Step 5: Entry point and delivery: ALB, ECR, Argo CD
The entry point. Routing in this series has always been the Gateway API: the platform creates a Gateway and the shop only writes an HTTPRoute pointing at api-gateway. On EKS, the AWS Load Balancer Controller (from v2.14) can turn a Gateway and HTTPRoute into an ALB, so the HTTPRoute from “Deploying a Microservice System on Kubernetes” doesn’t change by a single line; only the platform side switches to an ALB Gateway:
# platform/gateway/public.yaml
apiVersion: gateway.networking.k8s.io/v1
kind: GatewayClass
metadata:
name: aws-alb
spec:
controllerName: gateway.k8s.aws/alb
---
apiVersion: gateway.k8s.aws/v1
kind: LoadBalancerConfiguration
metadata:
name: public-alb
namespace: gateway-system
spec:
scheme: internet-facing # the default is internal, reachable only from inside the VPC
listenerConfigurations:
- protocolPort: HTTPS:443
defaultCertificate: arn:aws:acm:ap-northeast-1:111122223333:certificate/example
---
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: public
namespace: gateway-system
spec:
gatewayClassName: aws-alb
infrastructure:
parametersRef:
group: gateway.k8s.aws
kind: LoadBalancerConfiguration
name: public-alb
listeners:
- name: https
protocol: HTTPS
port: 443
allowedRoutes:
namespaces:
from: Selector
selector:
matchLabels:
kubernetes.io/metadata.name: shopACM issues the certificate (DNS-validated, then renewed automatically), and Route 53 points shop.example.com at the ALB with an alias record. If your cluster uses Ingress, the same controller turns an Ingress into an ALB; the idea is the same.
Delivery. Only two things change in the CI script from Step 9 of the Argo CD article: images go to ECR, and how CI gets permission to push. Don’t store long-lived AWS keys in GitHub; use OIDC: every GitHub Actions run gets a short-lived identity token, and AWS, following a trust policy, exchanges it for temporary credentials of a role that can only push to ECR.
Figure: GitHub Actions exchanges an OIDC token for temporary credentials, pushes images to ECR and writes the new tag into the config repository; Argo CD in the cluster pulls the config and nodes pull images from ECR. CI never holds any cluster permissions.
The CI role’s trust policy only lets the main branch of the example/shop repository assume it:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Federated": "arn:aws:iam::111122223333:oidc-provider/token.actions.githubusercontent.com"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringEquals": {
"token.actions.githubusercontent.com:aud": "sts.amazonaws.com",
"token.actions.githubusercontent.com:sub": "repo:example/shop:ref:refs/heads/main"
}
}
}
]
}The role’s permissions are only the actions needed to push to the shop/* ECR repositories. The workflow:
# .github/workflows/release.yaml
name: release
on:
push:
branches: [main]
permissions:
id-token: write # ask GitHub for an OIDC token
contents: read
jobs:
images:
runs-on: ubuntu-latest
env:
AWS_REGION: ap-northeast-1
REG: 111122223333.dkr.ecr.ap-northeast-1.amazonaws.com
steps:
- uses: actions/checkout@v6
- uses: aws-actions/configure-aws-credentials@v6
with:
role-to-assume: arn:aws:iam::111122223333:role/shop-ci-ecr-push
aws-region: ${{ env.AWS_REGION }}
- name: Build and push
run: |
aws ecr get-login-password --region "$AWS_REGION" \
| docker login --username AWS --password-stdin "$REG"
SHA="$(git rev-parse --short=12 HEAD)"
for svc in api-gateway order payment inventory; do
docker buildx build --build-arg SERVICE="$svc" \
-f deploy/docker/Dockerfile -t "$REG/shop/$svc:$SHA" --push .
done
# then, as in the Argo CD article: update the dev tag in shop-deploy and push; prod via PR(In production, pin third-party actions to a commit SHA rather than a major-version tag; see “Microservice Security: Authentication, Authorisation, Secrets and Supply Chain” for why.)
The config repository gains just one thing: the prod overlay’s images uses newName to replace registry.example.com/shop/<service> with the ECR address. Nodes pull from ECR with the node role’s permissions, so no imagePullSecrets are needed.
Who manages what. AWS resources are managed by Terraform and everything inside the cluster by Argo CD. Keep the boundary clear, or the two will overwrite each other:
| Managed by Terraform | Managed by Argo CD (config repository) |
|---|---|
| VPC, EKS, managed node group, RDS, ElastiCache, ECR, IAM roles | The shop’s four services, HPA/ScaledObject, PDB, HTTPRoute |
| Pod Identity associations, ACM certificates, Route 53 zones | Platform components: Load Balancer Controller, KEDA, ESO, metrics-server, NATS |
| Karpenter’s IAM and interruption queue | Karpenter itself (Helm) and its NodePool and EC2NodeClass |
Karpenter is the one to be careful with: Argo CD runs on nodes, and nodes are created by Karpenter. So both Karpenter and Argo CD run on the system node group built by Terraform; even if Karpenter breaks, Argo CD can still apply the fixed configuration.
Step 6: The three layers of elastic scaling
Back to the flash sale. Each problem actually sits in a different layer:
Figure: the pod layer adjusts replicas on CPU, queue lag and time; the node layer adds and removes machines based on pending pods; the data layer must have connections, read replicas and cache prepared in advance. The faster a layer above scales, the more pressure lands on the layer below.
| Layer | Components | Signals | Reaction time (order of magnitude) | Which opening problem |
|---|---|---|---|---|
| Pods | HPA, KEDA | CPU utilisation, JetStream lag, a schedule | Tens of seconds | inventory lag, HPA not moving |
| Nodes | Karpenter (or Cluster Autoscaler) | Pending pods that don’t fit; idle or underused nodes | One to several minutes | Pods pending for four minutes, empty nodes |
| Data | RDS, RDS Proxy, ElastiCache | Connections, CPU, replication lag, cache hit rate | Minutes to tens of minutes, or done in advance | Connections exhausted |
Three key points:
- Each layer has a different speed. Pods scale fast, nodes more slowly, and databases slowest (changing instance class or adding a read replica takes many minutes). The data layer can’t rely on “scale when needed”; capacity must be worked out beforehand.
- Scaling out one layer becomes load on the layer below. Going from 5 pods to 20 multiplies database connections by four. Tuning only HPA without a connection budget just pushes the problem down.
- Scaling in matters as much as scaling out. Scale-out affects availability, scale-in affects the bill; scaling in too eagerly means scaling out again on the next wave, and the replica count oscillates.
The next three steps take these layers in order.
Step 7: The pod layer: HPA on CPU, KEDA on lag and time
HPA needs metrics-server. First make sure the cluster has it (kubectl top pods -n shop returns results); without it, HPA can’t read CPU utilisation and just shows <unknown>. Once it’s installed, the HPA from “Deploying a Microservice System on Kubernetes” and the behavior from the configuration reference work as they are. api-gateway and order serve synchronous requests, so CPU tracks traffic and they stay on CPU:
| Service | Shape of the load | Scaling signal | Why |
|---|---|---|---|
| api-gateway | Every request passes through; CPU rises with requests | CPU (HPA) | Simplest and most reliable; no extra components |
| order | Synchronous requests plus saga coordination | CPU (HPA) | Same as above |
| payment | Mostly waiting on the payment provider; low CPU | No autoscaling; a fixed, sufficient replica count | The bottleneck is external; more replicas won’t make the provider faster |
| inventory | Consumes order.placed events | JetStream lag + CPU (KEDA) | When events pile up, CPU isn’t necessarily high; look at the queue itself |
Why should inventory watch lag? A consumer’s workload is “how many messages are still unprocessed”, not CPU. It may spend most of its time waiting for the database at 30% CPU while fifty thousand messages pile up. HPA on its own only sees Kubernetes metrics; to watch a queue you need to bring external metrics in, and that’s what KEDA does: it reads event sources (NATS, Kafka, SQS, Prometheus…), then creates and manages an HPA for you.
# apps/base/inventory/scaledobject.yaml
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: inventory
spec:
scaleTargetRef:
name: inventory
minReplicaCount: 2
maxReplicaCount: 30
pollingInterval: 15
advanced:
horizontalPodAutoscalerConfig:
behavior:
scaleUp:
stabilizationWindowSeconds: 0
policies:
- type: Percent
value: 100
periodSeconds: 30
scaleDown:
stabilizationWindowSeconds: 300
policies:
- type: Pods
value: 2
periodSeconds: 60
triggers:
- type: cpu
metricType: Utilization
metadata:
value: '70'
- type: nats-jetstream
metadata:
natsServerMonitoringEndpoint: nats.nats.svc.cluster.local:8222
account: $G
stream: ORDERS
consumer: inventory
lagThreshold: '200'
- type: cron
metadata:
timezone: Asia/Taipei
start: 30 19 * * 5
end: 30 23 * * 5
desiredReplicas: '12'Item by item:
nats-jetstreamreads a consumer’s pending count from NATS’s monitoring port (8222).lagThreshold: '200'means “each replica handles 200 messages of lag”: a lag of 4,000 needs 20 replicas.accountis the NATS account, the default$Gwhen you don’t use multiple accounts;streamandconsumermust match the real names, so check them withnats consumer ls ORDERS(Watermill builds durable names fromDurablePrefixand the topic).- Several triggers take the maximum. If CPU asks for 4 replicas, lag for 20 and the schedule for 12, you get 20. Whichever signal says “more” wins.
cronis a scheduled floor. Every Friday from 19:30 to 23:30 there are at least 12 replicas, ready before the sale starts instead of chasing the lag once it appears. Always settimezone, or the times are read as UTC.behavioris written as in the configuration reference; KEDA puts it into the HPA it creates.
Don’t let an HPA and a ScaledObject manage the same Deployment. KEDA creates an HPA named keda-hpa-inventory; if the original inventory HPA still exists, the two HPAs fight over the replica count. So apps/base/inventory/kustomization.yaml replaces hpa.yaml with scaledobject.yaml. The dev overlay shrank every HPA with a JSON patch; the ScaledObject needs its own patch (on /spec/minReplicaCount and /spec/maxReplicaCount). The HPA created by KEDA isn’t in git; Argo CD shows it as a child of the ScaledObject and doesn’t mark it out of sync.
cooldownPeriod is not a scale-in cooldown. It only applies between “scale to 0” and “activate from 0”; when minReplicaCount is above 0, the scale-in pace comes from the behavior above. None of the shop’s services scale to 0: the first request would wait for a cold start, which isn’t worth it for a transactional system.
The Kafka version. If you switch to MSK, replace the nats-jetstream trigger with a kafka trigger described by bootstrapServers, consumerGroup, topic and lagThreshold; the idea is exactly the same. Note that Kafka replicas beyond the topic’s partition count are useless: the extra consumers get no partition and sit idle. Keep maxReplicaCount at or below the partition count.
Step 8: The node layer: Karpenter
With the pod layer scaling, the next question is where the pods go. HPA raises replicas from 5 to 20; the existing nodes can’t fit them, and the extra pods are Pending. The node-layer component sees pending pods and finds machines for them. Two choices:
| Aspect | Cluster Autoscaler | Karpenter |
|---|---|---|
| How it scales out | Raises the desired count of a node group (Auto Scaling Group) | Creates the best-fitting EC2 instance directly from the pending pods’ needs |
| Instance types | Each node group has a fixed set of types decided in advance | Picks from an allow-list; can mix sizes, generations, architectures, Spot/On-Demand |
| Scale-in | Removes underused nodes whose pods can move | Consolidation: removes empty nodes or replaces them with smaller, cheaper ones |
| Fits | Many existing node groups; one tool across clouds | New clusters on EKS; varied workload shapes; using Spot to cut cost |
The shop uses Karpenter. It needs two resources: an EC2NodeClass describes what the machine looks like on AWS (AMI, subnets, security groups, node role), and a NodePool describes which machines may be created, the limits, and when they may be removed:
# platform/karpenter/default.yaml
apiVersion: karpenter.k8s.aws/v1
kind: EC2NodeClass
metadata:
name: default
spec:
role: shop-prod-karpenter-node # matches node_iam_role_name in Terraform
amiSelectorTerms:
- alias: al2023@v20240625 # format example: use the current version and pin it; change it here to upgrade, Karpenter replaces nodes in batches
subnetSelectorTerms:
- tags:
karpenter.sh/discovery: shop-prod
securityGroupSelectorTerms:
- tags:
karpenter.sh/discovery: shop-prod
---
apiVersion: karpenter.sh/v1
kind: NodePool
metadata:
name: default
spec:
template:
spec:
nodeClassRef:
group: karpenter.k8s.aws
kind: EC2NodeClass
name: default
requirements:
- key: karpenter.sh/capacity-type
operator: In
values: ['spot', 'on-demand']
- key: kubernetes.io/arch
operator: In
values: ['amd64']
- key: karpenter.k8s.aws/instance-category
operator: In
values: ['c', 'm', 'r']
- key: karpenter.k8s.aws/instance-generation
operator: Gt
values: ['5']
expireAfter: 720h
limits:
cpu: '200'
memory: 400Gi
disruption:
consolidationPolicy: WhenEmptyOrUnderutilized
consolidateAfter: 5m
budgets:
- nodes: '10%'
# 11:00-23:00 Taiwan time daily (12 hours from 03:00 UTC): don't remove nodes for being underutilised
- nodes: '0'
reasons: ['Underutilized']
schedule: '0 3 * * *'
duration: 12hWhy allow so many instance types? The wider the list, the easier it is for Karpenter to find a machine that is available and cheap right now, and the less likely Spot capacity is reclaimed. Allowing only m6i.large throws away Karpenter’s biggest advantage.
Spot and On-Demand. Spot is AWS’s spare capacity at a much lower price, but when AWS needs it back it sends a notice and then reclaims it (the Terraform Karpenter module created a queue for interruption events; Karpenter moves pods off early when it receives one). When a NodePool allows both, Karpenter prefers Spot and falls back to On-Demand. What belongs on Spot are stateless, multi-replica services that can be moved at any time: api-gateway, order, inventory. An interrupted request to the payment provider is more awkward to handle (even though idempotency keys protect correctness), so payment is pinned to On-Demand nodes:
# apps/overlays/prod/patches/payment-on-demand.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: payment
spec:
template:
spec:
nodeSelector:
karpenter.sh/capacity-type: on-demandConsolidation and disruption budgets. WhenEmptyOrUnderutilized lets Karpenter remove a node when it is empty or when its pods can move elsewhere and save money; consolidateAfter: 5m is how long a node’s pods must stay unchanged before it is considered. That is how the dozen empty nodes after the sale disappear within minutes. budgets limits how many nodes can be disrupted at once: at most 10% normally, and no consolidation for “underutilised” during business peak hours (empty and expired nodes are still handled). Note that schedule has no time-zone support: it is always UTC.
PDBs are the pods’ brakes. When Karpenter removes a node, it evicts pods according to their PDBs; maxUnavailable: 1 means each service loses one replica at a time. Individual pods that must not be interrupted (a running reconciliation Job, say) can carry the annotation karpenter.sh/do-not-disrupt: "true", and Karpenter won’t voluntarily remove their node.
Spreading across zones. The topologySpreadConstraints from “Deploying a Microservice System on Kubernetes” only spread across nodes; on AWS, add a rule that spreads across zones:
# add to each service's pod template
topologySpreadConstraints:
- maxSkew: 1
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: ScheduleAnyway
labelSelector:
matchLabels:
app.kubernetes.io/name: order
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: ScheduleAnyway
labelSelector:
matchLabels:
app.kubernetes.io/name: orderKarpenter creates nodes in the right zones according to the pending pods’ spread requirements. ScheduleAnyway rather than DoNotSchedule is deliberate: if one zone temporarily has no capacity, it’s better to run the pods unevenly than not at all.
Step 9: The data layer: connection budgets, proxies, read replicas and caching
The opening connection problem is arithmetic. Each pod’s pool limit (Go’s db.SetMaxOpenConns) times the number of pods is the most connections that service will ever open:
Figure: the top half connects directly, 20 pods with 25 connections each, exceeding the database limit; the bottom half goes through RDS Proxy, which takes the pods’ connections so the database only sees the small set the proxy maintains.
Every PostgreSQL connection is a backend process that uses memory; max_connections defaults to a value derived from the instance’s memory (check it with SHOW max_connections). Whenever HPA’s maxReplicas goes up, the budget must be recomputed. Three approaches, depending on the situation:
| Approach | How | Fits | Watch out for |
|---|---|---|---|
| Compute the pool limit | MaxOpenConns × maxReplicas ≤ budget (the program in Step 10) | A narrow replica range with enough connections | Recompute whenever the replica limit changes; with few connections per pod, requests may queue at peak |
| RDS Proxy | A managed connection pool between the application and RDS | Pod counts vary a lot, connections open and close often; reduce the impact of failover | Only fronts the writer, not read replicas; session state (SET, advisory locks and so on) “pins” connections so they can’t be shared |
| PgBouncer (in cluster) | A pool you run yourself, usually in transaction mode | Avoiding another AWS bill, finer control | You run its high availability; in transaction mode session-level features are restricted too, so check your driver and version settings |
The shop’s choice: order and payment go through RDS Proxy (RDS Proxy connects to the database with credentials from Secrets Manager, the same ones ESO uses), and pool limits are still set from the budget, with the proxy as a second safeguard. RDS Proxy also means application connections don’t all have to be rebuilt during a Multi-AZ failover.
Read replicas. order’s “my orders” list and back-office reports are read-heavy and can go to RDS read replicas, taking load off the primary. The price is replication lag: an order just placed may not be visible on the replica yet, so “order details shown right after checkout” read from the primary and only lists and reports read from replicas. Each RDS read replica has its own endpoint, and spreading across several is up to you; when you want one reader endpoint with replicas added and removed automatically, Aurora PostgreSQL’s reader endpoint and replica auto scaling fit better. When to split reads and writes and when to shard is covered in full, from the angle of scale, in the next article.
Caching. Product details for the sale page and inventory’s “approximate count” live in ElastiCache, which absorbs most reads. Two things to watch: a cache avalanche when many keys expire at once (add random jitter to expiry), and a flood of requests going to the source when a hot key expires (let one request refill while the others wait). Scaling ElastiCache (adding shards or replicas) also takes time, and like the database must be prepared in advance.
NATS itself. JetStream’s three nodes should be spread over three zones, with EBS (gp3) volumes. It doesn’t scale with traffic; before a peak, check that the stream’s storage limit and disk space can hold several hours of backlog.
Step 10: Set targets from load tests, so scale-out keeps up
The 70% for HPA, the 200 for lagThreshold and the 20 for maxReplicas should never be guesses. The process:
- Measure one pod’s capacity. Pin one
orderpod to a node and ramp load with a tool such as k6, finding how many requests per second it handles while p99 latency stays on target, and at what CPU. Say you measure 150 requests per second at about 70% CPU: that is HPA’s target and one pod’s capacity. - Derive the replica limit from the peak. Expected peak times headroom, divided by one pod’s capacity.
- Derive the connection budget from the replica limit. The replica limit times each pod’s pool must fit in the database’s budget.
- Measure how long scale-out takes. Drive the whole system with a realistic traffic curve (tenfold within one minute) and record the time from the rise in traffic until new pods are Ready.
Steps 2 and 3 can be a small program in the config repository’s CI, checking every change to maxReplicas or the pool size:
package main
import (
"fmt"
"math"
)
// Input holds the numbers measured in load tests and the database's limits
type Input struct {
PeakRPS float64 // expected peak requests per second
PodRPS float64 // requests per second one pod handles within the latency target
Headroom float64 // extra margin; 0.25 means 25% more
MinReplicas int
ConnsPerPod int // each pod's SetMaxOpenConns
DBMaxConns int // the database's max_connections
ReservedConns int // kept for migrations, admin tools and monitoring
}
// Plan is the derived configuration
type Plan struct {
MaxReplicas int // HPA's maxReplicas
PeakConns int // connections when every replica's pool is full
Budget int // connections available to this service
FitsDB bool // whether PeakConns fits in the budget
MaxConnsPerPod int // the most each pod may open at MaxReplicas
}
func Compute(in Input) (Plan, error) {
if in.PodRPS <= 0 || in.PeakRPS < 0 || in.Headroom < 0 {
return Plan{}, fmt.Errorf("unreasonable input: %+v", in)
}
n := int(math.Ceil(in.PeakRPS * (1 + in.Headroom) / in.PodRPS))
n = max(n, in.MinReplicas, 1)
budget := in.DBMaxConns - in.ReservedConns
if budget <= 0 {
return Plan{}, fmt.Errorf("connection budget is %d: more reserved than the limit", budget)
}
peak := n * in.ConnsPerPod
return Plan{
MaxReplicas: n,
PeakConns: peak,
Budget: budget,
FitsDB: peak <= budget,
MaxConnsPerPod: budget / n,
}, nil
}
func main() {
for _, conns := range []int{10, 25} {
p, err := Compute(Input{
PeakRPS: 2400, PodRPS: 150, Headroom: 0.25, MinReplicas: 3,
ConnsPerPod: conns, DBMaxConns: 300, ReservedConns: 30,
})
if err != nil {
fmt.Println(err)
continue
}
fmt.Printf("%d per pod: maxReplicas=%d, peak connections=%d, budget=%d, fits=%v, max per pod=%d\n",
conns, p.MaxReplicas, p.PeakConns, p.Budget, p.FitsDB, p.MaxConnsPerPod)
}
}Output:
10 per pod: maxReplicas=20, peak connections=200, budget=270, fits=true, max per pod=13
25 per pod: maxReplicas=20, peak connections=500, budget=270, fits=false, max per pod=13The opening incident is the second line: 25 connections per pod and twenty replicas make 500. With 10 per pod (or going through RDS Proxy), the same replica count fits in the budget.
How long does scale-out take? The diagram below is the timeline of one scale-out. The numbers are illustrative; measure the real ones with step 4:
Figure: after traffic rises, HPA waits for the metrics to reflect it before adding replicas; pods that don’t fit on existing nodes go Pending; Karpenter creates a node, the node joins the cluster, images are pulled, readiness passes, and only then do the new pods share the traffic. The longest stretch is usually starting the new node.
The diagram suggests several ways to shorten this, each suited to a different situation:
| Method | Which stretch it shortens | Fits | Cost |
|---|---|---|---|
Scale early with KEDA cron | All of it (done beforehand) | Peaks at known times: sales, on-the-hour events | Fixed cost during the window |
| Spare capacity (low-priority placeholder pods) | Starting a new node | Sudden but frequent peaks | Paying for a few extra nodes all the time |
| Smaller images, programs that start fast | Image pull, start-up | Every service | Almost none; Go static binaries are small anyway |
More aggressive scale-up behavior | The HPA stretch | Very steep traffic rises | Short spikes also scale out and must scale back |
| Lower HPA target utilisation | Gives each pod more headroom | Scale-out can’t keep up and you don’t want lots of standing spare capacity | More replicas in normal times |
Spare capacity means running a few pods that do nothing, with a negative priority, to “hold” node capacity for the real services. When a real pod needs room, the scheduler evicts a placeholder and places the real pod immediately; the evicted placeholder becomes Pending and makes Karpenter add a new node in the background:
# platform/overprovisioning.yaml
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
name: overprovisioning
value: -10
globalDefault: false
description: Placeholder; any normal pod may take its place
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: overprovisioning
namespace: overprovisioning
spec:
replicas: 2
selector:
matchLabels:
app.kubernetes.io/name: overprovisioning
template:
metadata:
labels:
app.kubernetes.io/name: overprovisioning
spec:
priorityClassName: overprovisioning
terminationGracePeriodSeconds: 0
containers:
- name: pause
image: registry.k8s.io/pause:3.10
resources:
requests:
cpu: '2'
memory: 4GiThe two placeholders each hold 2 cores and 4 GiB, so about 4 cores of space is always ready. This Deployment does set replicas, because it has no HPA; during the sale window you can raise it with KEDA’s cron.
Step 11: Cost controls and failure cases
Cost. One purpose of elastic scaling is not paying for idle capacity, but it needs guard rails:
- The NodePool’s
limits. 200 CPU cores and 400 GiB of memory cap the whole NodePool. A misconfigured HPA or a bug in a loop can’t grow the bill without bound. - Spot for stateless services, Savings Plans for the steady baseline. Capacity that is always there gets a commitment discount; the fluctuating part goes on Spot.
- Consolidation and scaling dev down after hours. The development environment uses KEDA’s
cronto shrink replicas to the minimum at night, and Karpenter then removes the empty nodes. - You can only control what you can see. Tag resources (
service,env), break down the AWS bill by tag, and set AWS Budgets alerts. NAT gateway data-processing charges are often overlooked: when image pulls from ECR and calls to S3 all go through NAT, they add up; adding VPC endpoints for S3 and ECR keeps that traffic off the NAT. - ARM (Graviton). Usually cheaper for the same performance. Go cross-compiles easily, but images must be built multi-arch (
docker buildx build --platform linux/amd64,linux/arm64), and the NodePool’skubernetes.io/archgetsarm64added.
Failure cases. Think through how things can go wrong beforehand, and rehearse them:
| Case | Symptoms | Countermeasures |
|---|---|---|
| Scaling out too slowly | Rising latency; pods pending for minutes | Scale early with cron for known peaks; spare capacity; measure scale-out time and leave HPA targets enough headroom |
| Connection storm | New pods connect at once; database CPU spikes or connections run out | Connection budget, RDS Proxy; pools that don’t open fully at start-up; retries with jitter (“Timeouts, Retries and Circuit Breakers”) |
| A PDB blocks a node | Karpenter can’t remove nodes; an AMI upgrade never finishes | PDBs with maxUnavailable: 1; no minAvailable: 1 on single-replica services; cap with terminationGracePeriod when needed |
| Mass Spot reclamation | Nodes of one type vanish together | Allow many instance types and several zones; PDBs and multiple replicas; critical services on On-Demand |
| An Availability Zone fails | A third of nodes and pods vanish; RDS may fail over | Spread pods across zones; one NAT per zone; RDS Multi-AZ; plan capacity to survive the peak with one zone missing |
| RDS failover | Writes fail for a minute or two; connections drop | Code reconnects and retries idempotent operations; RDS Proxy shortens the impact; readiness doesn’t check the database, so pods don’t all drop out at once |
| KEDA can’t read NATS monitoring | The ScaledObject’s metric errors; replicas stop changing | Monitor KEDA’s own metrics and events; set minReplicaCount to a value that survives normal traffic |
Zone failure belongs in the capacity plan. Spread evenly across three zones, losing one leaves two-thirds of the capacity. If all three zones are already at 70% at peak, the remaining two must take more than double their load; Karpenter will add nodes, but those few minutes are the incident. Ask the capacity question as: “with one zone gone, can we still survive the peak?”
Common pitfalls
- HPA installed, metrics-server not. HPA shows
<unknown>, the replica count stays at the minimum, and you find out at the first peak. - An HPA and KEDA managing the same Deployment. The two HPAs fight over the replica count; services using a ScaledObject must drop their original HPA.
- Treating
cooldownPeriodas a scale-in cooldown. It only governs scaling to 0; the scale-in pace belongs inadvanced.horizontalPodAutoscalerConfig.behavior. - Raising the replica limit without recomputing the pool. The better the pod layer scales, the sooner the database is crushed by connections;
maxReplicas × MaxOpenConnsmust fit in the budget. - Assuming RDS Proxy can front read replicas. It only fronts the writer; handle replicas separately, or use Aurora’s reader endpoint.
- Karpenter running on nodes it manages. Consolidation may evict it; it and Argo CD go on the fixed node group built by Terraform.
- A NodePool that allows only one instance type. Spot gets reclaimed easily and capacity runs out, and Karpenter’s advantage is gone.
- Reading a disruption budget’s
scheduleas local time. It is UTC; Taiwan time minus eight hours. - An AMI alias of
@latest. Every new release marks all nodes as drifted and replaces them one after another; pin the version in production and upgrade as an ordinary change. - Only one NAT gateway. When its zone fails, outbound traffic from every pod fails with it.
- Long-lived AWS keys stored in CI. Use OIDC, with the trust policy limited to the repository and branch.
- Pods that can read the node’s IMDS. That is the node role’s permissions handed over; use IMDSv2 with a hop limit of 1.
- More Kafka consumer replicas than partitions. The extras sit idle; keep
maxReplicaCountat or below the partition count. - Capacity planned only for “all zones healthy”. With one zone gone the peak isn’t survivable, and a failure becomes an incident.
Key takeaways
- Systems already on Kubernetes choose EKS; few services and minimal operations choose ECS Fargate; clone-the-whole-box monoliths choose EC2 Auto Scaling Groups.
- The VPC spans three Availability Zones: public subnets hold only the ALB and NAT, nodes sit in private subnets, databases in database subnets; production has one NAT gateway per zone.
- Terraform manages AWS resources (VPC, EKS, RDS, ECR, IAM) and Argo CD manages what’s in the cluster; Karpenter and Argo CD run on a fixed system node group.
- Pods get AWS permissions through EKS Pod Identity (IRSA on Fargate), one least-privilege role per ServiceAccount; CI exchanges OIDC for temporary credentials to push to ECR and stores no long-lived keys.
- Elastic scaling has three layers: pods (HPA, KEDA), nodes (Karpenter) and data (connection budget, RDS Proxy, read replicas, caching); the lower the layer, the slower it is and the more it must be prepared in advance.
- Synchronous services scale on CPU; event consumers use KEDA on lag; known peaks are scaled early with
cron; several signals take the maximum. - Karpenter uses a wide instance list, mixes Spot and On-Demand, consolidates idle nodes, protects peak hours with disruption budgets (in UTC), and PDBs protect each service.
maxReplicas × MaxOpenConnsmust fit in the database’s budget; measure one pod’s capacity and the scale-out time with load tests instead of guessing.- Cost comes from NodePool limits, Spot, Savings Plans, tags and budget alerts; capacity planning asks “can we survive the peak with one zone gone?”
References
- Learn how EKS Pod Identity grants pods access to AWS services (official AWS documentation): how Pod Identity works and that Fargate pods are not supported, used in step 4.
- Disruption (official Karpenter documentation): consolidation,
do-not-disruptand disruption budget schedules in UTC, used in step 8. - NodeClasses (official Karpenter documentation): the EC2NodeClass IMDS defaults (hop limit 1, IMDSv2 required), used in steps 4 and 8.
- ScaledObject specification (official KEDA documentation):
cooldownPeriodapplying only to scaling to zero and theadvancedHPA behavior, used in step 7. - NATS JetStream (official KEDA documentation):
lagThreshold, the default$Gaccount and the monitoring endpoint, used for inventory in step 7. - Amazon RDS Proxy (official AWS documentation): a proxy can only be associated with the writer instance, not a read replica, as noted in step 9.
- AWS Load Balancer Controller: Gateway API (official AWS Load Balancer Controller documentation): HTTPRoute to ALB support starting in v2.14, used in step 5.
- Configuring OpenID Connect in Amazon Web Services (official GitHub documentation): GitHub Actions exchanging OIDC tokens for AWS credentials and restricting
sub, used in step 5.
Next
The shop now runs on AWS, and when traffic rises the pod, node and data layers each know how to respond. The next article, “Deploying on GCP: Running Container Services on Cloud Run”, moves to another cloud: running the same services on GCP with Cloud Run, and mapping each AWS component to its counterpart to see where the two clouds work the same and where they differ.