user630702
user630702

Reputation: 3127

How do Ingress Controller and Ingress work together?

I don't see any link between the service and Ingress yaml files. How is it linked and how does it work? I looked at the nginx ingress controller but couldn't find any links to the ingress either.

How does the traffic flow? LB -> Ingress controller -> Ingress -> Backend service -> pods? And it seems only 80 and 443 are allowed by ingress. Does that mean any custom ports defined on ingress-nginx service is directly connected to the pod through like LB -> Backend service -> Pod?

Update: Figured out the traffic flow. Its as follows: LB -> Ingress controller -> Ingress -> Backend service -> pods

I have a https virtual host with a custom port and I guess I need to edit the ingress-controller yaml file to allow custom port and add the custom port to ingress and would it start routing?

Ingress.yml:

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: test
  namespace: test
  rules:
    - path: /
      backend:
        serviceName: httpd
        servicePort: 443

cloud-generic-service.yml:

apiVersion: v1
kind: Service
metadata:
  name: ingress-nginx
  namespace: ingress-nginx
  labels:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
data:
  1234: "test-web-dev/httpd:1234"
  1235: "test-web-dev/tomcat7:1235"
spec:
  externalTrafficPolicy: Local
  type: LoadBalancer
  selector:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
  ports:
    - name: http
      port: 80
      protocol: TCP
      targetPort: http
    - name: https
      port: 443
      protocol: TCP
      targetPort: https
    - name: port-1234
      port: 1234
      protocol: TCP
      targetPort: 1234
    - name: port-1235
      port: 1235
      protocol: TCP
      targetPort: 1235

Upvotes: 2

Views: 362

Answers (1)

kool
kool

Reputation: 3613

Explanation to this can be found in the documentation

Ingress exposes HTTP and HTTPS routes from outside the cluster to services within the cluster. Traffic routing is controlled by rules defined on the Ingress resource.

An Ingress may be configured to give Services externally-reachable URLs, load balance traffic, terminate SSL / TLS, and offer name-based virtual hosting.

So Ingress routes traffic from outside the cluster to service that you've specified in it, httpd in your example. You can specify how traffic should be used by adding annotations (example of annotation for nginx ingress).

The Ingress controller is an application that runs in a cluster and configures an HTTP load balancer according to Ingress resources. The load balancer can be a software load balancer running in the cluster or a hardware or cloud load balancer running externally. Different load balancers require different Ingress controller implementations.

In the case of NGINX, the Ingress controller is deployed in a pod along with the > load balancer.

Ingress resources requires Ingress controller to be present in the cluster. It is not deployed in to the cluster by default that's why it has has to be installed manually.

Upvotes: 1

Related Questions