Search code examples
nginxkuberneteskubernetes-ingressnginx-ingress

Kubernetes ingress update with deployment


We are currently setting up a kubernetes cluster for deploying our production workloads (mainly http rest services). In this cluster we have setup nginx ingress controller to route traffic to our services from the outside world. Since the ingress controller will be used mainly with path routing I do have the following questions:

  • Question 1: Dynamic backend routing

Is it possible to route the traffic to a backend, without specifically specifiying the backend name in the ingress specification? For example I have the followign ingress:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: example-ingress
  annotations:
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
    nginx.ingress.kubernetes.io/force-ssl-redirect: "false"
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - http:
      paths:
        - path: /apple
          backend:
            serviceName: apple-service
            servicePort: 8080

Is there any possibility that the /apple request is routed to the apple-service without specifically specifying it in the serviceName? So /apple is automatically routed to the apple-service service, /orange is automatically routed to the orange service without explicitly specifying the backend name?

  • Question Number 2

If there is no sulution to number 1 so that we can deploy based on some conventions, the question now goes further on how to manage the ingress in an automated way. Since the services are going to be deployed by an automated CI/CD pipeline, and new paths may be added as services are added to cluster, how can the ci/cd orchestrator (e.g. jenkins) update the ingress routes when an application is deployed? So that we are sure, that no manual intervention is needed into the cluster and each route is deployed together with the respective service?

I hope that the information given is enough to understand the issue. Thank you very much for your support.


Solution

  • The solution to number 2, is finally that each service deployment can be deployed together with each own ingress so no need for the point 1. That being said, you can have multiple ingress rules deployed.