Set up an HA Cluster Using a Load Balancer
This tutorial demonstrates the general configurations of a high-availability cluster as you install KubeSphere on Linux.
Make sure you have prepared six Linux machines before you begin, with three of them serving as master nodes and the other three as worker nodes. The following image shows details of these machines, including their private IP address and role. For more information about system and network requirements, see Multi-node Installation.
You must create a load balancer in your environment to listen (also known as listeners on some cloud platforms) on key ports. Here is a table of recommended ports that need to be listened on.
Note
Make sure your load balancer at least listens on the port of apiserver.
You may need to open ports in your security group to ensure external traffic is not blocked depending on where your cluster is deployed. For more information, see .
You can configure both internal and external load balancers on some cloud platforms. After assigning a public IP address to the external load balancer, you can use the IP address to access the cluster.
For more information about how to configure load balancers, see Installing on Public Cloud to see specific steps on major public cloud platforms.
is the next-gen installer which provides an easy, fast and flexible way to install Kubernetes and KubeSphere. Follow the steps below to download KubeKey.
Run the following command first to make sure you download KubeKey from the correct zone.
Run the following command to download KubeKey:
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 steps below.
Note
The commands above download the latest release (v1.2.0) of KubeKey. You can change 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.21.5 is used as an example.
./kk create config --with-kubesphere v3.2.0 --with-kubernetes v1.21.5
Note
Recommended Kubernetes versions for KubeSphere 3.2.0: v1.19.x, v1.20.x, v1.21.x or v1.22.x (experimental). If you do not specify a Kubernetes version, KubeKey will install Kubernetes v1.21.5 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 commands above, a configuration file config-sample.yaml
will be created. Edit the file to add machine information, configure the load balancer and more.
Note
The file name may be different if you customize it.
spec:
hosts:
- {name: master1, address: 192.168.0.2, internalAddress: 192.168.0.2, user: ubuntu, password: Testing123}
- {name: master3, address: 192.168.0.4, internalAddress: 192.168.0.4, user: ubuntu, password: Testing123}
- {name: node1, address: 192.168.0.5, internalAddress: 192.168.0.5, user: ubuntu, password: Testing123}
- {name: node2, address: 192.168.0.6, internalAddress: 192.168.0.6, user: ubuntu, password: Testing123}
- {name: node3, address: 192.168.0.7, internalAddress: 192.168.0.7, user: ubuntu, password: Testing123}
roleGroups:
etcd:
- master1
- master3
master:
- master1
- master2
worker:
- node1
- node2
- node3
For more information about different fields in this configuration file, see and Multi-node Installation.
Configure the load balancer
Note
- The address and port should be indented by two spaces in
config-sample.yaml
. - In most cases, you need to provide the private IP address of the load balancer for the field
address
. However, different cloud providers may have different configurations for load balancers. For example, if you configure a Server Load Balancer (SLB) on Alibaba Cloud, the platform assigns a public IP address to the SLB, which means you need to specify the public IP address for the fieldaddress
. - The domain name of the load balancer is
lb.kubesphere.local
by default for internal access. - To use an internal load balancer, uncomment the field
internalLoadbalancer
.
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.
Enable pluggable components (Optional)
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 will be 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, you can execute the following command to start the installation:
./kk create cluster -f config-sample.yaml
Verify installation
-
When you see the following message, it means your HA cluster is successfully created.