Let's say I have multiple endpoints in my application that are exposed as different Kubernetes services via an ingress controller.
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: test
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- host: foo.bar.com
http:
paths:
- path: /service1
backend:
serviceName: service1
servicePort: 80
- path: /service2
backend:
serviceName: service2
servicePort: 80
Let us say service2 endpoint does not receive requests for a long time, so a serverless strategy is appropriate for it. Can I configure a Kubernetes ingress controller to dynamically scale service deployments up when a request arrives after a long time to service2 and shut down the pods for service2 when no request arrives for a long time?
I don't think ingress controller can auto scale pods. Look at kubernetes autoscalar (https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/), this can be used to horizontally scale pods of your deployment (or other resources where replicas can be specified).
Nginx ingress can not be used for serverless. You can use knative for this use case.