SlideShare a Scribd company logo
1 of 93
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
E L A S T I C C O N TA I N E R S E R V I C E F O R K U B E R N E T E S
(EKS)
Re Alvarez Parmar
@realz reparmar@amazon.com
Nikita Patil
nikipat@amazon.com
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Agenda
10:00am EKS Overview and Roadmap
12:00pm Lunch
12:30pm EKS Workshop Hands on Lab
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Why Containers?
• Speed
• Efficiency
• Easier packaging
• Less risky deployments
• Better Development
experience
• Microservices Photo & Licence
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Customer use cases
Microservices
PaaS
Platform-as-a-Service Enterprise App
Migration
Machine Learning
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Challenges of Containers at Scale
• More transient
• More distributed and complex
• Networking
• Scheduling / Resource Management
• Less isolated (containers can share a kernel)
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS container services landscape
Management
Deployment, Scheduling,
Scaling & Management of
containerized applications
Hosting
Where the containers run
Amazon Elastic
Container Service
Amazon Elastic
Container Service
for Kubernetes
Amazon EC2 AWS Fargate
Image Registry
Container Image Repository
Amazon Elastic
Container Registry
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Open source container
management platform
Helps you run
containers at scale
Gives you primitives
for building modern
applications
What is Kubernetes?
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Cloud-native applications
M I C R O S E R V I C E
T O O L I N G
C L O U D N AT I V E
A P P L I C AT I O N S
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
But where you run Kubernetes matters
Quality of the
cloud platform
Quality of the
applications
Your users
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
51%of Kubernetes workloads
run on AWS today
— Cloud Native Computing Foundation
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
“Run Kubernetes for me.”
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Tenet 1
EKS is a platform for enterprises
to run production-grade
workloads
Tenet 2
EKS provides a native and
upstream Kubernetes experience
Tenet 3
Provide seamless integration with
AWS services and eliminate
undifferentiated heavy lifting
Tenet 4
EKS team actively contributes
to the Kubernetes project
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EKS is Kubernetes Certified
Kubernetes Conformance
• Guaranteed Portability and Interoperability
• Timely Updates
• Confirmability
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
0
20
40
60
80
100
120
140
160
jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov
AWS Contributions to Kubernetes in 2018
AWS contributions to Kubernetes
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EKS Architecture Overview
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Kubernetes on AWS
Highly available
Scalable
Secure
3x Kubernetes API Servers for HA
3x Kubernetes etcd Servers for HA
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Availability
Zone 1
Availability
Zone 2
Availability
Zone 3
API Servers
etcd
Worker nodes
EKS Overview
AWS
Managed
Customer
Managed
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
[mycluster].eks.amazonaws.com
Availability
Zone 1
Availability
Zone 2
Availability
Zone 3
Kubectl
AWS Cloud
VPC
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EKS – Creating your cluster
C r e a t e c l u s t e r
C r e a t e H A c o n t r o l
p l a n e
I A M i n t e g r a t i o n
C e r t i f i c a t e
m a n a g e m e n t
S e t u p L B
A d d W o r k e r
N o d e s
aws eks create-cluster --name devel --role-arn arn:aws:iam::111122223333:role/eks-service-
role-AWSServiceRoleForAmazonEKS-EXAMPLEBKZRQR --resources-vpc-config
subnetIds=subnet-a9189fe2,subnet-50432629,securityGroupIds=sg-f5c54184
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Describe Cluster
$ aws eks describe-cluster --name devel
HTTP/1.1 200 Content-type: application/json
{ "cluster":
{
"clusterName": "string",
"createdAt": number,
"currentMasterVersion": "string",
"desiredMasterVersion": "string",
"masterEndpoint": "string",
"roleArn": "string",
"status": "string",
"statusMessage": "string"
}
}
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EKS Architecture
EKS VPCCustomer VPC
Worker Nodes
EKS-Owned
ENI
Kubernetes
API calls
Exec, Logs,
Proxy
Internet
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EKS Logging
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EKS Logging
EKS ManagedCustomer Account
Internet
Amazon
CloudWatch
AWS
CloudTrail
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
WorkerWorkerMaster
WorkerWorkerMaster
ASG
AZ1
Region
AZ2
ASG
CloudWatch
Logs
Elasticsearch
Kibana
Fluentd
DaemonSet
Kubectl logs
Elasticsearch (index),
Fluentd (store), and
Kibana (visualize)
EKS Logging
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Helm: Package Manager for Kubernetes
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• Helm not only is a package manager, but also a Kubernetes
application deployment management tool
• It helps you to:
• achieve a simple (one command) and repeatable deployment
• manage application dependency, using specific versions of other
application and services
• manage multiple deployment configurations: test, staging, production and
others
• execute post/pre deployment jobs during application deployment
• update/rollback and test application deployments
Helm: package manager for Kubernetes
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EKS Identity & Access Management
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Identity & Access Management (IAM)
IAM enables secure access to AWS services and resources
Granular controls for Kubectl and pods
Two IAM roles created
for K8s cluster
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
K8s action allowed/denied
IAM roles for Kubectl
Authorizes AWS Identity with RBAC
K8s API
Passes AWS Identity
Verifies AWS Identity
AWS Auth
1
2
3
4
Kubectl
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Worker provisioning
k u b e c t l
A W S A u t h
c o n f i g m a p & R B A C
W o r k e r s
R o l e
R o l e
config map
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
IAM roles for Pods
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
IAM Roles for Pods
AWS proposed solution
Makes use of Kubernetes TokenRequestProjection
Tokens to assume an IAM role
Needs Kubernetes v1.11 & latest AWS SDKs
AWS CloudTrail support at launch
Coming
Soon
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SAML 2.0 – Integrate with AD and SSO
M A
AWS Directory
Service
On-premises users
and groups
Manage Permissions to
AWS accounts
sts:AssumeRole
On-premises
Microsoft Active
Directory
AD Connector / AD
Trust
IAM role
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EKS Networking
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Native VPC networking
with CNI plugin
Pods have the same VPC
address inside the pod
as on the VPC
Simple, secure networking
Open source and
on Github
…{ }
https://github.com/aws/amazon-vpc-cni-k8s
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
VPC CNI plugin
• Bridge between the K8s and – AWS VPC
• A W S R o u t a b l e I P s
• Thin layer – no performance impact
• Pod IP ENI secondary IP
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
R u n t i m e
N e t w o r k
p l u g i n
N e t w o r k
c o n f i g u r a t i o n
CNI Infrastructure
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
K u b e l e t
V P C C N I
p l u g i n
1 . C N I A d d / D e l e t e
E C 2
E N I E N I E N I
P o d P o d P o d P o d
V P C
N e t w o r k
.........
0 . C r e a t e E N I
2 . S e t u p v e t h
VPC Networking Internals
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
VPC CNI plugin architecture
K u b e l e t
V P C C N I
p l u g i n
N e t w o r k l o c a l
c o n t r o l p l a n e
E N I s /
S e c o n d a r y I P s
C N I A d d / D e l e t e
g R P C
E C 2
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS VPC CNI plugin
ENI
Secondary IPs:
10.0.0.1
10.0.0.2
10.0.0.1
10.0.0.2
ENI
10.0.0.20
10.0.0.22
Secondary IPs:
10.0.0.20
10.0.0.22
ec2.associateaddress()
VPC Subnet –
10.0.0.0/24
Instance 1 Instance 2
VPC
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS VPC CNI plugin – Understanding IP allocation
• Primary CIDR range è RFC 1918 addresses è 10/8, 172.16/12, 192.168/16
Used in EKS for:
• Pods
• X-account ENIs for (masters à workers) communication (exec, logs, proxy
etc.)
• Internal Kubernetes services network (10.100/16 or 172.20/16 – chosen based on
your VPC range)
Setup: EKS cluster creation è provide list of subnets (in at least 2 AZs!) è tagging
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS VPC CNI plugin – Understanding IP Allocation
• Secondary CIDR ranges (new!) è non-RFC 1918 address blocks (100.64.0.0/10
and 198.19.0.0/16)
Used in EKS for:
• Pods only
How?
• EKS custom network config è enable è create ENIConfig CRD è annotate
nodes
CNI
1.2.1+
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS VPC CNI plugin
ENI
Secondary IPs:
10.0.0.1
10.0.0.2
10.0.0.1
10.0.0.2
ENI
10.0.0.20
10.0.0.22
Secondary IPs:
10.0.0.20
10.0.0.22
ec2.associateaddress()
VPC Subnet –
10.0.0.0/24
Instance 1 Instance 2
VPC
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS VPC CNI plugin - configurability
• Custom Network Configs
• SNAT / External SNAT
• Configurable warm pool
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Packet flow : pod - to - pod
E C 2
Default namespace
Pod namespace
veth veth
Main RT
E C 2
Default namespace
Pod namespace
veth
Route
Table
Main RT
ENI RT
veth
VPC
fabric
ENI RT
Route
Table
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Packet flow : pod - to external
E C 2
Default namespace
Pod namespace
veth
Route
Table
Main RT
ENI RT
veth
External
Network
IPTables
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Frontend
Cats Dogs
kind: NetworkPolicy
apiVersion: extensions/v1beta1
metadata:
name: default-deny
spec:
podSelector:
matchLabels: {}
dev-namespace
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Frontend
Cats Dogs
kind: NetworkPolicy
apiVersion: extensions/v1beta1
metadata:
name: default-deny
spec:
podSelector:
matchLabels: {}
dev-namespace
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Frontend
Cats Dogs
dev-namespace
apiVersion: extensions/v1beta1
kind: NetworkPolicy
metadata:
name: public-to-frontend
spec:
podSelector:
matchLabels:
role: frontend
ingress:
- from:
- ipBlock:
cidr: "0.0.0.0/0"
ports:
- protocol: TCP
port: 80
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Frontend
Cats Dogs
dev-namespace
apiVersion: extensions/v1beta1
kind: NetworkPolicy
metadata:
name: public-to-frontend
spec:
podSelector:
matchLabels:
role: frontend
ingress:
- from:
- ipBlock:
cidr: "0.0.0.0/0"
ports:
- protocol: TCP
port: 80
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Frontend
Cats Dogs
dev-namespace
apiVersion: extensions/v1beta1
kind: NetworkPolicy
metadata:
name: frontend-to-cats
spec:
podSelector:
matchLabels:
role: cats
ingress:
- from:
- podSelector:
matchLabels:
role: “frontend”
ports:
- protocol: TCP
port: 80
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Frontend
Cats Dogs
dev-namespace
apiVersion: extensions/v1beta1
kind: NetworkPolicy
metadata:
name: frontend-to-cats
spec:
podSelector:
matchLabels:
role: cats
ingress:
- from:
- podSelector:
matchLabels:
role: “frontend”
ports:
- protocol: TCP
port: 80
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
That looks good. But, what about isolation?
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
kubectl create namespace prod-namespace
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Frontend
Cats Dogs
dev-namespace
Frontend
Cats Dogs
prod-namespace
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Frontend
Cats Dogs
prod-namespace
apiVersion: extensions/v1beta1
kind: NetworkPolicy
metadata:
name: frontend-to-cats-and-dogs
namespace: prod-namespace
spec:
podSelector:
matchLabels:
role: cats-and-dogs
ingress:
- from:
- podSelector:
matchLabels:
role: “frontend”
ports:
- protocol: TCP
port: 80
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Networking: Pod to service
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• Exposes the service on a cluster-internal IP
• Only reachable from within the cluster
• Access possible via kube-proxy
• Useful for debugging services, connecting from
your laptop or displaying internal dashboards
Kubernetes ServiceType: ClusterIP
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Kubernetes ServiceType: NodePort
• Exposes the service on each Node’s IP at a
static port.
• Routes to a ClusterIP service, which is
automatically created.
• from outside the cluster:
<NodeIP>:<NodePort>
• 1 service per port
• Uses ports 30000-32767
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• Exposes the service externally using a cloud
provider’s load balancer.
• NodePort and ClusterIP services (to which LB
will route) automatically created.
• Each service exposed with a LoadBalancer (ELB
or NLB) will get its own IP address
• Exposes L4 (TCP) or L7 (HTTP) services
Kubernetes ServiceType: LoadBalancer
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Service load balancer: NLB
apiVersion: v1
kind: Service
metadata:
name: nginx
namespace: default
labels:
app: nginx
annotations:
service.beta.kubernetes.io/aws-load-balancer-type: "nlb"
spec:
externalTrafficPolicy: Local
ports:
- name: http
port: 80
protocol: TCP
targetPort: 80
selector:
app: nginx
type: LoadBalancer
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Service load balancer: NLB
• NLB supports forwarding the client’s IP through to the node
• .spec.externalTrafficPolicy = Local è client ip passed to pod
• Nodes with no matching pods will be removed by specified NLB’s health check
.spec.healthCheckNodePort
• Use DaemonSet or pod anti-affinity to verify even traffic split
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• exposes HTTP/HTTPS routes
to services within the cluster
• Many implementations: ALB,
Nginx, F5, HAProxy etc
• Default Service Type:
ClusterIP
Kubernetes Ingress Object
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
ALB Ingress Controller
AWS Resources
Kubernetes Cluster
Node Node
Kubernetes
API Server ALB Ingress
Controller
Node
HTTP ListenerHTTPS Listener
Rule: /cheesesRule: /charcuterie
TargetGroup:
Green (IP Mode)
TargetGroup:
Blue (Instance
Mode)
NodePort NodePort
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Kubernetes Autoscaling with Amazon EKS
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Pod Autoscaling Options
• HPA: de-facto method
• Cluster-proportional-autoscaler
• k8s-rabid-pod-autoscaler
• Kube-sqs-autoscaler
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EKS – Pod Scaling by HPA
• Horizontal pod scaling
• Automatically scales number of pods in replication
controller
• Implemented as a Kubernetes API resource and a
controller.
• The controller periodically adjusts # of replicas in a
replication controller or deployment to match the observed
average CPU utilization to the target specified by user.
• HPA can scale on custom and external metrics (any metric
collected by metrics server api) instead of simply CPU and
memory..
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Cluster Autoscaling Options
• Cluster Auto-scaler (CA): de-facto method
• Kubernetes-ec2-autoscaler
• kube-aws-autoscaler
• Atlassian Escalator: batch or job optimized horizontal
autoscaler
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Cluster auto-scaler
• Deployed As a daemon set
• Scale down cluster capacity if nodes are under-utilized
• Scale up in case of unschedulable pods
• Solely responsible for managing scaling!!
• Manages multiple ASG’s
• Only for EC2 Instance scaling
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Using Spot instances with EKS
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EKS worker node provisioning with EC2 Spot
• Recommend using the node labels to identify EC2 Spot
instances
• Launch EC2 Spot instances as part of AutoScaling group
• Use EC2 Spot instances best practice of mixed instance
types
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Handling interruptions
Instance gets terminated / maintenance / interrupted,
workflow should be:
• Stop directing new-traffic to the pods on EC2 Spot
Instance which will be terminated.
• Gracefully drain connections of traffic already being
served
• Re-instantiate pods elsewhere in EKS cluster
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Interrupt handler
• Catch EC2 Spot interruption event
• Leverage K8’s functionality to set node state to DRAIN
• Leverage K8’s schedulers to re-instantiate pods
https://github.com/kube-aws/kube-spot-termination-notice-handler
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Put it all together
[mycluster].eks.amazonaws.com
Availability
Zone 1
Availability
Zone 2
Availability
Zone 3
Kubectl
VPC
Instance
Auto Scaling group for m4.large Spot instances
Auto Scaling group for t2.medium Spot instances
Auto Scaling group for On-Demand instances
Cluster Autoscaler Daemonset
Spot Interruption handler
Daemonset
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Storage with EKS
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Storage
• Persistent Volume
• Persistent Volume Claims
• StatefulSets
• Storage classes
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Lifecycle of a storage volume
Provisioning Binding Using Reclaiming
• Static
• Dynamic*
• Control loop watches
for PVC requests and
satisfies if PV is
available.
• For Dynamic, PVC
will provision PV
• PVC to PV binding is
one-to-one mapping
• Cluster mounts
volume based on
PVC
• Retain (default)
• Recycle
• Delete
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
What if I need specific volume type?
StorageClass
gp2 io1 sc1 encrypted
io1
st1
1) Admin pre-provisions
StorageClass based
on workload needs
2) End user requests for
specific volume types
(For ex, encrypted
io1 volume)
3) Control loop watches
PVC request and
allocates volume if
PV exists
MySQL Pods
4) End user creates
stateful workload
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Statefulset Properties
• Network identifiers
• Persistent Storage
• Ordered graceful deployment and scaling
• Ordered graceful termination
• Ordered rolling updates
• If none of these fit your portfolio, use
Deployment or Replicaset
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
StatefulSet
1) Define headless
service, statefulset
and PVC
2) Control loop allocates
PV based on PVC
request
StorageClass
gp2 io1 sc1 encrypted
io1
st1
3) Kubernetes creates
statefulset
MySQL Pods
mysql-0 mysql-1 mysql-2 mysql-3
Network
Identifiers
Ordered
Deployment
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
StatefulSet
1) Define headless
service, statefulset
and PVC
2) Control loop allocates
PV based on PVC
request 3) Kubernetes creates
statefulset
MySQL Pods
mysql-0 mysql-1 mysql-2 mysql-3
Ordered
Scaling
mysql-4
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Scheduling with Kubernetes
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Controlling scheduling
Resource requirements
Constraints
• Taints Node-level
• Tolerations Pod-level
Affinity/Anti-Affinity
Volume filters
Resource filters
Topology filters
Prioritization
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Limit resource usage
Container A Container B
limit
request
600m
600m
limit
request
800m
400m
⎲
⎳ Pod CPU and memory resources
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Resource Quotas
apiVersion: v1
kind: Pod
metadata:
name: production
spec:
containers:
- name: nginx-pod
image: nginx
resources:
limits:
memory: "800Mi"
cpu: "800m" # 0.8 vCPU
requests:
memory: "600Mi"
cpu: "400m“ # 0.4 vCPU
Applied per Namespace
apiVersion: v1
kind: ResourceQuota
metadata:
name: production
spec:
hard:
requests.cpu: "1"
requests.memory: 1Gi
limits.cpu: "2"
limits.memory: 2Gi
ResourceQuota
defined both, so
Pod must define
both
Pod Resource Request
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Taints and Tolerations
# Taint node
$ kubectl taint nodes ip-10-0-32-12.us-west-2.compute.internal 
skynet=false:NoSchedule
# Tolerations
kind: Pod
spec:
tolerations:
- key: skynet
operator: Equal
value: “false”
effect: NoSchedule
[...]
Match taint to
schedule onto
tainted node
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Affinity / Anti-Affinity
● Control scheduling onto nodes
○ Combine with Taints & Tolerations
● Distribute Pods across cluster
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: "beta.kubernetes.io/instance-type"
operator: In
values: [“r4.large",“r4.xlarge"]
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
CICD for applications deployed on EKS
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Jenkins
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Kubernetes continuous deployment
AWS CodePipeline
AWS CodeCommit AWS CodeBuild AWS Lambda
Amazon ECR
1 2 4
3 5
6
1
Developers continuously integrate
changes into a main branch hosted
within a repo
2
Triggers an execution of the pipeline
when a new version is found, builds
a new image with build id
3
Pushes the newly built image
tagged with build id to ECR repo
4
Invokes a Lambda function to
trigger application deployment
5
Leverages Kubernetes Python SDK
to update a deployment
6
Fetches new container image
and performs a rolling update
of deployment
Developer
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
dashboard.eventengine.run/login
Eksworkshop.com
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

More Related Content

What's hot

Using AWS Control Tower to govern multi-account AWS environments at scale - G...
Using AWS Control Tower to govern multi-account AWS environments at scale - G...Using AWS Control Tower to govern multi-account AWS environments at scale - G...
Using AWS Control Tower to govern multi-account AWS environments at scale - G...
Amazon Web Services
 

What's hot (20)

AWS networking fundamentals
AWS networking fundamentalsAWS networking fundamentals
AWS networking fundamentals
 
AWS Technical Essentials Day
AWS Technical Essentials DayAWS Technical Essentials Day
AWS Technical Essentials Day
 
(DVO401) Deep Dive into Blue/Green Deployments on AWS
(DVO401) Deep Dive into Blue/Green Deployments on AWS(DVO401) Deep Dive into Blue/Green Deployments on AWS
(DVO401) Deep Dive into Blue/Green Deployments on AWS
 
Getting Started on Amazon EKS
Getting Started on Amazon EKSGetting Started on Amazon EKS
Getting Started on Amazon EKS
 
An Introduction to the AWS Well Architected Framework - Webinar
An Introduction to the AWS Well Architected Framework - WebinarAn Introduction to the AWS Well Architected Framework - Webinar
An Introduction to the AWS Well Architected Framework - Webinar
 
Amazon EKS - security best practices - 2022
Amazon EKS - security best practices - 2022 Amazon EKS - security best practices - 2022
Amazon EKS - security best practices - 2022
 
AWS WAF
AWS WAFAWS WAF
AWS WAF
 
Eks and fargate
Eks and fargateEks and fargate
Eks and fargate
 
Containers on AWS: An Introduction
Containers on AWS: An IntroductionContainers on AWS: An Introduction
Containers on AWS: An Introduction
 
Fundamentals of AWS Security
Fundamentals of AWS SecurityFundamentals of AWS Security
Fundamentals of AWS Security
 
Azure kubernetes service (aks)
Azure kubernetes service (aks)Azure kubernetes service (aks)
Azure kubernetes service (aks)
 
Using AWS Control Tower to govern multi-account AWS environments at scale - G...
Using AWS Control Tower to govern multi-account AWS environments at scale - G...Using AWS Control Tower to govern multi-account AWS environments at scale - G...
Using AWS Control Tower to govern multi-account AWS environments at scale - G...
 
AWS for Backup and Recovery
AWS for Backup and RecoveryAWS for Backup and Recovery
AWS for Backup and Recovery
 
AWS ECS vs EKS
AWS ECS vs EKSAWS ECS vs EKS
AWS ECS vs EKS
 
Getting Started with Kubernetes
Getting Started with Kubernetes Getting Started with Kubernetes
Getting Started with Kubernetes
 
Elastic Kubernetes Services (EKS)
Elastic Kubernetes Services (EKS)Elastic Kubernetes Services (EKS)
Elastic Kubernetes Services (EKS)
 
Deep dive into AWS IAM
Deep dive into AWS IAMDeep dive into AWS IAM
Deep dive into AWS IAM
 
AWS IAM Introduction
AWS IAM IntroductionAWS IAM Introduction
AWS IAM Introduction
 
Amazon API Gateway
Amazon API GatewayAmazon API Gateway
Amazon API Gateway
 
Elastic Load Balancing Deep Dive - AWS Online Tech Talk
Elastic  Load Balancing Deep Dive - AWS Online Tech TalkElastic  Load Balancing Deep Dive - AWS Online Tech Talk
Elastic Load Balancing Deep Dive - AWS Online Tech Talk
 

Similar to Amazon EKS - Elastic Container Service for Kubernetes

Similar to Amazon EKS - Elastic Container Service for Kubernetes (20)

Fast-Track Your Application Modernisation Journey with Containers - AWS Summi...
Fast-Track Your Application Modernisation Journey with Containers - AWS Summi...Fast-Track Your Application Modernisation Journey with Containers - AWS Summi...
Fast-Track Your Application Modernisation Journey with Containers - AWS Summi...
 
Architecting security and governance through policy guardrails in Amazon EKS ...
Architecting security and governance through policy guardrails in Amazon EKS ...Architecting security and governance through policy guardrails in Amazon EKS ...
Architecting security and governance through policy guardrails in Amazon EKS ...
 
AWS Containers Day.pdf
AWS Containers Day.pdfAWS Containers Day.pdf
AWS Containers Day.pdf
 
AWS App Mesh (Service Mesh Magic)- AWS Container Day 2019 Barcelona
AWS App Mesh (Service Mesh Magic)- AWS Container Day 2019 BarcelonaAWS App Mesh (Service Mesh Magic)- AWS Container Day 2019 Barcelona
AWS App Mesh (Service Mesh Magic)- AWS Container Day 2019 Barcelona
 
Breaking the Monolith using AWS Container Services
Breaking the Monolith using AWS Container ServicesBreaking the Monolith using AWS Container Services
Breaking the Monolith using AWS Container Services
 
Running kubernetes with amazon eks
Running kubernetes with amazon eksRunning kubernetes with amazon eks
Running kubernetes with amazon eks
 
You're in the Cloud, now What?
You're in the Cloud, now What?You're in the Cloud, now What?
You're in the Cloud, now What?
 
Builders' Day- Mastering Kubernetes on AWS
Builders' Day- Mastering Kubernetes on AWSBuilders' Day- Mastering Kubernetes on AWS
Builders' Day- Mastering Kubernetes on AWS
 
Expert Tips for Successful Kubernetes Deployment on AWS
Expert Tips for Successful Kubernetes Deployment on AWSExpert Tips for Successful Kubernetes Deployment on AWS
Expert Tips for Successful Kubernetes Deployment on AWS
 
Expert Tips for Successful Kubernetes Deployment - AWS Summit Sydney 2018
Expert Tips for Successful Kubernetes Deployment - AWS Summit Sydney 2018Expert Tips for Successful Kubernetes Deployment - AWS Summit Sydney 2018
Expert Tips for Successful Kubernetes Deployment - AWS Summit Sydney 2018
 
SRV318 Running Kubernetes with Amazon EKS
SRV318 Running Kubernetes with Amazon EKSSRV318 Running Kubernetes with Amazon EKS
SRV318 Running Kubernetes with Amazon EKS
 
Modernizing legacy applications with Amazon EKS - MAD301 - Chicago AWS Summit
Modernizing legacy applications with Amazon EKS - MAD301 - Chicago AWS SummitModernizing legacy applications with Amazon EKS - MAD301 - Chicago AWS Summit
Modernizing legacy applications with Amazon EKS - MAD301 - Chicago AWS Summit
 
Amazon EKS: Getting Started
Amazon EKS: Getting StartedAmazon EKS: Getting Started
Amazon EKS: Getting Started
 
Modern-Application-Design-with-Amazon-ECS
Modern-Application-Design-with-Amazon-ECSModern-Application-Design-with-Amazon-ECS
Modern-Application-Design-with-Amazon-ECS
 
Modernizing applications with Amazon EKS - MAD304 - Santa Clara AWS Summit.pdf
Modernizing applications with Amazon EKS - MAD304 - Santa Clara AWS Summit.pdfModernizing applications with Amazon EKS - MAD304 - Santa Clara AWS Summit.pdf
Modernizing applications with Amazon EKS - MAD304 - Santa Clara AWS Summit.pdf
 
Simplifying Microsoft Architectures with AWS Services
Simplifying Microsoft Architectures with AWS ServicesSimplifying Microsoft Architectures with AWS Services
Simplifying Microsoft Architectures with AWS Services
 
Container, Container, Container -유재석 (AWS 솔루션즈 아키텍트)
Container, Container, Container -유재석 (AWS 솔루션즈 아키텍트)Container, Container, Container -유재석 (AWS 솔루션즈 아키텍트)
Container, Container, Container -유재석 (AWS 솔루션즈 아키텍트)
 
利用微服務加速創新的步伐
利用微服務加速創新的步伐利用微服務加速創新的步伐
利用微服務加速創新的步伐
 
Running Kubernetes on AWS.pdf
Running Kubernetes on AWS.pdfRunning Kubernetes on AWS.pdf
Running Kubernetes on AWS.pdf
 
Expert Tips for Successful Kubernetes Deployments on AWS
Expert Tips for Successful Kubernetes Deployments on AWSExpert Tips for Successful Kubernetes Deployments on AWS
Expert Tips for Successful Kubernetes Deployments on AWS
 

More from Amazon Web Services

Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
Amazon Web Services
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
Amazon Web Services
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
Amazon Web Services
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
Amazon Web Services
 

More from Amazon Web Services (20)

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS Fargate
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWS
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot
 
Open banking as a service
Open banking as a serviceOpen banking as a service
Open banking as a service
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
 
Computer Vision con AWS
Computer Vision con AWSComputer Vision con AWS
Computer Vision con AWS
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatare
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e web
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
 
Fundraising Essentials
Fundraising EssentialsFundraising Essentials
Fundraising Essentials
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container Service
 

Amazon EKS - Elastic Container Service for Kubernetes

  • 1. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. E L A S T I C C O N TA I N E R S E R V I C E F O R K U B E R N E T E S (EKS) Re Alvarez Parmar @realz reparmar@amazon.com Nikita Patil nikipat@amazon.com
  • 2. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Agenda 10:00am EKS Overview and Roadmap 12:00pm Lunch 12:30pm EKS Workshop Hands on Lab
  • 3. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Why Containers? • Speed • Efficiency • Easier packaging • Less risky deployments • Better Development experience • Microservices Photo & Licence
  • 4. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Customer use cases Microservices PaaS Platform-as-a-Service Enterprise App Migration Machine Learning
  • 5. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Challenges of Containers at Scale • More transient • More distributed and complex • Networking • Scheduling / Resource Management • Less isolated (containers can share a kernel)
  • 6. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS container services landscape Management Deployment, Scheduling, Scaling & Management of containerized applications Hosting Where the containers run Amazon Elastic Container Service Amazon Elastic Container Service for Kubernetes Amazon EC2 AWS Fargate Image Registry Container Image Repository Amazon Elastic Container Registry
  • 7. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Open source container management platform Helps you run containers at scale Gives you primitives for building modern applications What is Kubernetes?
  • 8. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Cloud-native applications M I C R O S E R V I C E T O O L I N G C L O U D N AT I V E A P P L I C AT I O N S
  • 9. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. But where you run Kubernetes matters Quality of the cloud platform Quality of the applications Your users
  • 10. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 51%of Kubernetes workloads run on AWS today — Cloud Native Computing Foundation
  • 11. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. “Run Kubernetes for me.”
  • 12. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Tenet 1 EKS is a platform for enterprises to run production-grade workloads Tenet 2 EKS provides a native and upstream Kubernetes experience Tenet 3 Provide seamless integration with AWS services and eliminate undifferentiated heavy lifting Tenet 4 EKS team actively contributes to the Kubernetes project
  • 13. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. EKS is Kubernetes Certified Kubernetes Conformance • Guaranteed Portability and Interoperability • Timely Updates • Confirmability
  • 14. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 0 20 40 60 80 100 120 140 160 jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov AWS Contributions to Kubernetes in 2018 AWS contributions to Kubernetes
  • 15. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. EKS Architecture Overview
  • 16. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Kubernetes on AWS Highly available Scalable Secure 3x Kubernetes API Servers for HA 3x Kubernetes etcd Servers for HA
  • 17. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Availability Zone 1 Availability Zone 2 Availability Zone 3 API Servers etcd Worker nodes EKS Overview AWS Managed Customer Managed
  • 18. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. [mycluster].eks.amazonaws.com Availability Zone 1 Availability Zone 2 Availability Zone 3 Kubectl AWS Cloud VPC
  • 19. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. EKS – Creating your cluster C r e a t e c l u s t e r C r e a t e H A c o n t r o l p l a n e I A M i n t e g r a t i o n C e r t i f i c a t e m a n a g e m e n t S e t u p L B A d d W o r k e r N o d e s aws eks create-cluster --name devel --role-arn arn:aws:iam::111122223333:role/eks-service- role-AWSServiceRoleForAmazonEKS-EXAMPLEBKZRQR --resources-vpc-config subnetIds=subnet-a9189fe2,subnet-50432629,securityGroupIds=sg-f5c54184
  • 20. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Describe Cluster $ aws eks describe-cluster --name devel HTTP/1.1 200 Content-type: application/json { "cluster": { "clusterName": "string", "createdAt": number, "currentMasterVersion": "string", "desiredMasterVersion": "string", "masterEndpoint": "string", "roleArn": "string", "status": "string", "statusMessage": "string" } }
  • 21. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. EKS Architecture EKS VPCCustomer VPC Worker Nodes EKS-Owned ENI Kubernetes API calls Exec, Logs, Proxy Internet
  • 22. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. EKS Logging
  • 23. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. EKS Logging EKS ManagedCustomer Account Internet Amazon CloudWatch AWS CloudTrail
  • 24. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. WorkerWorkerMaster WorkerWorkerMaster ASG AZ1 Region AZ2 ASG CloudWatch Logs Elasticsearch Kibana Fluentd DaemonSet Kubectl logs Elasticsearch (index), Fluentd (store), and Kibana (visualize) EKS Logging
  • 25. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Helm: Package Manager for Kubernetes
  • 26. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. • Helm not only is a package manager, but also a Kubernetes application deployment management tool • It helps you to: • achieve a simple (one command) and repeatable deployment • manage application dependency, using specific versions of other application and services • manage multiple deployment configurations: test, staging, production and others • execute post/pre deployment jobs during application deployment • update/rollback and test application deployments Helm: package manager for Kubernetes
  • 27. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. EKS Identity & Access Management
  • 28. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Identity & Access Management (IAM) IAM enables secure access to AWS services and resources Granular controls for Kubectl and pods Two IAM roles created for K8s cluster
  • 29. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. K8s action allowed/denied IAM roles for Kubectl Authorizes AWS Identity with RBAC K8s API Passes AWS Identity Verifies AWS Identity AWS Auth 1 2 3 4 Kubectl
  • 30. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Worker provisioning k u b e c t l A W S A u t h c o n f i g m a p & R B A C W o r k e r s R o l e R o l e config map
  • 31. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. IAM roles for Pods
  • 32. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. IAM Roles for Pods AWS proposed solution Makes use of Kubernetes TokenRequestProjection Tokens to assume an IAM role Needs Kubernetes v1.11 & latest AWS SDKs AWS CloudTrail support at launch Coming Soon
  • 33. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SAML 2.0 – Integrate with AD and SSO M A AWS Directory Service On-premises users and groups Manage Permissions to AWS accounts sts:AssumeRole On-premises Microsoft Active Directory AD Connector / AD Trust IAM role
  • 34. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. EKS Networking
  • 35. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Native VPC networking with CNI plugin Pods have the same VPC address inside the pod as on the VPC Simple, secure networking Open source and on Github …{ } https://github.com/aws/amazon-vpc-cni-k8s
  • 36. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. VPC CNI plugin • Bridge between the K8s and – AWS VPC • A W S R o u t a b l e I P s • Thin layer – no performance impact • Pod IP ENI secondary IP
  • 37. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. R u n t i m e N e t w o r k p l u g i n N e t w o r k c o n f i g u r a t i o n CNI Infrastructure
  • 38. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. K u b e l e t V P C C N I p l u g i n 1 . C N I A d d / D e l e t e E C 2 E N I E N I E N I P o d P o d P o d P o d V P C N e t w o r k ......... 0 . C r e a t e E N I 2 . S e t u p v e t h VPC Networking Internals
  • 39. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. VPC CNI plugin architecture K u b e l e t V P C C N I p l u g i n N e t w o r k l o c a l c o n t r o l p l a n e E N I s / S e c o n d a r y I P s C N I A d d / D e l e t e g R P C E C 2
  • 40. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS VPC CNI plugin ENI Secondary IPs: 10.0.0.1 10.0.0.2 10.0.0.1 10.0.0.2 ENI 10.0.0.20 10.0.0.22 Secondary IPs: 10.0.0.20 10.0.0.22 ec2.associateaddress() VPC Subnet – 10.0.0.0/24 Instance 1 Instance 2 VPC
  • 41. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS VPC CNI plugin – Understanding IP allocation • Primary CIDR range è RFC 1918 addresses è 10/8, 172.16/12, 192.168/16 Used in EKS for: • Pods • X-account ENIs for (masters à workers) communication (exec, logs, proxy etc.) • Internal Kubernetes services network (10.100/16 or 172.20/16 – chosen based on your VPC range) Setup: EKS cluster creation è provide list of subnets (in at least 2 AZs!) è tagging
  • 42. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS VPC CNI plugin – Understanding IP Allocation • Secondary CIDR ranges (new!) è non-RFC 1918 address blocks (100.64.0.0/10 and 198.19.0.0/16) Used in EKS for: • Pods only How? • EKS custom network config è enable è create ENIConfig CRD è annotate nodes CNI 1.2.1+
  • 43. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS VPC CNI plugin ENI Secondary IPs: 10.0.0.1 10.0.0.2 10.0.0.1 10.0.0.2 ENI 10.0.0.20 10.0.0.22 Secondary IPs: 10.0.0.20 10.0.0.22 ec2.associateaddress() VPC Subnet – 10.0.0.0/24 Instance 1 Instance 2 VPC
  • 44. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS VPC CNI plugin - configurability • Custom Network Configs • SNAT / External SNAT • Configurable warm pool
  • 45. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Packet flow : pod - to - pod E C 2 Default namespace Pod namespace veth veth Main RT E C 2 Default namespace Pod namespace veth Route Table Main RT ENI RT veth VPC fabric ENI RT Route Table
  • 46. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Packet flow : pod - to external E C 2 Default namespace Pod namespace veth Route Table Main RT ENI RT veth External Network IPTables
  • 47. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
  • 48. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Frontend Cats Dogs kind: NetworkPolicy apiVersion: extensions/v1beta1 metadata: name: default-deny spec: podSelector: matchLabels: {} dev-namespace
  • 49. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Frontend Cats Dogs kind: NetworkPolicy apiVersion: extensions/v1beta1 metadata: name: default-deny spec: podSelector: matchLabels: {} dev-namespace
  • 50. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Frontend Cats Dogs dev-namespace apiVersion: extensions/v1beta1 kind: NetworkPolicy metadata: name: public-to-frontend spec: podSelector: matchLabels: role: frontend ingress: - from: - ipBlock: cidr: "0.0.0.0/0" ports: - protocol: TCP port: 80
  • 51. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Frontend Cats Dogs dev-namespace apiVersion: extensions/v1beta1 kind: NetworkPolicy metadata: name: public-to-frontend spec: podSelector: matchLabels: role: frontend ingress: - from: - ipBlock: cidr: "0.0.0.0/0" ports: - protocol: TCP port: 80
  • 52. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Frontend Cats Dogs dev-namespace apiVersion: extensions/v1beta1 kind: NetworkPolicy metadata: name: frontend-to-cats spec: podSelector: matchLabels: role: cats ingress: - from: - podSelector: matchLabels: role: “frontend” ports: - protocol: TCP port: 80
  • 53. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Frontend Cats Dogs dev-namespace apiVersion: extensions/v1beta1 kind: NetworkPolicy metadata: name: frontend-to-cats spec: podSelector: matchLabels: role: cats ingress: - from: - podSelector: matchLabels: role: “frontend” ports: - protocol: TCP port: 80
  • 54. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. That looks good. But, what about isolation?
  • 55. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. kubectl create namespace prod-namespace
  • 56. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Frontend Cats Dogs dev-namespace Frontend Cats Dogs prod-namespace
  • 57. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Frontend Cats Dogs prod-namespace apiVersion: extensions/v1beta1 kind: NetworkPolicy metadata: name: frontend-to-cats-and-dogs namespace: prod-namespace spec: podSelector: matchLabels: role: cats-and-dogs ingress: - from: - podSelector: matchLabels: role: “frontend” ports: - protocol: TCP port: 80
  • 58. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Networking: Pod to service
  • 59. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. • Exposes the service on a cluster-internal IP • Only reachable from within the cluster • Access possible via kube-proxy • Useful for debugging services, connecting from your laptop or displaying internal dashboards Kubernetes ServiceType: ClusterIP
  • 60. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Kubernetes ServiceType: NodePort • Exposes the service on each Node’s IP at a static port. • Routes to a ClusterIP service, which is automatically created. • from outside the cluster: <NodeIP>:<NodePort> • 1 service per port • Uses ports 30000-32767
  • 61. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. • Exposes the service externally using a cloud provider’s load balancer. • NodePort and ClusterIP services (to which LB will route) automatically created. • Each service exposed with a LoadBalancer (ELB or NLB) will get its own IP address • Exposes L4 (TCP) or L7 (HTTP) services Kubernetes ServiceType: LoadBalancer
  • 62. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Service load balancer: NLB apiVersion: v1 kind: Service metadata: name: nginx namespace: default labels: app: nginx annotations: service.beta.kubernetes.io/aws-load-balancer-type: "nlb" spec: externalTrafficPolicy: Local ports: - name: http port: 80 protocol: TCP targetPort: 80 selector: app: nginx type: LoadBalancer
  • 63. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Service load balancer: NLB • NLB supports forwarding the client’s IP through to the node • .spec.externalTrafficPolicy = Local è client ip passed to pod • Nodes with no matching pods will be removed by specified NLB’s health check .spec.healthCheckNodePort • Use DaemonSet or pod anti-affinity to verify even traffic split
  • 64. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. • exposes HTTP/HTTPS routes to services within the cluster • Many implementations: ALB, Nginx, F5, HAProxy etc • Default Service Type: ClusterIP Kubernetes Ingress Object
  • 65. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ALB Ingress Controller AWS Resources Kubernetes Cluster Node Node Kubernetes API Server ALB Ingress Controller Node HTTP ListenerHTTPS Listener Rule: /cheesesRule: /charcuterie TargetGroup: Green (IP Mode) TargetGroup: Blue (Instance Mode) NodePort NodePort
  • 66. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Kubernetes Autoscaling with Amazon EKS
  • 67. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Pod Autoscaling Options • HPA: de-facto method • Cluster-proportional-autoscaler • k8s-rabid-pod-autoscaler • Kube-sqs-autoscaler
  • 68. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. EKS – Pod Scaling by HPA • Horizontal pod scaling • Automatically scales number of pods in replication controller • Implemented as a Kubernetes API resource and a controller. • The controller periodically adjusts # of replicas in a replication controller or deployment to match the observed average CPU utilization to the target specified by user. • HPA can scale on custom and external metrics (any metric collected by metrics server api) instead of simply CPU and memory..
  • 69. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Cluster Autoscaling Options • Cluster Auto-scaler (CA): de-facto method • Kubernetes-ec2-autoscaler • kube-aws-autoscaler • Atlassian Escalator: batch or job optimized horizontal autoscaler
  • 70. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Cluster auto-scaler • Deployed As a daemon set • Scale down cluster capacity if nodes are under-utilized • Scale up in case of unschedulable pods • Solely responsible for managing scaling!! • Manages multiple ASG’s • Only for EC2 Instance scaling
  • 71. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Using Spot instances with EKS
  • 72. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. EKS worker node provisioning with EC2 Spot • Recommend using the node labels to identify EC2 Spot instances • Launch EC2 Spot instances as part of AutoScaling group • Use EC2 Spot instances best practice of mixed instance types
  • 73. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Handling interruptions Instance gets terminated / maintenance / interrupted, workflow should be: • Stop directing new-traffic to the pods on EC2 Spot Instance which will be terminated. • Gracefully drain connections of traffic already being served • Re-instantiate pods elsewhere in EKS cluster
  • 74. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Interrupt handler • Catch EC2 Spot interruption event • Leverage K8’s functionality to set node state to DRAIN • Leverage K8’s schedulers to re-instantiate pods https://github.com/kube-aws/kube-spot-termination-notice-handler
  • 75. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Put it all together [mycluster].eks.amazonaws.com Availability Zone 1 Availability Zone 2 Availability Zone 3 Kubectl VPC Instance Auto Scaling group for m4.large Spot instances Auto Scaling group for t2.medium Spot instances Auto Scaling group for On-Demand instances Cluster Autoscaler Daemonset Spot Interruption handler Daemonset
  • 76. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Storage with EKS
  • 77. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Storage • Persistent Volume • Persistent Volume Claims • StatefulSets • Storage classes
  • 78. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Lifecycle of a storage volume Provisioning Binding Using Reclaiming • Static • Dynamic* • Control loop watches for PVC requests and satisfies if PV is available. • For Dynamic, PVC will provision PV • PVC to PV binding is one-to-one mapping • Cluster mounts volume based on PVC • Retain (default) • Recycle • Delete
  • 79. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. What if I need specific volume type? StorageClass gp2 io1 sc1 encrypted io1 st1 1) Admin pre-provisions StorageClass based on workload needs 2) End user requests for specific volume types (For ex, encrypted io1 volume) 3) Control loop watches PVC request and allocates volume if PV exists MySQL Pods 4) End user creates stateful workload
  • 80. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Statefulset Properties • Network identifiers • Persistent Storage • Ordered graceful deployment and scaling • Ordered graceful termination • Ordered rolling updates • If none of these fit your portfolio, use Deployment or Replicaset
  • 81. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. StatefulSet 1) Define headless service, statefulset and PVC 2) Control loop allocates PV based on PVC request StorageClass gp2 io1 sc1 encrypted io1 st1 3) Kubernetes creates statefulset MySQL Pods mysql-0 mysql-1 mysql-2 mysql-3 Network Identifiers Ordered Deployment
  • 82. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. StatefulSet 1) Define headless service, statefulset and PVC 2) Control loop allocates PV based on PVC request 3) Kubernetes creates statefulset MySQL Pods mysql-0 mysql-1 mysql-2 mysql-3 Ordered Scaling mysql-4
  • 83. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Scheduling with Kubernetes
  • 84. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Controlling scheduling Resource requirements Constraints • Taints Node-level • Tolerations Pod-level Affinity/Anti-Affinity Volume filters Resource filters Topology filters Prioritization
  • 85. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Limit resource usage Container A Container B limit request 600m 600m limit request 800m 400m ⎲ ⎳ Pod CPU and memory resources
  • 86. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Resource Quotas apiVersion: v1 kind: Pod metadata: name: production spec: containers: - name: nginx-pod image: nginx resources: limits: memory: "800Mi" cpu: "800m" # 0.8 vCPU requests: memory: "600Mi" cpu: "400m“ # 0.4 vCPU Applied per Namespace apiVersion: v1 kind: ResourceQuota metadata: name: production spec: hard: requests.cpu: "1" requests.memory: 1Gi limits.cpu: "2" limits.memory: 2Gi ResourceQuota defined both, so Pod must define both Pod Resource Request
  • 87. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Taints and Tolerations # Taint node $ kubectl taint nodes ip-10-0-32-12.us-west-2.compute.internal skynet=false:NoSchedule # Tolerations kind: Pod spec: tolerations: - key: skynet operator: Equal value: “false” effect: NoSchedule [...] Match taint to schedule onto tainted node
  • 88. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Affinity / Anti-Affinity ● Control scheduling onto nodes ○ Combine with Taints & Tolerations ● Distribute Pods across cluster affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - key: "beta.kubernetes.io/instance-type" operator: In values: [“r4.large",“r4.xlarge"]
  • 89. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. CICD for applications deployed on EKS
  • 90. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Jenkins
  • 91. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Kubernetes continuous deployment AWS CodePipeline AWS CodeCommit AWS CodeBuild AWS Lambda Amazon ECR 1 2 4 3 5 6 1 Developers continuously integrate changes into a main branch hosted within a repo 2 Triggers an execution of the pipeline when a new version is found, builds a new image with build id 3 Pushes the newly built image tagged with build id to ECR repo 4 Invokes a Lambda function to trigger application deployment 5 Leverages Kubernetes Python SDK to update a deployment 6 Fetches new container image and performs a rolling update of deployment Developer
  • 92. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. dashboard.eventengine.run/login Eksworkshop.com
  • 93. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.