Kuvel icon indicating copy to clipboard operation
Kuvel copied to clipboard

LoadBalancer should be defined as a label, not a ReplicaSet.

Open siloneco opened this issue 2 years ago • 0 comments

In the current Kuvel, ReplicaSet is regarded as a LoadBalancer, and load balance is performed to the pods under it. This is inconvenient when you want to load balance across ReplicaSet. In addition, due to the specification of k8s, when ReplicaSet is created under Deployment or StatefulSet, the label of ReplicaSet inherits the label of the Pod, so it is difficult to set that the label is given only to ReplicaSet and not to Pod. This makes the configuration of LoadBalancer difficult.

From 3.0.0, I would like to solve this problem and set up LoadBalancer by Pod's label. The name of the load balancer will be defined as the label value, and players will be load balanced to all pods with the same label value. Due to this change, pods with LoadBalancer specified will always specify a number after preferred-server-name. For example, pods that were previously registered as test-server when replica was 1 will now be registered as test-server-1.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: test-deployment
  namespace: minecraft
spec:
  selector:
    matchLabels:
      app: test
  template:
    metadata:
      labels:
        app: test
        kuvel.azisaba.net/enable-server-discovery: "true"
        kuvel.azisaba.net/preferred-server-name: "test-server" # will be registered as `test-server-1`
        kuvel.azisaba.net/load-balancer: "test-server"

siloneco avatar Jan 13 '23 07:01 siloneco