Specifying an external Load Balancing strategy in a YAML file

I’ve been reading about different strategies for the external load balancer in Kubernetes which include Round Robin, Kube-proxy L4 Round Robin Load Balancing, L7 Round Robin Load Balancing etc. but I cannot find anywhere where I would configure an externally exposed load balanced service to use a particular strategy type. I have created the following service description YAML file

apiVersion: v1
kind: Service
metadata:
name: epcluster-service
spec:
selector:
app: epcluster
ports:
- port: 8765
targetPort: 5000
type: LoadBalancer

This will create a service with a default Load Balancer. I cannot see how I would specify a strategy type e.g. Round Robin. I have extensively searched the web for this and although I can find many articles discussiong the strategies available, nowhere can I find how to acually choose one within a YAML file or via kurbctl.

Does anyone know how to do this, or am I misunderstanding how the Load Balancer is implemented?

Many thanks,

Damien

LoadBalancer services exist ‘outside’ of Kubernetes. They are part of the platform you’re on. GKE, AWS, or MetalLB are all different and have different sets of capabilities. There isn’t a way to really ‘normalize’ them from the Kubernetes perspective. They just have to satisfy the condition of directing external traffic to the hosts/pods.

For what you’re looking for, that either needs to be configured externally to Kubernetes OR some LB implementations can look at the annotations on a service for their provider specific configs.

Eg. LoadBalancer Service concepts  |  Google Kubernetes Engine (GKE)  |  Google Cloud

For your case, you should look at what LB specific configs your provider supports.

Thanks for your clear and detailed response. I had a feeling that this might be the case. I am currently using the limited Kubernetes instance that is available under Docker Desktop for testing. I suspect this also only offers a very limited range of LoadBalancing strategies. No probs, I’m just getting my head around how the system works and how to configure and depoy it in a production environment.

Thanks again,

Damien