正如标题所说,我正在寻找一种方法来强制 LoadBalancer 服务使用 AWS 中的预定义安全组。我不想手动编辑由 Kubernetes 为 ELB 创建的安全组的入站/出站规则。我无法在文档中找到任何内容,也没有找到任何在线其他地方有效的内容。这是我当前的模板:
apiVersion: v1
kind: Service
metadata:
name: ds-proxy
spec:
type: LoadBalancer
ports:
- port: 8761 # the port that this service should serve on
targetPort: 8761
protocol: TCP
selector:
app: discovery-service
最佳答案
您无法阻止 Kubernetes 创建新的安全组。但是自从 Andonaeus 的回答被提交以来,一个新功能已经被添加,它允许通过您的服务的配置文件显式定义入站权限。
见 the user guide details对于具体情况。那里提供的示例表明,通过使用 spec.loadBalancerSourceRanges
您可以提供允许入站 IP:
In the following example, a load blancer will be created that is only accessible to clients with IP addresses from 130.211.204.1 and 130.211.204.2.
apiVersion: v1
kind: Service
metadata:
name: myapp
spec:
ports:
- port: 8765
targetPort: 9376
selector:
app: example
type: LoadBalancer
loadBalancerSourceRanges:
- 130.211.204.1/32
- 130.211.204.2/32
关于amazon-web-services - Kubernetes 和 AWS : Set LoadBalancer to use predefined Security Group,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34748320/