22
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Walkley He, Solutions Architect, AWS Nov 2019 云原生应用中的网络流量管理

云原生应用中的网络流量管理 · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 云原生 云原生应用 云原生技术有利于各组织在公有云、私有云和混

  • Upload
    others

  • View
    10

  • Download
    0

Embed Size (px)

Citation preview

Page 1: 云原生应用中的网络流量管理 · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 云原生 云原生应用 云原生技术有利于各组织在公有云、私有云和混

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Walkley He, Solutions Architect, AWS

Nov 2019

云原生应用中的网络流量管理

Page 2: 云原生应用中的网络流量管理 · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 云原生 云原生应用 云原生技术有利于各组织在公有云、私有云和混

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

议题

• 概述• 集群外网络流量管理• 集群内网络流量管理• Demo• Q&A

Page 3: 云原生应用中的网络流量管理 · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 云原生 云原生应用 云原生技术有利于各组织在公有云、私有云和混

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

云原生

云原生应用云原生技术有利于各组织在公有云、私有云和混合云等新型动态环境中,构建和运行可弹性扩展的应用。云原生的代表技术包括容器、服务网格、微服务、不可变基础设施和声明式API。这些技术能够构建容错性好、易于管理和便于观察的松耦合系统。结合可靠的自动化手段,云原生技术使工程师能够轻松地对系统作出频繁和可预测的重大变更。

应用层网络流量管理• 分发• 限流• 熔断• 重试• 加密

Page 4: 云原生应用中的网络流量管理 · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 云原生 云原生应用 云原生技术有利于各组织在公有云、私有云和混

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential

微服务带来的网络管理复杂性

Source: Netflix tech blog

Page 5: 云原生应用中的网络流量管理 · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 云原生 云原生应用 云原生技术有利于各组织在公有云、私有云和混

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential

AWS网络相关服务

Edge location Route tableFlow logs NAT gateway Client VPN

Streamingdistribution

Peering VPC Sharing

Downloaddistribution

Hosted zoneCustomer gateway Elastic networkinterface

Endpoints

Site-to-Site VPN Direct Connectgateway

AWS Transit Gateway

AWS GlobalAccelerator

Internet gateway

Elastic networkadapter

Network accesscontrol list

Router

Classicload balancer

Networkload balancer

Applicationload balancer

AWS VirtualPrivate Network

Route 53 Resolver

AWSCloud Map

Page 6: 云原生应用中的网络流量管理 · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 云原生 云原生应用 云原生技术有利于各组织在公有云、私有云和混

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

应用外部网络流量管理

Amazon Route 53

DNS

DNS

Amazon CloudFront

Edge location

Edge location

AWS Global Accelerator

us-west-2VPC

Elastic Load Balancing

ap-southeast-1

VPC

Elastic Load Balancing

Amazon API Gateway

Backbone

Backbone

Amazon API Gateway

Page 7: 云原生应用中的网络流量管理 · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 云原生 云原生应用 云原生技术有利于各组织在公有云、私有云和混

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Kubernetes Ingress

Service1

Pod Pod Pod

Service2

Pod Pod Pod

Service3

Pod Pod Pod

Ingress

foo.mydomain.com mydomain.com/bar other

Kubernetes Cluster

用于管理从外部访问集群内服务的的一个API对象,通常是HTTP。

Ingress可以提供负载平衡,SSL终止和基于名称的虚拟主机。

Page 8: 云原生应用中的网络流量管理 · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 云原生 云原生应用 云原生技术有利于各组织在公有云、私有云和混

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Kubernetes Ingress

https://kubedex.com/ingress/

Page 9: 云原生应用中的网络流量管理 · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 云原生 云原生应用 云原生技术有利于各组织在公有云、私有云和混

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

ALB Ingress Controller

AWS Resources

Kubernetes ClusterNode Node

Kubernetes API Server ALB Ingress

Controller

Node

HTTP ListenerHTTPS Listener

Rule: /cheesesRule: /charcuterie

TargetGroup: Green (IP Mode)

TargetGroup: Blue (Instance Mode)

NodePort NodePort

https://github.com/kubernetes-sigs/aws-alb-ingress-controller

Page 10: 云原生应用中的网络流量管理 · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 云原生 云原生应用 云原生技术有利于各组织在公有云、私有云和混

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

NLB + ingress-nginx

• Static IP/elastic IP addresses• Scalability• Zonal isolation• Source/remote address

preservation• Long-lived TCP connections• Reduced bandwidth usage• SSL termination

Network Load Balancer

Service1

Pod Pod Pod

Service2

Pod Pod Pod

Service3

Pod Pod Pod

ingress-nginx

foo.mydomain.com mydomain.com/bar other

Kubernetes Cluster

Page 11: 云原生应用中的网络流量管理 · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 云原生 云原生应用 云原生技术有利于各组织在公有云、私有云和混

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Kubernetes Service

• ClusterIP virtual IP, accessible from all nodes• LoadBalancer automatically creates a public ELB (using

IAM role)• NodePort bind service to the same port on every host

Service

Pod Pod Pod

Elastic Load Balancing

Page 12: 云原生应用中的网络流量管理 · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 云原生 云原生应用 云原生技术有利于各组织在公有云、私有云和混

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Kubernetes CNI - AWS VPC CNI 插件

https://github.com/aws/amazon-vpc-cni-k8s

Nginx Pod

Java Pod

ENI

Secondary IPs:10.0.0.110.0.0.2

Veth IP: 10.0.0.1

Veth IP: 10.0.0.2

Nginx Pod

Java Pod

ENI

Veth IP: 10.0.0.20

Veth IP: 10.0.0.22

Secondary IPs:10.0.0.2010.0.0.22

ec2.associateaddress()

VPC Subnet – 10.0.0.0/24

Instance 1 Instance 2

CNI

CNI

Page 13: 云原生应用中的网络流量管理 · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 云原生 云原生应用 云原生技术有利于各组织在公有云、私有云和混

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Kubernetes Network Policy

Frontend

Cats Dogs

kind: NetworkPolicyapiVersion: extensions/v1beta1metadata:name: default-denyspec:podSelector:matchLabels: {}

prod-namespace

Page 14: 云原生应用中的网络流量管理 · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 云原生 云原生应用 云原生技术有利于各组织在公有云、私有云和混

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Node.js

Database

JavaNode.is

Java

Infrastructure team

Product teams

Platform teams

Java

Service Teams

Java

Java

Java

Database

Database

Database

Product teams

控制服务与服务之间的通讯

服务与服务之间通讯的可观察性

组织创新的小DevOps团队

自动化的安全合规检测

Service Mesh

Page 15: 云原生应用中的网络流量管理 · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 云原生 云原生应用 云原生技术有利于各组织在公有云、私有云和混

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

AWS App Mesh

一个全托管的服务网格

利用Sidecar代理机制

App Mesh is a service mesh

不需要开发构建和维护

不依赖于应用程序部署平台

(例如:容器编排)

适用于不同计算平台

可靠地存储和分发配置

Page 16: 云原生应用中的网络流量管理 · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 云原生 云原生应用 云原生技术有利于各组织在公有云、私有云和混

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

App Mesh – 流量与路由管理

流量管理Load balancingWeight targetsService discovery (DNS + AWS Cloud Map)Health checksRetriesTimeoutsCircuit breakers

路由控制Protocols support (HTTP, TCP, gRPC)Path-basedHeader-basedCookie-basedhttps://github.com/aws/aws-app-mesh-roadmap/projects/1

Page 17: 云原生应用中的网络流量管理 · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 云原生 云原生应用 云原生技术有利于各组织在公有云、私有云和混

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

App Mesh: 与AWS服务相集成

Amazon ECS

AWS Fargate

Amazon EKS

Amazon EC2

AWS App Mesh

CloudWatch

AWS Cloud Map

Page 18: 云原生应用中的网络流量管理 · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 云原生 云原生应用 云原生技术有利于各组织在公有云、私有云和混

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

App Mesh 构成

MeshVirtual node

Virtual router and routesVirtual service

Create and manage these in App Mesh API, CLI, SDK, or

AWS Management Console

ProxiesServices

Service discovery

Configure and run proxies and services on Amazon ECS, Fargate, Amazon

EKS, Amazon EC2

Service discovery with AWS Cloud Map

Page 19: 云原生应用中的网络流量管理 · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 云原生 云原生应用 云原生技术有利于各组织在公有云、私有云和混

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

App Mesh 跨集群部署管理

VPC

AWS Cloud

AWS Cloud Map

AWS App Mesh

Amazon EKS AWS FargateAmazon ECS AWS X-Ray

Page 20: 云原生应用中的网络流量管理 · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 云原生 云原生应用 云原生技术有利于各组织在公有云、私有云和混

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Demo

Page 21: 云原生应用中的网络流量管理 · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 云原生 云原生应用 云原生技术有利于各组织在公有云、私有云和混

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential

Q&A

Page 22: 云原生应用中的网络流量管理 · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 云原生 云原生应用 云原生技术有利于各组织在公有云、私有云和混

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential

Thank you!