Set Up an HA Cluster Using the Internal HAProxy of KubeKey

    This document describes how to use the built-in high availability mode when installing KubeSphere on Linux.

    The following figure shows the example architecture of the built-in high availability mode. For more information about system and network requirements, see Multi-node Installation.

    Note

    In the development environment, make sure you have prepared six Linux machines, among which three of them serve as control planes and the other three as worker nodes.

    Refer to the following steps to download KubeKey.

    Download KubeKey from or run the following command.

    Run the following command first to make sure that you download KubeKey from the correct zone.

    1. curl -sfL https://get-kk.kubesphere.io | VERSION=v2.2.1 sh -

    Note

    After you download KubeKey, if you transfer it to a new machine also with poor network connections to Googleapis, you must run export KKZONE=cn again before you proceed with the following steps.

    Note

    The preceding commands download the latest release of KubeKey (v2.2.1). You can modify the version number in the command to download a specific version.

    Make kk executable:

    Create an example configuration file with default configurations. Here Kubernetes v1.22.10 is used as an example.

    1. ./kk create config --with-kubesphere v3.3.0 --with-kubernetes v1.22.10

    Note

    • Recommended Kubernetes versions for KubeSphere 3.3.0: v1.19.x, v1.20.x, v1.21.x, v1.22.x, and v1.23.x (experimental support). If you do not specify a Kubernetes version, KubeKey will install Kubernetes v1.23.7 by default. For more information about supported Kubernetes versions, see Support Matrix.
    • If you add the flag --with-kubesphere without specifying a KubeSphere version, the latest version of KubeSphere will be installed.

    After you run the preceding commands, a configuration file config-sample.yaml is created. Edit the file to add machine information, configure the load balancer and more.

    The file name may be different if you customize it.

    1. spec:
    2. hosts:
    3. - {name: master1, address: 192.168.0.2, internalAddress: 192.168.0.2, user: ubuntu, password: Testing123}
    4. - {name: master3, address: 192.168.0.4, internalAddress: 192.168.0.4, user: ubuntu, password: Testing123}
    5. - {name: node1, address: 192.168.0.5, internalAddress: 192.168.0.5, user: ubuntu, password: Testing123}
    6. - {name: node2, address: 192.168.0.6, internalAddress: 192.168.0.6, user: ubuntu, password: Testing123}
    7. - {name: node3, address: 192.168.0.7, internalAddress: 192.168.0.7, user: ubuntu, password: Testing123}
    8. roleGroups:
    9. etcd:
    10. - master1
    11. - master2
    12. control-plane:
    13. - master1
    14. - master2
    15. worker:
    16. - node1
    17. - node2
    18. - node3

    For more information about different fields in this configuration file, see and Multi-node Installation.

    Enable the built-in high availability mode

    Note

    • To enable the built-in high availability mode, uncomment the field internalLoadbalancer.
    • The fields address and port in config-sample.yaml must be indented by two spaces against controlPlaneEndpoint.
    • The default internal access domain name for the load balancer is lb.kubesphere.local.

    For a production environment, you need to prepare persistent storage and configure the storage plugin (for example, CSI) in config-sample.yaml to define which storage service you want to use. For more information, see Persistent Storage Configurations.

    (Optional) Enable pluggable components

    KubeSphere has decoupled some core feature components since v2.1.0. These components are designed to be pluggable which means you can enable them either before or after installation. By default, KubeSphere is installed with the minimal package if you do not enable them.

    You can enable any of them according to your demands. It is highly recommended that you install these pluggable components to discover the full-stack features and capabilities provided by KubeSphere. Make sure your machines have sufficient CPU and memory before enabling them. See Enable Pluggable Components for details.

    After you complete the configuration, run the following command to start installation:

    1. ./kk create cluster -f config-sample.yaml

    Verify installation

    1. Run the following command to inspect the logs of installation.