Service located in another namespace

前端 未结 4 1979
無奈伤痛
無奈伤痛 2020-11-28 01:29

I have been trying to find a way to define a service in one namespace that links to a Pod running in another namespace. I know that containers in a Pod running in nam

4条回答
  •  误落风尘
    2020-11-28 01:40

    I stumbled over the same issue and found a nice solution which does not need any static ip configuration:

    You can access a service via it's DNS name (as mentioned by you): servicename.namespace.svc.cluster.local

    You can use that DNS name to reference it in another namespace via a local service:

    kind: Service
    apiVersion: v1
    metadata:
      name: service-y
      namespace: namespace-a
    spec:
      type: ExternalName
      externalName: service-x.namespace-b.svc.cluster.local
      ports:
      - port: 80
    

提交回复
热议问题