Sub topic 2
Who Can Talk to the Cluster
Assume you know pods, Deployments, Services, namespaces, kubectl, YAML, IAM, VPCs, and basic AWS CLI commands.
Who Can Talk to the Cluster
EKS separates authentication from authorization:
- IAM identifies the AWS principal, such as a user or role.
- EKS access entries map that principal to Kubernetes permissions.
- Kubernetes RBAC grants permissions to resources and actions.
Give administrators access through an IAM role, not personal long-lived keys. Then bind the role to an appropriate EKS access policy or Kubernetes group.
aws eks create-access-entry \
--cluster-name demo \
--principal-arn arn:aws:iam::111122223333:role/platform-admin
aws eks associate-access-policy \
--cluster-name demo \
--principal-arn arn:aws:iam::111122223333:role/platform-admin \
--policy-arn arn:aws:eks::aws:cluster-access-policy/AmazonEKSClusterAdminPolicy \
--access-scope type=clusterThe IAM role authenticates the caller. RBAC or an EKS access policy decides what that caller may do.
Deploying and Inspecting an Application
A Deployment maintains two nginx pods. A ClusterIP Service gives those pods a stable internal address.
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
spec:
replicas: 2
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: web
image: nginx:stable
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: web
spec:
selector:
app: web
ports:
- port: 80
targetPort: 80kubectl apply -f web.yaml
kubectl get deployment,pods,service web
kubectl describe pod -l app=web
kubectl logs deploy/webGiving Pods AWS Permissions
Do not place AWS keys in a container. Use a Kubernetes service account with temporary credentials.
IRSA uses an IAM OIDC provider and role trust policy. EKS Pod Identity uses the Pod Identity Agent and a trust policy for pods.eks.amazonaws.com.
eksctl create iamserviceaccount \
--cluster demo \
--namespace default \
--name s3-reader \
--attach-policy-arn arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess \
--approveGrant only the actions and resources the workload needs.
Managing Cluster Add-ons
Install critical integrations as managed EKS add-ons when possible. Common examples include the VPC CNI, CoreDNS, kube-proxy, EBS CSI driver, and Pod Identity Agent. Check versions during Kubernetes upgrades and monitor their health.
Exposing Services Through ALB and NLB
The AWS Load Balancer Controller creates an Application Load Balancer from an Ingress. Use it for HTTP routing, TLS termination, and host or path rules.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: web
annotations:
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/target-type: ip
spec:
ingressClassName: alb
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: web
port:
number: 80Use a Network Load Balancer when you need TCP, UDP, static IP behavior, or very high-throughput network traffic.
Exercise
A pod is running, but its Service has no endpoints. What should you inspect first?
Show answer
Compare the Service selector with the labels on the pod template. They must match exactly.