Kubernetes 클러스터 배포¶
개요¶
sealos는 간단한 Go 바이너리 파일로, 대부분의 Linux 운영 체제에 설치할 수 있습니다. Kubernetes 클러스터 배포를 유연하게 수행하는 데 사용할 수 있습니다.
사전 조건¶
- 각 클러스터 노드는 서로 다른 호스트 이름을 가져야 합니다. 호스트 이름에 밑줄(
_)을 포함하지 마십시오. - 모든 노드의 시간이 동기화되어야 합니다.
- 모든 노드는 root 사용자로 서로 SSH 로그인이 가능해야 하며, 모든 노드의 root 비밀번호가 동일해야 합니다.
- Kubernetes 클러스터의 첫 번째 노드에서
sealos run명령어를 실행해야 합니다. 현재 클러스터 외부의 노드에서는 클러스터 설치를 지원하지 않습니다. - 클러스터를 생성할 때는 깨끗한 운영 체제를 사용하는 것을 권장합니다. Docker를 직접 설치하지 마십시오.
- 대부분의 Linux 배포판을 지원합니다. 예: Ubuntu, CentOS, Rocky Linux.
- containerd를 컨테이너 런타임으로 사용하는 것을 지원합니다.
- 퍼블릭 클라우드에서는 프라이빗 IP를 사용하십시오.
기본 정보 및 호환성¶
| 호스트 이름 | IP 주소 | 역할 | K8s 구성 |
|---|---|---|---|
| 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 |
| 항목 | 설명 |
|---|---|
| 오프라인 설치 지원 여부 | 지원함 |
| 지원 아키텍처 | amd64/arm64 |
설치 단계¶
1. 호스트 이름 설정¶
각각 다음 명령어를 실행합니다:
hostnamectl set-hostname k8s-master
hostnamectl set-hostname k8s-node01
hostnamectl set-hostname k8s-node02
2. 노드 시간 동기화¶
각 노드에서 다음 명령어를 실행합니다:
# ntpdate 설치
yum install ntpdate -y
# 로컬 시간 동기화
ntpdate time.windows.com
# 네트워크 소스와 동기화
ntpdate cn.pool.ntp.org
crontab을 설정할 수도 있습니다.
* */1 * * * /usr/sbin/ntpdate cn.pool.ntp.org
3. sealos 명령어 설치¶
다음 명령어를 실행하여 설치합니다:
배포 성공 여부를 확인합니다:
$ 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.
한 대의 머신에만 설치하면 됩니다.
4. 클러스터 설치¶
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]
명령어의 IP와 비밀번호는 수정해야 합니다.
반드시 root 사용자여야 하며, 노드 간 환경 포트는 서로 통신 가능해야 합니다.
매개변수 설명:
| 매개변수명 | 매개변수값 예시 | 매개변수 설명 |
|---|---|---|
--masters |
192.168.100.101 | kubernetes master 노드 주소 목록 |
--nodes |
192.168.100.102,192.168.100.103 | kubernetes node 노드 주소 목록 |
--passwd |
[your-ssh-passwd] | SSH 로그인 비밀번호 |
| kubernetes | labring/kubernetes:v1.24.0 | kubernetes 이미지 |