我正在尝试解决似乎很常见的问题的解决方案。
这适用于在8088端口上公开一项服务:
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: myingress
namespace: myns
annotations:
kubernetes.io/ingress.class: alb
alb.ingress.kubernetes.io/healthcheck-path: /ping
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/tags: Environment=dev,Team=test
alb.ingress.kubernetes.io/target-type: ip
alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 8088}]'
spec:
rules:
- host: myhost
http:
paths:
- path: /*
backend:
serviceName: firstservice
servicePort: 8088
使用ONE入口如何为两种服务实现相同的目的?
提前致谢。
最佳答案
最终,为了解决此问题,我使用了ALB入口 Controller 组功能,该功能当前处于alpha状态:https://github.com/kubernetes-sigs/aws-alb-ingress-controller/issues/914
这是我的入口资源现在的样子:
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: myingress_1
namespace: myns
annotations:
kubernetes.io/ingress.class: alb
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/tags: Environment=dev,Team=test
alb.ingress.kubernetes.io/target-type: ip
alb.ingress.kubernetes.io/group.name: mygroup
alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 8088}]'
spec:
rules:
- host: <HOST>
http:
paths:
- path: /*
backend:
serviceName: myservice
servicePort: 8088
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: myingress_2
namespace: myns
annotations:
kubernetes.io/ingress.class: alb
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/tags: Environment=dev,Team=test
alb.ingress.kubernetes.io/target-type: ip
alb.ingress.kubernetes.io/group.name: mygroup
alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 60004}]'
spec:
rules:
- host: <HOST>
http:
paths:
- path: /*
backend:
serviceName: myservice
servicePort: 60004
关键在哪里
alb.ingress.kubernetes.io/group.name: mygroup
连接这两个入口资源。
因此,我得出以下结论:
资源,但它们都指向同一个AWS ALB(因为同一个组
名称)
60004,它们每个都指向相同的k8s服务,但是
同一Pod上的不同端口(这很可能是两个不同的k8s服务
如果需要的话)
关于kubernetes - Kubernetes ALB入口: How to expose multiple ports on ingress resource,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/58065884/