Kubernetes: Ingress

Ingress is an API object that allows communication to services inside a cluster from external sources. It manages inbound connections. Ingress allows us to do Name-based virtual hosting, load-balance traffic , do SSL Termination and provide external based URL’s. Ingress allows us to route and serve traffic based on request host or path. Currently, Ingress only supports HTTP based rules. Before Ingress can be used, an Ingress Controller needs to be installed in the cluster. Multiple Ingress Controller can be installed in the cluster. The Ingress Controller uses the rules specified in the Ingress configuration to handle traffic from outside the cluster. Ingress can be configured to use TLS also by creating a secret that contains SSL certificate .crt and .key files key values in the secret manifest. We then specify the secret as part of the Ingress configuration. Below are examples of Ingress manifest.

Here is an example of multiple host entries under one Ingress configuration.

kind: Ingress
apiVersion: extensions/v1beta1
metadata:
  name: hello
spec:
  rules:
  - host: aquatribe.com
    http:
      paths:
      - path: /about
        backend:
          serviceName: about-service
          servicePort: 80
  - host: eksmanual.com
    http:
      paths:
      - path: /manual
        backend:
          serviceName: eks-service
          servicePort: 80

Here is one with a single host and multiple paths.

kind: Ingress
apiVersion: extensions/v1beta1
metadata:
  name: hello-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target:
spec:
  rules:
    - host: aquatribe.com
      http:
        paths:
          - path: /about
            backend:
              serviceName: about-svc
              servicePort: 8080
          - path: /consult
            backend:
              serviceName: consult-svc
              servicePort: 8080

Leave a Reply

Your email address will not be published. Required fields are marked *