【发布时间】:2019-02-26 18:51:01
【问题描述】:
作为从遗留服务发现框架迁移到 kube/CoreDNS 的一部分,我想创建一个知道如何自动发布 Endpoints 的服务,但也手动创建了端点。
基本上我认为我想要以下内容:
---
kind: Service
apiVersion: v1
metadata:
name: my-service
spec:
selector:
app: MyApp
ports:
- protocol: TCP
port: 80
---
kind: Endpoints
apiVersion: v1
metadata:
name: my-service
annotations:
transition: legacy
subsets:
- addresses:
- ip: 1.2.3.4
ports:
- port: 9376
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: service-discovery-backend
labels:
app: MyApp
spec:
replicas: 1
selector:
matchLabels:
app: MyApp
template:
metadata:
labels:
app: MyApp
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
不过,正如 the docs imply 一样,像这样明确设置会导致只有一个 Endpoints 对象与服务相关联——无论是服务的自动创建的对象还是我手动指定的对象似乎有所不同。
对于知道如何自行发布的服务和外部服务手动控制端点直到我们 100% 迁移,然后切换到基于选择器的方法,最合理的方法是使用 CoreDNS 作为服务发现吗?
【问题讨论】:
标签: kubernetes service-discovery