通过k8s service代理外部服务

通过k8s service代理外部服务

参考文章:《https://www.cnblogs.com/kuku0223/p/10898068.html》

本文中,需要通过service代理外部已经部署的nsqd服务,将其直接映射到某个更方便代码中统一使用的唯一名称。

apiVersion: v1
kind: Service
metadata:
  name: the-nsqd
spec:
  ports:
    - port: 80
      targetPort: 4151

---

kind: Endpoints
apiVersion: v1
metadata:
  name: the-nsqd
  # namespace: default
subsets:
  - addresses:
      - ip: 10.0.0.1
      - ip: 10.0.0.2
      - ip: 10.0.0.3
      - ip: 10.0.0.4
    ports:
      - port: 4151

实际上,k8s据说还有另外一种service代理方式, ExternalName
但这种配置方式不支持IP作为终点,仅支持 dns名称。

原文地址:https://www.cnblogs.com/morya/p/13732877.html