需要入口 -> 服务(无标签选择器) -> 服务(有标签选择器) -> pods...
设置蓝/绿环境,并且由于跨应用程序限制,我需要一个入口将流量发送到一个服务,该服务将流量转发到另一个可能经常更改的服务名称(因此我试图避免对任何 IP 地址进行硬编码)并且还需要支持另一个命名空间中的服务,以及稍后完全支持另一个集群中的服务。我读到,我可能需要手动创建自己的 EndpointSlice 以便入口使用的ExternalName 类型服务,但我正在使用 aws alb 控制器使用入口注释来创建 ALB,显然它不支持ExternalName 服务。即使在创建具有 FQDN 类型的端点切片后,我的入口也会给出端点未找到错误,无论下面的 live-svc 是否为ExternalName 类型。
重要提示:外部入口向其发送流量的服务在通过其内部 DNS 名称 live-svc.myNamespace.svc.cluster.local 引用时,需要在内部接收来自其他 Pod 的流量。由于延迟要求,流量无法退出集群并返回以进行应用程序间通信。因此,用户可以通过访问 app-live.mydomain.com 来访问 pod,或者集群内的其他应用程序可以引用 live-svc DNS 名称来访问,并且流量保留在集群内部。
以下是我正在尝试的。入口应到达 live-svc,然后 live-svc 将流量引导至 secondaryService,而 secondaryService 根据标签选择器将流量引导至 pod。我认为 EndpointSlice 是导致它无法工作的原因。 我是否必须创建 Endpoints 类型资源?我认为 EndpointSlice 正在取代 Endpoints 并且值得推荐?
apiVersion: v1
kind: Service
metadata:
name: live-svc
namespace: myNamespace
spec:
#type: ExternalName
#externalName: secondaryService.myNamespace.svc.cluster.local #this secondary service does select pods successfully
ports:
- name: https
port: 443
protocol: TCP
targetPort: https
apiVersion: discovery.k8s.io/v1
kind: EndpointSlice
metadata:
name: live-svc
namespace: myNamespace
labels:
kubernetes.io/service-name: live-svc
addressType: FQDN
ports:
- name: https
protocol: TCP
port: 443
endpoints:
- addresses:
- secondaryService.myNamespace.svc.cluster.local
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
...
name: app-public
namespace: myNamespace
spec:
rules:
- host: app-live.mydomain.com
http:
paths:
- backend:
service:
name: live-svc
port:
name: https
path: /
pathType: Prefix
...secondaryService which directs traffic to pods based on label selectors.
...
endpoints:
- addresses:
- secondaryService.myNamespace.svc.cluster.local
FQDN 不能是 K8s 服务类型 ClusterIP,不支持。