Kubernetes Cross Namespace Ingress Network

后端 未结 1 1519
甜味超标
甜味超标 2020-12-31 11:36

I have a simple ingress network, I want to access services at different namespaces, from this ingress network.

How I can do this? My ingress network yaml file:

相关标签:
1条回答
  • 2020-12-31 12:32

    An ExternalName service is a special case of service that does not have selectors and uses DNS names instead.

    You can find out more about ExternalName service from the official Kubernetes documentation:

    When you want to access a service from a different namespace, your yaml could, for example, look like this:

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

    As to your Ingress yaml file, please recheck it and make sure it is compliant with the official examples, for example this one as it contains some inconsistency:

    apiVersion: extensions/v1beta1  
    kind: Ingress  
    metadata:  
      name: my-ingress  
    spec:  
      rules:  
      - host: www.mysite.com  
        http:  
          paths:  
          - backend:  
              serviceName: website  
              servicePort: 80  
      - host: forums.mysite.com  
        http:  
          paths:  
          - path:  
            backend:  
              serviceName: forums  
              servicePort: 80
    

    Please also recheck ExternalName yaml as it has TargetPorts and selectors which are not used in this type of Service and make sure that:

    ExternalName Services are available only with kube-dns version 1.7 and later.

    In case you will not succeed, please share the kind of problem you have meet.

    0 讨论(0)
提交回复
热议问题