![如何在 Kubernetes 中创建内部第 4 层负载均衡器?](https://linux22.com/image/770288/%E5%A6%82%E4%BD%95%E5%9C%A8%20Kubernetes%20%E4%B8%AD%E5%88%9B%E5%BB%BA%E5%86%85%E9%83%A8%E7%AC%AC%204%20%E5%B1%82%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1%E5%99%A8%EF%BC%9F.png)
我正在尝试在 AWS 中创建一个内部(无外部 IP)第 4 层负载均衡器 - 网络 LB 或经典 LB - 用于内部流量管理,而不是使用 kube-proxy。
下面是我的清单文件 - 无论我如何指定注释,它都会不断创建外部 LB。我尝试过不使用“aws-load-balancer-type”注释以及“aws-load-balancer-scheme”(默认为“内部”)。我不确定下一步该尝试什么。(我接下来可能会尝试第 7 层 LB。)
% k get svc|grep test
test-internal-lb LoadBalancer 10.100.253.178 a29xxx.us-west-2.elb.amazonaws.com 80:xxx/TCP,443:xxx/TCP 8s
apiVersion: v1
kind: Service
metadata:
name: test-internal-lb
annotations:
service.beta.kubernetes.io/aws-load-balancer-nlb-target-type: ip
service.beta.kubernetes.io/aws-load-balancer-scheme: internal
service.beta.kubernetes.io/aws-load-balancer-type: nlb-ip
spec:
type: LoadBalancer
selector:
app: test-app
ports:
- name: http
protocol: TCP
port: 80
targetPort: 8080
- name: https
protocol: TCP
port: 443
targetPort: 8080
答案1
解决方案:
test-app LoadBalancer 172.20.40.154 internal-a03xxx.us-west-2.elb.amazonaws.com 80:8000/TCP 11d
kind: Service
metadata:
name: test-app
annotations:
service.beta.kubernetes.io/aws-load-balancer-internal: “true”
service.beta.kubernetes.io/aws-load-balancer-backend-protocol: "http"
spec:
type: LoadBalancer
externalTrafficPolicy: Local
selector:
app: test-app
ports:
- name: http
protocol: TCP
port: 80
targetPort: 8000