gpt4 book ai didi

amazon-web-services - 我可以为由 Istio 配置的经典 AWS ELB 定义子域吗?

转载 作者:行者123 更新时间:2023-12-03 17:23:35 24 4
gpt4 key购买 nike

我在 AWS EKS 托管的 Kubernetes 集群中部署了 Istio。这创建了一个名为 istio-ingressgateway 的 LoadBalancer 类型的 Kubernetes 服务,外部主机名为 [redacted]-redacted.us-west-2.elb.amazonaws.com ,并自动预置一个 AWS ELB,输入经典。那太棒了。 (注意:在 AWS 控制台中,我没有看到此 elb 主机名的托管区域,看起来我无法配置别名或诸如此类的东西)
我已经能够通过定义一个 istio 网关将在集群外运行的 gRPC 客户端连接到在集群中运行的 gRPC 服务器,该网关将端口 80 打开到 host:"*"。 ,并定义一个 istio 虚拟服务,它将端口 80 路由到我的目的地(某些 kubernetes 服务的某个端口)。到现在为止还挺好。
现在我想为集群中的第二个 gRPC 端点执行此操作。据我所知,我的选择是:要么通过在入口上打开第二个端口(比如 81)来路由(我现在选择不这样做)。或者通过定义 [redacted]-redacted.us-west-2.elb.amazonaws.com 的子域来路由,或通过实现“虚拟主机”路由,即客户端发送的同一域上的两个服务 host:"svc1"在标题中。
这就是我被困的地方。不知道怎么给这个ELB域名定义子域,也不知道能不能用TLS做虚拟主机,如果能,还能不能用Istio的“passthrough”tls模式,以免TLS 在网关上终止。
1- 使用子域:当在我的开发机器上时,我尝试 getent hosts svc1.[redacted]-redacted.us-west-2.elb.amazonaws.com它不映射到 IP,而如果删除 svc1前缀 DNS 返回 3 个 IP(猜测 us-west-2 中的 3 个可用区)。所以我不能在没有一些工作的情况下为域添加 svc1 前缀。
我可以定义子域吗svc1svc2对于通过部署 Istio 自动配置的经典 AWS ELB 创建的域,如果是这样,如何?我可以用 kubectl/istioctl 做这个吗?配置 Istio,还是我需要使用 AWS CLI 执行此操作?这可以在不注册域的情况下完成吗,我对用户不友好的 elb.amazonaws.com 主机名没问题?
2- 虚拟主机:或者,我可以在 gRPC 元数据中添加一个 host=svc1。我尝试添加 ctx := metadata.AppendToOutgoingContext(context.Background(), "Host", "svc1")对我的 Go 客户来说,那没有用。
一些指导会很棒。
更新 1,一种明文解决方案
我正在阅读 List of HTTP header fields HTTP2 中不应使用“Host” header 。鉴于这是 gRPC,它是 HTTP2,因此我不应该将它添加为我的 gRPC 客户端请求中的自定义 header 。做虚拟主机时的解决方法,在gRPC客户端,不是发送“host”header,而是发送“:Authority”header,该值必须对应istio的gateway+virtualservice中指定的host。这对我有用。在我的 Go 客户端中,我必须添加 dialOptions = append(dialOptions, grpc.WithAuthority("[my-service-1]")) .
根据 GoDoc grpc.WithAuthority,该解决方案不适用于 TLS .所以我仍然需要找到在使用 TLS 时如何从相同的外部 IP 和端口路由 2 个服务。
更新 1.1:
在虚拟主机中,当使用 TLS 时,SNI 可以在 CLIENT HELLO 消息中传递,而不是像纯文本那样作为 gRPC header 。根据您的语言,确切的 API 会有所不同,但在 Go 中,我可以通过设置 ServerName 来传递主机名。字段在 tls.Config .然后,您可以在 istio 网关配置中对该主机名进行门控,并根据您的 istio 虚拟服务中的该值进行路由。
更新 2:我尝试在 AWS Route53 上创建子域,但失败了。首先,我为域创建一个公共(public)托管区域:[redacted]-redacted.us-west-2.elb.amazonaws.com。接下来,在该托管区域中,我创建了一个名称= svc1. 的 A 记录。 [redacted]-redacted.us-west-2.elb.amazonaws.com,route=Classic Load Balancer 的别名,region=us-west-2,负载均衡器=dualstack.[redacted]-redacted.us-west-2 .elb.amazonaws.com。
我后来测试了 svc1.[redacted]-redacted.us-west-2.elb.amazonaws.com 记录存在于 dig ,它不会返回答案。然而,dig 确实返回了 [redacted]-redacted.us-west-2.elb.amazonaws.com(没有 svc1 前缀)的 3 个 A 记录,以及 3 个负载均衡器的 IP。

最佳答案

伊斯蒂奥

Can I define subdomains svc1 and svc2 for a domain created by classic AWS ELB automatically provisioned by deploying Istio, and if so how?


你不能用 istio 来做,你必须在云中配置它,在你的情况下你必须在 aws 上配置它。
在 istio 上,您只能指定主机,也就是在 aws 上配置的子域。
虚拟服务看起来像这样:
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: mipnw-vs1
spec:
hosts:
- svc1.example.com
http:
- name: "svc1-route"
match:
- uri:
prefix: /
route:
- destination:
host: svc1.default.svc.cluster.local

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: mipnw-vs2
spec:
hosts:
- svc2.example.com
http:
- name: "svc2-route"
match:
- uri:
prefix: /
route:
- destination:
host: svc2.default.svc.cluster.local
aws

I would love to learn how to create 2 subdomains "abc" and "def" for domain "[redacted]-[redacted].us-west-2.elb.amazonaws.com"


我不确定这就是你要找的东西,但我在 aws 文档中做了一些研究,我发现你可以使用 Amazon Route 53达到你所需要的。

Amazon Route 53 is a highly available and scalable cloud Domain Name System (DNS) web service. It is designed to give developers and businesses an extremely reliable and cost effective way to route end users to Internet applications by translating names like www.example.com into the numeric IP addresses like 192.0.2.1


以下信息收集自:
  • https://aws.amazon.com/route53/faqs/
  • https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-to-elb-load-balancer.html

  • If you host a website on multiple Amazon EC2 instances, you can distribute traffic to your website across the instances by using an Elastic Load Balancing (ELB) load balancer. The ELB service automatically scales the load balancer as traffic to your website changes over time. The load balancer also can monitor the health of its registered instances and route domain traffic only to healthy instances.

    To route domain traffic to an ELB load balancer, use Amazon Route 53 to create an alias record that points to your load balancer. An alias record is a Route 53 extension to DNS. It's similar to a CNAME record, but you can create an alias record both for the root domain, such as example.com, and for subdomains, such as www.example.com. (You can create CNAME records only for subdomains.)


    Amazon Route 53 also offers alias records, which are an Amazon Route 53-specific extension to DNS. You can create alias records to route traffic to selected AWS resources, including Amazon Elastic Load Balancing load balancers, Amazon CloudFront distributions, AWS Elastic Beanstalk environments, API Gateways, VPC interface endpoints, and Amazon S3 buckets that are configured as websites. Alias record typically have a type of A or AAAA, but they work like a CNAME record. Using an alias record, you can map your record name (example.com) to the DNS name for an AWS resource(elb1234.elb.amazonaws.com). Resolvers see the A or AAAA record and the IP address of the AWS resource.


    还有关于子域的问题

    Can I use 'Alias' records with my sub-domains?

    Yes. You can also use Alias records to map your sub-domains (www.example.com, pictures.example.com, etc.) to your ELB load balancers, CloudFront distributions, or S3 website buckets.


    其他资源:
  • https://medium.com/cloud-native-the-gathering/istio-ingress-to-expose-your-k8s-services-via-individual-dns-2ec9c2717b81
  • https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/dns-routing-traffic-for-subdomains.html
  • 关于amazon-web-services - 我可以为由 Istio 配置的经典 AWS ELB 定义子域吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64037625/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com