Configure Multiple PorterLB Replicas

This document describes how to configure multiple PorterLB replicas to ensure high availability in a production environment. You can skip this document if PorterLB is used in a test environment. By default, only one PorterLB replica is installed in a Kubernetes cluster.

  • If all Kubernetes cluster nodes are deployed under the same router (BGP mode or Layer 2 mode), you are advised to configure at least two PorterLB replicas, which are installed on two Kubernetes cluster nodes respectively.
  • If the Kubernetes cluster nodes are deployed under different leaf routers (BGP mode only), you are advised to configure at least two PorterLB replicas (one replica for one node) under each leaf router. For details, see Configure PorterLB for Multi-router Clusters.

Prerequisites

You need to prepare a Kubernetes cluster where PorterLB has been installed.

Procedure

NOTE

The node names and namespace in the following steps are examples only. You need to use the actual values in your environment.
  1. Log in to the Kubernetes cluster and run the following command to label the Kubernetes cluster nodes where PorterLB is to be installed:

    kubectl label --overwrite nodes master1 worker-p002 lb.kubesphere.io/v1alpha1=porter
    

    NOTE

    In this example, PorterLB will be installed on master1 and worker-p002.
  2. Run the following command to scale the number of porter-manager Pods to 0:

    kubectl scale deployment porter-manager --replicas=0 -n porter-system
    
  3. Run the following command to edit the porter-manager Deployment:

    kubectl edit deployment porter-manager -n porter-system
    
  4. In the porter-manager Deployment YAML configuration, add the following fields under spec:template:spec:

    nodeSelector:
      kubernetes.io/os: linux
      lb.kubesphere.io/v1alpha1: porter
    
  5. Run the following command to scale the number of porter-manager Pods to the required number (change the number 2 to the actual value):

    kubectl scale deployment porter-manager --replicas=2 -n porter-system
    
  6. Run the following command to check whether PorterLB has been installed on the required nodes.

    kubectl get po -n porter-system -o wide
    

    verify-configuration-result

NOTE

  • In Layer 2 mode, PorterLB uses the leader election feature of Kubernetes to ensure that only one replica responds to ARP/NDP requests.
  • In BGP mode, all PorterLB replicas will respond to the BgpPeer configuration and attempt to establish a BGP connection with the peer BGP router by default. If the Kubernetes cluster nodes are deployed under different routers, you need to perform further configuration so that the PorterLB replicas establish BGP connections with the correct BGP routers. For details, see Configure PorterLB for Multi-router Clusters.

最新更新 January 30, 2023: improve documentation (6d8b189)