首页 > 解决方案 > 在 AWS 基础设施中私下访问 EKS 服务

问题描述

我在 K8S 中有一个服务,我想从另一个 EKS 集群的 POD 私下访问它。

服务.yaml

apiVersion: v1
kind: Service
metadata:
  name: test
  namespace: test
spec:
  type: LoadBalancer
  selector:
    app: test
  ports:
    - name: http
      protocol: TCP
      port: 80
      targetPort: 8888

在 LoadBalancer 的安全组中,我只删除0.0.0.0/0并启用了客户端的工作节点 IP 和 POD IP

工作节点 IP

Type: All traffic
Protocol: All   
Port range: All 
Source: 10.x.0.0/16

点播IP

Type: All traffic
Protocol: All
Port range: All
Source: 10.x.x.x/32

现在当我从客户端的 POD telnet 到服务时,telnet 挂在 Trying 状态

telnet xxxx-xxxxx.us-west-1.elb.amazonaws.com 80
Trying xx.xxx.xxx.xxx...

如果我启用安全组中的所有源,如下所示,一切正常。这不是预期的行为,因为必须私下访问此资源。

Type: HTTP
Protocol: TCP
Port range: 80
Source: 0.0.0.0/0

我尝试了其他服务选项,没有任何效果

....
annotations:
    service.beta.kubernetes.io/aws-load-balancer-type: "nlb"
    service.beta.kubernetes.io/aws-load-balancer-internal: "true"

spec:
  externalTrafficPolicy: Local # Tried both Cluster and Local
....

标签: amazon-web-serviceskubernetesamazon-eks

解决方案


推荐阅读