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.
1台のマシンにのみインストールすれば問題ありません。
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 イメージ |