I had found a definition, when reviewing a project, that intrigued me: the use of Ingress with a Service of type LoadBalancer without installing the load balancer itself on Kind. As defined, it seems to work but I don't know why. I say that it works because I'm able to curl the application on browser as expected.
Code:
apiVersion: apps/v1
kind: Deployment
metadata:
name: server
labels:
app: server
spec:
replicas: 1
selector:
matchLabels:
app: server
template:
metadata:
labels:
app: server
spec:
containers:
- name: server
image: localhost:5000/server:2.0
---
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
app: server
name: server
spec:
type: LoadBalancer
selector:
app: server
ports:
- port: 8080
targetPort: 8080
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: server
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: server
port:
number: 8080
I thought that hitting a Ingress and then the LoadBalancer would cause some redirect issue. My choice for that case would be a simple ClusterIP instead, this answer agrees. If MetalLB is not installed on the cluster, what the LoadBalancer do here? This may have a point for wanting something like that, but as far as I know, the load balancer by itself is a resource outside the cluster, i.e: a cloud provider load balancer.