k8s-RockyLinux8.10上使用Sealos工具快速安装kubernetes集群
目录
1.环境准备
1.1环境描述
|
主机名 |
主机ip |
角色 |
操作系统 |
备注 |
|
k8s-master01 |
10.9.254.31 |
master |
RockyLinux8.10 |
|
|
k8s-master02 |
10.9.254.32 |
master |
RockyLinux8.10 |
|
|
k8s-master03 |
10.9.254.33 |
master |
RockyLinux8.10 |
|
|
k8s-worker01 |
10.9.254.34 |
worker |
RockyLinux8.10 |
|
|
k8s-worker02 |
10.9.254.35 |
worker |
RockyLinux8.10 |
1.2修改主机名(所有节点)
为每台服务器设置唯一的主机名,且不包含下划线。
|
[root@localhost ~]# hostnamectl set-hostname k8s-master01 [root@localhost ~]# bash [root@k8s-master01 ~]# |
1.3配置主机解析(所有节点)
在所有节点上配置 /etc/hosts,确保能通过主机名解析到正确的IP地址。
|
[root@k8s-master01 ~]# vim /etc/hosts |
|
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 10.9.254.31 k8s-master01 10.9.254.32 k8s-master02 10.9.254.33 k8s-master03 10.9.254.34 k8s-worker01 10.9.254.35 k8s-worker02 |
1.4配置时钟同步(所有节点)
|
[root@k8s-master01 ~]# dnf -y install chrony |
|
Installed: chrony-4.1-1.el8.x86_64 timedatex-0.5-3.el8.x86_64 Complete! |
|
[root@k8s-master01 ~]# ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime [root@k8s-master01 ~]# echo 'Asia/Shanghai' >/etc/timezone [root@k8s-master01 ~]# systemctl start chronyd [root@k8s-master01 ~]# systemctl enable chronyd [root@k8s-master01 ~]# vi /etc/chrony.conf |
|
#pool 2.pool.ntp.org iburst server ntp.aliyun.com iburst server cn.ntp.org.cn iburst |
|
[root@k8s-master01 ~]# systemctl restart chronyd [root@k8s-master01 ~]# chronyc sources -v |
|
.-- Source mode '^' = server, '=' = peer, '#' = local clock. / .- Source state '*' = current best, '+' = combined, '-' = not combined, | / 'x' = may be in error, '~' = too variable, '?' = unusable. || .- xxxx [ yyyy ] +/- zzzz || Reachability register (octal) -. | xxxx = adjusted offset, || Log2(Polling interval) --. | | yyyy = measured offset, || \ | | zzzz = estimated error. || | | \ MS Name/IP address Stratum Poll Reach LastRx Last sample =============================================================================== ^* 203.107.6.88 2 6 17 19 +12ms[ +13ms] +/- 31ms ^- 223.113.103.191 3 6 27 17 +15ms[ +15ms] +/- 112ms |
1.5关闭防火墙(所有节点)
|
[root@localhost ~]# systemctl disable --now firewalld [root@localhost ~]# setenforce 0 [root@localhost ~]# sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/sysconfig/selinux [root@localhost ~]# sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config [root@localhost ~]# cat /etc/selinux/config |
|
# This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=disabled # SELINUXTYPE= can take one of these three values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted |
2.安装Sealos
2.1下载Sealos(k8s-master01)
https://github.com/labring/sealos/releases

https://github.com/labring/sealos/releases/download/v5.1.1/sealos_5.1.1_linux_amd64.rpm
|
[root@k8s-master01 ~]# wget https://gh-proxy.org/https://github.com/labring/sealos/releases/download/v5.1.1/sealos_5.1.1_linux_amd64.rpm [root@k8s-master01 ~]# ll |
|
-rw-r--r-- 1 root root 28356113 Nov 17 12:24 sealos_5.1.1_linux_amd64.rpm |
2.2使用yum安装sealos
|
[root@k8s-master01 ~]# dnf -y localinstall sealos_5.1.1_linux_amd64.rpm |
|
Installed: sealos-5.1.1-1.x86_64 Complete! |
2.3验证安装
|
[root@k8s-master01 ~]# sealos --help |
|
sealos is a Kubernetes distribution, a unified OS to manage cloud native applications. Cluster Management Commands: apply Run cloud images within a kubernetes cluster with Clusterfile cert update Kubernetes API server's cert run Run cloud native applications with ease, with or without a existing cluster reset Reset all, everything in the cluster status state of sealos Node Management Commands: add Add nodes into cluster delete Remove nodes from cluster Remote Operation Commands: exec Execute shell command or script on specified nodes scp Copy file to remote on specified nodes Experimental Commands: registry registry related Container and Image Commands: build Build an image using instructions in a Containerfile or Kubefile create Create a cluster without running the CMD, for inspecting image diff Inspect changes to the object's file systems inspect Inspect the configuration of a container or image images List images in local storage load Load image(s) from archive file login Login to a container registry logout Logout of a container registry manifest Manipulate manifest lists and image indexes merge merge multiple images into one pull Pull images from the specified location push Push an image to a specified destination rmi Remove one or more images from local storage save Save image into archive file tag Add an additional name to a local image Other Commands: completion Generate the autocompletion script for the specified shell docs generate API reference env prints out all the environment information in use by sealos gen generate a Clusterfile with all default settings version Print version info Use "sealos --help" for more information about a given command. |
|
[root@k8s-master01 ~]# sealos version |
|
SealosVersion: buildDate: "2025-11-17T04:16:18Z" compiler: gc gitCommit: 1e312ad2c gitVersion: 5.1.1 goVersion: go1.23.12 platform: linux/amd6 |
3.在线部署kubernetes集群
3.1查看kubernetes版本支持
使用 Registry Explorer 可以查看 K8s 集群镜像的所有版本,直接输入 registry.cn-shanghai.aliyuncs.com/labring/kubernetes,然后点击“Submit Query”:


3.2安装指定版本的Kubernetes集群
|
sealos run registry.cn-shanghai.aliyuncs.com/labring/kubernetes:v1.31.9 registry.cn-shanghai.aliyuncs.com/labring/helm:v3.9.4 registry.cn-shanghai.aliyuncs.com/labring/cilium:v1.13.4 --masters 10.9.254.31,10.9.254.32,10.9.254.33 --nodes 10.9.254.34,10.9.254.35 -p P@88w0rd |
|
[root@k8s-master01 ~]# sealos run registry.cn-shanghai.aliyuncs.com/labring/kubernetes:v1.31.9 registry.cn-shanghai.aliyuncs.com/labring/helm:v3.9.4 registry.cn-shanghai.aliyuncs.com/labring/cilium:v1.13.4 --masters 10.9.254.31,10.9.254.32,10.9.254.33 --nodes 10.9.254.34,10.9.254.35 -p P@88w0rd |
|
2025-11-27T15:16:30 info succeeded in creating a new cluster, enjoy it! 2025-11-27T15:16:30 info ___ ___ ___ ___ ___ ___ /\ \ /\ \ /\ \ /\__\ /\ \ /\ \ /::\ \ /::\ \ /::\ \ /:/ / /::\ \ /::\ \ /:/\ \ \ /:/\:\ \ /:/\:\ \ /:/ / /:/\:\ \ /:/\ \ \ _\:\~\ \ \ /::\~\:\ \ /::\~\:\ \ /:/ / /:/ \:\ \ _\:\~\ \ \ /\ \:\ \ \__\ /:/\:\ \:\__\ /:/\:\ \:\__\ /:/__/ /:/__/ \:\__\ /\ \:\ \ \__\ \:\ \:\ \/__/ \:\~\:\ \/__/ \/__\:\/:/ / \:\ \ \:\ \ /:/ / \:\ \:\ \/__/ \:\ \:\__\ \:\ \:\__\ \::/ / \:\ \ \:\ /:/ / \:\ \:\__\ \:\/:/ / \:\ \/__/ /:/ / \:\ \ \:\/:/ / \:\/:/ / \::/ / \:\__\ /:/ / \:\__\ \::/ / \::/ / \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ Website: https://sealos.io/ Address: github.com/labring/sealos Version: 5.1.1-1e312ad2c |
|
[root@k8s-master01 ~]# kubectl get nodes |
|
NAME STATUS ROLES AGE VERSION k8s-master01 Ready control-plane 2m35s v1.31.9 k8s-master02 Ready control-plane 2m8s v1.31.9 k8s-master03 Ready control-plane 102s v1.31.9 k8s-worker01 Ready 97s v1.31.9 k8s-worker02 Ready 97s v1.31.9 |
参数说明:
--masters:指定 Master 节点 IP 地址列表。
--nodes:指定 Worker 节点 IP 地址列表。
-p:SSH 登录密码。
3.3安装指定版本的kubernetes单机版
|
$ sealos run registry.cn-shanghai.aliyuncs.com/labring/kubernetes:v1.31.9 registry.cn-shanghai.aliyuncs.com/labring/helm:v3.9.4 registry.cn-shanghai.aliyuncs.com/labring/cilium:v1.13.4 --single |
3.4安装分布式应用
|
sealos run registry.cn-shanghai.aliyuncs.com/labring/helm:v3.9.4 # install helm sealos run registry.cn-shanghai.aliyuncs.com/labring/openebs:v3.9.0 # install openebs sealos run registry.cn-shanghai.aliyuncs.com/labring/minio-operator:v4.5.5 registry.cn-shanghai.aliyuncs.com/labring/ingress-nginx:4.1.0 |
4.离线部署kubernetes集群
4.1下载集群镜像
|
[root@k8s-master01 ~]# sealos pull registry.cn-shanghai.aliyuncs.com/labring/kubernetes-docker:v1.31.9 [root@k8s-master01 ~]# sealos pull registry.cn-shanghai.aliyuncs.com/labring/helm:v3.9.4 [root@k8s-master01 ~]# sealos pull registry.cn-shanghai.aliyuncs.com/labring/calico:v3.28.1 |
|
[root@k8s-master01 ~]# sealos images |
|
REPOSITORY TAG IMAGE ID CREATED SIZE registry.cn-shanghai.aliyuncs.com/labring/helm v3.9.4 333b1a3d00b4 3 months ago 46.4 MB registry.cn-shanghai.aliyuncs.com/labring/kubernetes-docker v1.31.9 ae02ececbccc 6 months ago 674 MB registry.cn-shanghai.aliyuncs.com/labring/calico v3.28.1 3d5490e2bcb4 2 years ago 355 MB |
|
[root@k8s-master01 ~]# sealos save -o kubernetes.tar registry.cn-shanghai.aliyuncs.com/labring/kubernetes-docker:v1.31.9 [root@k8s-master01 ~]# sealos save -o helm.tar registry.cn-shanghai.aliyuncs.com/labring/helm:v3.9.4 [root@k8s-master01 ~]# sealos save -o calico.tar registry.cn-shanghai.aliyuncs.com/labring/calico:v3.28.1 |
4.2导入离线镜像
将打包文件拷贝到离线环境,使用 load 命令导入镜像即可
|
[root@k8s-master01 ~]# sealos load -i kubernetes.tar [root@k8s-master01 ~]# sealos load -i helm.tar [root@k8s-master01 ~]# sealos load -i calico.tar [root@k8s-master01 ~]# sealos images |
|
REPOSITORY TAG IMAGE ID CREATED SIZE registry.cn-shanghai.aliyuncs.com/labring/helm v3.9.4 333b1a3d00b4 3 months ago 46.4 MB registry.cn-shanghai.aliyuncs.com/labring/kubernetes-docker v1.31.9 ae02ececbccc 6 months ago 674 MB registry.cn-shanghai.aliyuncs.com/labring/calico v3.28.1 3d5490e2bcb4 2 years ago 355 MB |
4.3安装kubernetes集群
生成配置文件
sealos gen registry.cn-shanghai.aliyuncs.com/labring/kubernetes-docker:v1.31.9 registry.cn-shanghai.aliyuncs.com/labring/helm:v3.9.4 registry.cn-shanghai.aliyuncs.com/labring/calico:v3.28.1 \
--masters 10.9.254.31,10.9.254.32,10.9.254.33 \
--nodes 10.9.254.34,10.9.254.35 --passwd 'P@88w0rd' -o Clusterfile
|
[root@k8s-master01 ~]# sealos gen registry.cn-shanghai.aliyuncs.com/labring/kubernetes-docker:v1.31.9 registry.cn-shanghai.aliyuncs.com/labring/helm:v3.9.4 registry.cn-shanghai.aliyuncs.com/labring/calico:v3.28.1 \ > --masters 10.9.254.31,10.9.254.32,10.9.254.33 \ > --nodes 10.9.254.34,10.9.254.35 --passwd 'P@88w0rd' -o Clusterfile |
|
2025-12-01T16:47:48 info using v1beta4 kubeadm config |
|
[root@k8s-master01 ~]# ll |
|
-rw-r--r-- 1 root root 6631 Dec 1 16:47 Clusterfile |
|
[root@k8s-master01 ~]# cat Clusterfile |
|
apiVersion: apps.sealos.io/v1beta1 kind: Cluster metadata: creationTimestamp: null name: default spec: hosts: - ips: - 10.9.254.31:22 - 10.9.254.32:22 - 10.9.254.33:22 roles: - master - amd64 - ips: - 10.9.254.34:22 - 10.9.254.35:22 roles: - node - amd64 image: - registry.cn-shanghai.aliyuncs.com/labring/kubernetes-docker:v1.31.9 - registry.cn-shanghai.aliyuncs.com/labring/helm:v3.9.4 - registry.cn-shanghai.aliyuncs.com/labring/calico:v3.28.1 ssh: passwd: P@88w0rd status: {} --- apiVersion: kubeadm.k8s.io/v1beta4 kind: InitConfiguration localAPIEndpoint: advertiseAddress: 10.9.254.31 bindPort: 6443 nodeRegistration: kubeletExtraArgs: - name: node-ip value: 10.9.254.31 taints: null --- apiServer: certSANs: - 127.0.0.1 - apiserver.cluster.local - 10.103.97.2 - 10.9.254.31 - 10.9.254.32 - 10.9.254.33 extraArgs: - name: audit-log-format value: json - name: audit-log-maxage value: "7" - name: audit-log-maxbackup value: "10" - name: audit-log-maxsize value: "100" - name: audit-log-path value: /var/log/kubernetes/audit.log - name: audit-policy-file value: /etc/kubernetes/audit-policy.yml - name: enable-aggregator-routing value: "true" - name: feature-gates value: "" extraVolumes: - hostPath: /etc/kubernetes mountPath: /etc/kubernetes name: audit pathType: DirectoryOrCreate - hostPath: /var/log/kubernetes mountPath: /var/log/kubernetes name: audit-log pathType: DirectoryOrCreate - hostPath: /etc/localtime mountPath: /etc/localtime name: localtime pathType: File readOnly: true apiVersion: kubeadm.k8s.io/v1beta4 controlPlaneEndpoint: apiserver.cluster.local:6443 controllerManager: extraArgs: - name: bind-address value: 0.0.0.0 - name: cluster-signing-duration value: 876000h - name: feature-gates value: "" extraVolumes: - hostPath: /etc/localtime mountPath: /etc/localtime name: localtime pathType: File readOnly: true dns: {} etcd: local: dataDir: "" extraArgs: - name: listen-metrics-urls value: http://0.0.0.0:2381 kind: ClusterConfiguration kubernetesVersion: v1.31.9 networking: podSubnet: 100.64.0.0/10 serviceSubnet: 10.96.0.0/22 proxy: {} scheduler: extraArgs: - name: bind-address value: 0.0.0.0 - name: feature-gates value: "" extraVolumes: - hostPath: /etc/localtime mountPath: /etc/localtime name: localtime pathType: File readOnly: true --- apiVersion: kubeadm.k8s.io/v1beta4 caCertPath: /etc/kubernetes/pki/ca.crt controlPlane: localAPIEndpoint: bindPort: 6443 discovery: {} kind: JoinConfiguration nodeRegistration: taints: null --- apiVersion: kubeproxy.config.k8s.io/v1alpha1 bindAddress: 0.0.0.0 bindAddressHardFail: false clientConnection: acceptContentTypes: "" burst: 10 contentType: application/vnd.kubernetes.protobuf kubeconfig: "" qps: 5 clusterCIDR: "" configSyncPeriod: 15m0s conntrack: maxPerCore: 32768 min: 131072 tcpBeLiberal: false tcpCloseWaitTimeout: 1h0m0s tcpEstablishedTimeout: 24h0m0s udpStreamTimeout: 0s udpTimeout: 0s detectLocal: bridgeInterface: "" interfaceNamePrefix: "" detectLocalMode: "" enableProfiling: false healthzBindAddress: 0.0.0.0:10256 hostnameOverride: "" iptables: localhostNodePorts: true masqueradeAll: false masqueradeBit: 14 minSyncPeriod: 1s syncPeriod: 30s ipvs: excludeCIDRs: - 10.103.97.2/32 minSyncPeriod: 0s scheduler: "" strictARP: false syncPeriod: 30s tcpFinTimeout: 0s tcpTimeout: 0s udpTimeout: 0s kind: KubeProxyConfiguration logging: flushFrequency: 5s format: text options: json: infoBufferSize: "0" text: infoBufferSize: "0" verbosity: 0 metricsBindAddress: 0.0.0.0:10249 mode: ipvs nftables: masqueradeAll: false masqueradeBit: 14 minSyncPeriod: 1s syncPeriod: 30s nodePortAddresses: null oomScoreAdj: -999 portRange: "" showHiddenMetricsForVersion: "" winkernel: enableDSR: false forwardHealthCheckVip: false networkName: "" rootHnsEndpointName: "" sourceVip: "" --- address: 0.0.0.0 apiVersion: kubelet.config.k8s.io/v1beta1 authentication: anonymous: enabled: false webhook: cacheTTL: 2m0s enabled: true x509: clientCAFile: /etc/kubernetes/pki/ca.crt authorization: mode: Webhook webhook: cacheAuthorizedTTL: 5m0s cacheUnauthorizedTTL: 30s cgroupDriver: cgroupfs cgroupsPerQOS: true configMapAndSecretChangeDetectionStrategy: Watch containerLogMaxFiles: 5 containerLogMaxSize: 10Mi containerLogMaxWorkers: 1 containerLogMonitorInterval: 10s containerRuntimeEndpoint: unix:///run/containerd/containerd.sock contentType: application/vnd.kubernetes.protobuf cpuCFSQuota: true cpuCFSQuotaPeriod: 100ms cpuManagerPolicy: none cpuManagerReconcilePeriod: 10s enableControllerAttachDetach: true enableDebugFlagsHandler: true enableDebuggingHandlers: true enableProfilingHandler: true enableServer: true enableSystemLogHandler: true enforceNodeAllocatable: - pods eventBurst: 100 eventRecordQPS: 50 evictionHard: imagefs.available: 10% memory.available: 100Mi nodefs.available: 10% nodefs.inodesFree: 5% evictionPressureTransitionPeriod: 5m0s failSwapOn: true fileCheckFrequency: 20s hairpinMode: promiscuous-bridge healthzBindAddress: 0.0.0.0 healthzPort: 10248 httpCheckFrequency: 20s imageGCHighThresholdPercent: 85 imageGCLowThresholdPercent: 80 imageMaximumGCAge: 0s imageMinimumGCAge: 2m0s iptablesDropBit: 15 iptablesMasqueradeBit: 14 kind: KubeletConfiguration kubeAPIBurst: 100 kubeAPIQPS: 50 localStorageCapacityIsolation: true logging: flushFrequency: 5000000000 format: text options: json: infoBufferSize: "0" text: infoBufferSize: "0" verbosity: 0 makeIPTablesUtilChains: true maxOpenFiles: 1000000 maxPods: 110 memoryManagerPolicy: None memorySwap: {} memoryThrottlingFactor: 0.8 nodeLeaseDurationSeconds: 40 nodeStatusMaxImages: 50 nodeStatusReportFrequency: 10s nodeStatusUpdateFrequency: 10s oomScoreAdj: -999 podLogsDir: /var/log/pods podPidsLimit: -1 port: 10250 registerNode: true registryBurst: 100 registryPullQPS: 50 rotateCertificates: true runtimeRequestTimeout: 2m0s seccompDefault: false serializeImagePulls: false shutdownGracePeriod: 0s shutdownGracePeriodCriticalPods: 0s staticPodPath: /etc/kubernetes/manifests streamingConnectionIdleTimeout: 4h0m0s syncFrequency: 1m0s topologyManagerPolicy: none topologyManagerScope: container volumePluginDir: /usr/libexec/kubernetes/kubelet-plugins/volume/exec/ volumeStatsAggPeriod: 1m0s |
启动集群
|
[root@k8s-master01 ~]# sealos apply -f Clusterfile |
|
2025-12-01T17:14:22 info succeeded in creating a new cluster, enjoy it! 2025-12-01T17:14:22 info ___ ___ ___ ___ ___ ___ /\ \ /\ \ /\ \ /\__\ /\ \ /\ \ /::\ \ /::\ \ /::\ \ /:/ / /::\ \ /::\ \ /:/\ \ \ /:/\:\ \ /:/\:\ \ /:/ / /:/\:\ \ /:/\ \ \ _\:\~\ \ \ /::\~\:\ \ /::\~\:\ \ /:/ / /:/ \:\ \ _\:\~\ \ \ /\ \:\ \ \__\ /:/\:\ \:\__\ /:/\:\ \:\__\ /:/__/ /:/__/ \:\__\ /\ \:\ \ \__\ \:\ \:\ \/__/ \:\~\:\ \/__/ \/__\:\/:/ / \:\ \ \:\ \ /:/ / \:\ \:\ \/__/ \:\ \:\__\ \:\ \:\__\ \::/ / \:\ \ \:\ /:/ / \:\ \:\__\ \:\/:/ / \:\ \/__/ /:/ / \:\ \ \:\/:/ / \:\/:/ / \::/ / \:\__\ /:/ / \:\__\ \::/ / \::/ / \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ Website: https://sealos.io/ Address: github.com/labring/sealos Version: 5.1.1-1e312ad2c |
|
[root@k8s-master01 ~]# kubectl get nodes |
|
NAME STATUS ROLES AGE VERSION k8s-master01 Ready control-plane 2m3s v1.31.9 k8s-master02 Ready control-plane 95s v1.31.9 k8s-master03 Ready control-plane 63s v1.31.9 k8s-worker01 Ready 53s v1.31.9 k8s-worker02 Ready 54s v1.31.9 |
5.日常运维操作
5.1添加节点
#添加worker节点10.9.254.37
|
[root@localhost ~]# hostnamectl set-hostname k8s-worker03 [root@localhost ~]# bash [root@k8s-worker03 ~]# |
|
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 10.9.254.31 k8s-master01 10.9.254.32 k8s-master02 10.9.254.33 k8s-master03 10.9.254.34 k8s-worker01 10.9.254.35 k8s-worker02 10.9.254.37 k8s-worker03 |
|
[root@k8s-master01 ~]# sealos add --nodes 10.9.254.37 |
|
2025-11-27T15:33:54 info succeeded in scaling this cluster 2025-11-27T15:33:55 info ___ ___ ___ ___ ___ ___ /\ \ /\ \ /\ \ /\__\ /\ \ /\ \ /::\ \ /::\ \ /::\ \ /:/ / /::\ \ /::\ \ /:/\ \ \ /:/\:\ \ /:/\:\ \ /:/ / /:/\:\ \ /:/\ \ \ _\:\~\ \ \ /::\~\:\ \ /::\~\:\ \ /:/ / /:/ \:\ \ _\:\~\ \ \ /\ \:\ \ \__\ /:/\:\ \:\__\ /:/\:\ \:\__\ /:/__/ /:/__/ \:\__\ /\ \:\ \ \__\ \:\ \:\ \/__/ \:\~\:\ \/__/ \/__\:\/:/ / \:\ \ \:\ \ /:/ / \:\ \:\ \/__/ \:\ \:\__\ \:\ \:\__\ \::/ / \:\ \ \:\ /:/ / \:\ \:\__\ \:\/:/ / \:\ \/__/ /:/ / \:\ \ \:\/:/ / \:\/:/ / \::/ / \:\__\ /:/ / \:\__\ \::/ / \::/ / \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ Website: https://sealos.io/ Address: github.com/labring/sealos Version: 5.1.1-1e312ad2c |
|
[root@k8s-master01 ~]# kubectl get nodes |
|
NAME STATUS ROLES AGE VERSION k8s-master01 Ready control-plane 19m v1.31.9 k8s-master02 Ready control-plane 18m v1.31.9 k8s-master03 Ready control-plane 18m v1.31.9 k8s-worker01 Ready 18m v1.31.9 k8s-worker02 Ready 18m v1.31.9 k8s-worker03 Ready 34s v1.31.9 |
#添加master节点10.9.254.36
|
[root@localhost ~]# hostnamectl set-hostname k8s-master04 [root@localhost ~]# bash [root@k8s-master04 ~]# vim /etc/hosts |
|
10.9.254.31 k8s-master01 10.9.254.32 k8s-master02 10.9.254.33 k8s-master03 10.9.254.34 k8s-worker01 10.9.254.35 k8s-worker02 10.9.254.36 k8s-master04 |
|
[root@k8s-master01 ~]# sealos add --masters 10.9.254.36 |
|
2025-11-27T15:41:26 info succeeded in scaling this cluster 2025-11-27T15:41:26 info ___ ___ ___ ___ ___ ___ /\ \ /\ \ /\ \ /\__\ /\ \ /\ \ /::\ \ /::\ \ /::\ \ /:/ / /::\ \ /::\ \ /:/\ \ \ /:/\:\ \ /:/\:\ \ /:/ / /:/\:\ \ /:/\ \ \ _\:\~\ \ \ /::\~\:\ \ /::\~\:\ \ /:/ / /:/ \:\ \ _\:\~\ \ \ /\ \:\ \ \__\ /:/\:\ \:\__\ /:/\:\ \:\__\ /:/__/ /:/__/ \:\__\ /\ \:\ \ \__\ \:\ \:\ \/__/ \:\~\:\ \/__/ \/__\:\/:/ / \:\ \ \:\ \ /:/ / \:\ \:\ \/__/ \:\ \:\__\ \:\ \:\__\ \::/ / \:\ \ \:\ /:/ / \:\ \:\__\ \:\/:/ / \:\ \/__/ /:/ / \:\ \ \:\/:/ / \:\/:/ / \::/ / \:\__\ /:/ / \:\__\ \::/ / \::/ / \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ Website: https://sealos.io/ Address: github.com/labring/sealos Version: 5.1.1-1e312ad2c |
|
[root@k8s-master01 ~]# kubectl get nodes |
|
NAME STATUS ROLES AGE VERSION k8s-master01 Ready control-plane 26m v1.31.9 k8s-master02 Ready control-plane 26m v1.31.9 k8s-master03 Ready control-plane 25m v1.31.9 k8s-master04 Ready control-plane 56s v1.31.9 k8s-worker01 Ready 25m v1.31.9 k8s-worker02 Ready 25m v1.31.9 k8s-worker03 Ready 8m22s v1.31.9 |
5.2删除节点
#删除worker节点10.9.254.37
|
[root@k8s-master01 ~]# sealos delete --nodes 10.9.254.37 |
|
2025-11-27T15:45:43 info succeeded in scaling this cluster 2025-11-27T15:45:44 info ___ ___ ___ ___ ___ ___ /\ \ /\ \ /\ \ /\__\ /\ \ /\ \ /::\ \ /::\ \ /::\ \ /:/ / /::\ \ /::\ \ /:/\ \ \ /:/\:\ \ /:/\:\ \ /:/ / /:/\:\ \ /:/\ \ \ _\:\~\ \ \ /::\~\:\ \ /::\~\:\ \ /:/ / /:/ \:\ \ _\:\~\ \ \ /\ \:\ \ \__\ /:/\:\ \:\__\ /:/\:\ \:\__\ /:/__/ /:/__/ \:\__\ /\ \:\ \ \__\ \:\ \:\ \/__/ \:\~\:\ \/__/ \/__\:\/:/ / \:\ \ \:\ \ /:/ / \:\ \:\ \/__/ \:\ \:\__\ \:\ \:\__\ \::/ / \:\ \ \:\ /:/ / \:\ \:\__\ \:\/:/ / \:\ \/__/ /:/ / \:\ \ \:\/:/ / \:\/:/ / \::/ / \:\__\ /:/ / \:\__\ \::/ / \::/ / \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ Website: https://sealos.io/ Address: github.com/labring/sealos Version: 5.1.1-1e312ad2c |
|
[root@k8s-master01 ~]# kubectl get nodes |
|
NAME STATUS ROLES AGE VERSION k8s-master01 Ready control-plane 30m v1.31.9 k8s-master02 Ready control-plane 30m v1.31.9 k8s-master03 Ready control-plane 29m v1.31.9 k8s-master04 Ready control-plane 4m43s v1.31.9 k8s-worker01 Ready 29m v1.31.9 k8s-worker02 Ready 29m v1.31.9 |
#删除master节点10.9.254.36
|
[root@k8s-master01 ~]# sealos delete --masters 10.9.254.36 |
|
2025-11-27T15:49:55 info succeeded in scaling this cluster 2025-11-27T15:49:56 info ___ ___ ___ ___ ___ ___ /\ \ /\ \ /\ \ /\__\ /\ \ /\ \ /::\ \ /::\ \ /::\ \ /:/ / /::\ \ /::\ \ /:/\ \ \ /:/\:\ \ /:/\:\ \ /:/ / /:/\:\ \ /:/\ \ \ _\:\~\ \ \ /::\~\:\ \ /::\~\:\ \ /:/ / /:/ \:\ \ _\:\~\ \ \ /\ \:\ \ \__\ /:/\:\ \:\__\ /:/\:\ \:\__\ /:/__/ /:/__/ \:\__\ /\ \:\ \ \__\ \:\ \:\ \/__/ \:\~\:\ \/__/ \/__\:\/:/ / \:\ \ \:\ \ /:/ / \:\ \:\ \/__/ \:\ \:\__\ \:\ \:\__\ \::/ / \:\ \ \:\ /:/ / \:\ \:\__\ \:\/:/ / \:\ \/__/ /:/ / \:\ \ \:\/:/ / \:\/:/ / \::/ / \:\__\ /:/ / \:\__\ \::/ / \::/ / \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ Website: https://sealos.io/ Address: github.com/labring/sealos Version: 5.1.1-1e312ad2c |
|
[root@k8s-master01 ~]# kubectl get nodes |
|
NAME STATUS ROLES AGE VERSION k8s-master01 Ready control-plane 34m v1.31.9 k8s-master02 Ready control-plane 34m v1.31.9 k8s-master03 Ready control-plane 33m v1.31.9 k8s-worker01 Ready 33m v1.31.9 k8s-worker02 Ready 33m v1.31.9 |
注意:在删除节点,尤其是 Master 节点时,请确保集群中剩余节点数量能满足高可用需求。如果遇到节点删除失败的问题(例如 SSH 认证失败),请检查并确保所有节点的 SSH 凭据一致。
5.3清理集群
|
[root@k8s-master01 ~]# sealos reset |
|
2025-11-27T15:53:18 info succeeded in deleting current cluster 2025-11-27T15:53:18 info using v1beta3 kubeadm config 2025-11-27T15:53:18 info ___ ___ ___ ___ ___ ___ /\ \ /\ \ /\ \ /\__\ /\ \ /\ \ /::\ \ /::\ \ /::\ \ /:/ / /::\ \ /::\ \ /:/\ \ \ /:/\:\ \ /:/\:\ \ /:/ / /:/\:\ \ /:/\ \ \ _\:\~\ \ \ /::\~\:\ \ /::\~\:\ \ /:/ / /:/ \:\ \ _\:\~\ \ \ /\ \:\ \ \__\ /:/\:\ \:\__\ /:/\:\ \:\__\ /:/__/ /:/__/ \:\__\ /\ \:\ \ \__\ \:\ \:\ \/__/ \:\~\:\ \/__/ \/__\:\/:/ / \:\ \ \:\ \ /:/ / \:\ \:\ \/__/ \:\ \:\__\ \:\ \:\__\ \::/ / \:\ \ \:\ /:/ / \:\ \:\__\ \:\/:/ / \:\ \/__/ /:/ / \:\ \ \:\/:/ / \:\/:/ / \::/ / \:\__\ /:/ / \:\__\ \::/ / \::/ / \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ Website: https://sealos.io/ Address: github.com/labring/sealos Version: 5.1.1-1e312ad2c |
6.集群部署与运维核心命令速查
|
阶段 |
任务 |
核心命令 |
|
环境准备 |
设置主机名 |
hostnamectl set-hostname |
|
配置主机解析 |
vi /etc/hosts |
|
|
时间同步 |
chronyd |
|
|
关闭防火墙 |
systemctl disable --now firewalld |
|
|
安装Sealos |
下载并安装 |
yum -y install sealos_5.1.1_linux_amd64.rpm |
|
验证安装 |
sealos --version |
|
|
部署集群 |
集群安装 |
sealos run registry.cn-shanghai.aliyuncs.com/labring/kubernetes:v1.31.9 ...... |
|
日常运维 |
添加节点 |
sealos add --nodes 10.9.254.37 |
|
删除节点 |
sealos delete --nodes 10.9.254.37 |
|
|
清理集群 |
sealos reset |
|
|
集群状态检查 |
kubectl get nodes |
更多推荐

所有评论(0)