This document describes how to build a Kubernetes cluster management environment by using the K3s application image. K3s is an open-source, extremely lightweight Kubernetes distribution. Currently, it is a Cloud Native Computing Foundation (CNCF) sandbox project. It has low requirements for server computing resources and can run in standalone mode. The K3s application image is preconfigured with the Kubernetes Dashboard visualization tool for easy Kubernetes cluster management in a browser.
NoteThe underlying layer of the sample K3s image in this document is based on CentOS 8.2 64-bit. Application images are subject to updates from time to time, and the actual image information on the purchase page shall prevail.
NoteThe default port for Kubernetes Dashboard is 9090.
The instance created with the K3s application image works as the Master in the cluster. You can add nodes to the cluster as instructed below:
TCP:6443
, UDP:8472
, and TCP:10250 (for node monitoring)
as instructed in Configuring Lighthouse firewall.k3s-add-node {node-ip}
The sample command is as follows:Note
- The Master is on CentOS 8.2. We recommend you create Lighthouse instances with the same OS in the same AZ as nodes in the cluster.
- Nodes need to be connected to the Master over the private network.
- Lighthouse instances in the same region under the same account are interconnected over the private network by default. For more information, see Region and Interconnection.
- To allow the communication among nodes in the cluster, open port
TCP:6443
,UDP:8472
, andTCP:10250
in the firewall rule as instructed in step1.
[lighthouse@VM-5-100-centos ~]$ k3s-add-node 10.0.5.158
The response is as follows:
Please ensure firewall rule(TCP:6443) of master node has been allowed!
root@10.0.5.158's password:
root
user password of the node to be added and press Enter. After the node is initiated, it will be added to the cluster.NoteIf you haven't set or forgotten the
root
user password, see Resetting Password.
The default NodePort range is 30000-32767. In some cases, due to network policy restrictions, you may need to modify this range in the following steps:
Enter the instance details page, select the Firewall tab, and open the modified NodePort (e.g., 30000–42767
) as instructed in Configuring Lighthouse firewall.
In Remote login on the instance details page, click Log in.
Run the following command to edit the k3s.service
configuration file.
sudo vi /etc/systemd/system/k3s.service
Press i to enter the edit mode, find ExecStart
, and add the --service-node-port-range
parameter to specify the NodePort; for example:
ExecStart=/usr/local/bin/k3s server --write-kubeconfig-mode=644 --service-node-port-range=30000-42767
The result should be as follows:
5. Press Esc and enter :wq to save the change and exit the edit mode.
6. Run the following command and enter the root
user password to restart the K3s service and make the configuration take effect.
systemctl daemon-reload && systemctl restart k3s
You can install an SSL certificate and enable HTTPS access for your website as instructed in Installing Certificate on NGINX Server.
Was this page helpful?