Kubernetes Ingress and Service object

9/27/2020

I have a deployment which is WEB API. I apply it to Kubernetes. Then add service.yml file to expose it. It is working. I have 12 microservices. All of them have service and deployment .yaml files.

So what is Ingress controller. Why should I use it?

(Except sidecar proxy like istio. Its perfect for resilince and metrics.)

enter image description here

-- eren arslan
kubernetes

1 Answer

9/27/2020

In order for the Ingress resource to work, the cluster must have an ingress controller running. The controller can be for example Nginx Ingress Controller and it can be adjusted in various ways. After you have deployed the controller, all you need is an Ingress resource object deployed in K8s.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-sample
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - http:
      paths:
      - path: /api
        pathType: Prefix
        backend:
          service:
            name: web-api
            port:
              number: 80

service.name: web-api is the place where you specify link between the ingress and the service.

-- Ivan Aracki
Source: StackOverflow