kubernetes: access Ingress within a Pod

5/27/2018

I have an Ingress object set up to route traffic to the appropriate Service based on the url path. I would like to access/expose this Ingress object within another Pod. I'm wondering if this is possible?

I tried to set up a Service on the Ingress but that didn't seem to work.

-- brianSan
kubernetes

2 Answers

5/29/2018

As fiunchinho mentioned in the comment, Ingress is designed to manage external traffic flow to cluster. To connect different pods inside the same cluster, you should use Service.

In your case, you can connect the pod to the Service that backs the Ingress object.

-- VAS
Source: StackOverflow

5/29/2018

Inside your cluster your pods use services to reach other pods.

From outside the cluster a client may use ingress to reach services.

Ingress resource allows connection to services. So your pod need to be reachable by a service (my-svc-N in the following example), which you're going to use in your ingress definition.

Take a look at this example:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: example-ing
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  backend:
    serviceName: default-http-backend
    servicePort: 80
  rules:
  - host: my-kube.info
    http:
      paths:
      - path: /
        backend:
          serviceName: my-svc-1
          servicePort: 80
  - host: cheeses.all
    http:
      paths:
      - path: /aaa
        backend:
          serviceName: my-svc-2
          servicePort: 80
      - path: /bbb
        backend:
          serviceName: my-svc-3
          servicePort: 80
-- Nicola Ben
Source: StackOverflow