Skip to content

Deploying a Kubernetes Cluster

Introduction

sealos is a simple Go binary that can be installed on most Linux operating systems. It can be flexibly used to deploy Kubernetes clusters.

Prerequisites

  • Each cluster node must have a different hostname. Hostnames must not contain underscores.
  • All nodes must have synchronized time.
  • All nodes must be able to SSH into each other as the root user, and all nodes must share the same root password.
  • The sealos run command must be executed on the first node of the Kubernetes cluster. Cluster installation is not supported from outside the cluster.
  • It is recommended to use a clean operating system to create the cluster. Do not install Docker manually.
  • Most Linux distributions are supported, for example: Ubuntu, CentOS, Rocky Linux.
  • containerd is supported as the container runtime.
  • Use private IP addresses on public clouds.

Basic Information and Compatibility

Hostname IP Address Role K8s Configuration
k8s-master 192.168.100.101 master 4 CPU, 16G MEM, 100G DISK
K8s-node01 192.168.100.102 node01 4 CPU, 16G MEM, 100G DISK
K8s-node02 192.168.100.103 node02 4 CPU, 16G MEM, 100G DISK
Name Description
Offline installation supported Yes
Supported architectures amd64/arm64

Installation Steps

1. Set Hostnames

Execute the following commands respectively:

hostnamectl set-hostname k8s-master
hostnamectl set-hostname k8s-node01
hostnamectl set-hostname k8s-node02

2. Synchronize Time on All Nodes

Execute the following command on each node:

# Install ntpdate
yum install ntpdate -y

# Synchronize local time
ntpdate time.windows.com

# Synchronize with a network time source
ntpdate cn.pool.ntp.org

You can also set a crontab:

* */1 * * * /usr/sbin/ntpdate cn.pool.ntp.org

3. Install the sealos Command

Execute the following command to install:

wget https://static.guance.com/dataflux/package/sealos_4.1.5_linux_amd64.tar.gz \
   && tar zxvf sealos_4.1.5_linux_amd64.tar.gz sealos && chmod +x sealos && mv sealos /usr/bin
wget https://static.guance.com/dataflux/package/sealos_4.1.5_linux_arm64.tar.gz \
   && tar zxvf sealos_4.1.5_linux_arm64.tar.gz sealos && chmod +x sealos && mv sealos /usr/bin

Verify that the installation was successful:

$ sealos -h

simplest way install kubernetes tools.

Usage:
  sealos [command]

Available Commands:
  add         add some node
  apply       apply a kubernetes cluster
  build       build an cloud image from a Kubefile
  completion  Generate the autocompletion script for the specified shell
  create      Create a cluster without running the CMD
  delete      delete some node
  exec        exec a shell command or script on all node.
  gen         Generate a Clusterfile
  help        Help about any command
  images      list cloud image
  load        load cloud image
  login       login image repository
  logout      logout image repository
  prune       prune  image
  pull        pull cloud image
  push        push cloud image
  reset       Simplest way to reset your cluster
  rmi         Remove one or more cloud images
  run         Simplest way to run your kubernetes HA cluster
  save        save cloud image to a tar file
  scp         copy local file to remote on all node.
  tag         tag a image as a new one
  version     version

Flags:
      --cluster-root string   cluster root directory (default "/var/lib/sealos")
      --debug                 enable debug logger
  -h, --help                  help for sealos

Use "sealos [command] --help" for more information about a command.

You only need to install it on one machine.

4. Install the Cluster

sealos run pubrepo.guance.com/googleimages/kubernetes:v1.24.0 \
    pubrepo.guance.com/googleimages/calico:v3.22.1 \
    --masters 192.168.100.101     \
    --nodes 192.168.100.102,192.168.100.103     \
    --passwd [your-ssh-passwd] 

Note: The IP addresses and password in the command must be modified.

You must be the root user, and the ports between node environments must be accessible.

Parameter description:

Parameter Example Value Description
--masters 192.168.100.101 List of Kubernetes master node addresses
--nodes 192.168.100.102,192.168.100.103 List of Kubernetes node addresses
--passwd [your-ssh-passwd] SSH login password
kubernetes labring/kubernetes:v1.24.0 Kubernetes image

Verify Installation

kubectl get nodes

Additional Operations

Adding Nodes

Add a node:

sealos add --nodes 192.168.100.104,192.168.100.105

Add a master:

sealos add --masters 192.168.100.104,192.168.100.105

Deleting Nodes

Delete a node:

sealos delete --nodes 192.168.100.104,192.168.100.105

Delete a master:

sealos delete --masters 192.168.100.104,192.168.100.105

How to Uninstall

sealos reset

Feedback

Is this page helpful?