CentOS Stream 9
Sponsored Link

Kubernetes : Kubeadm インストール2023/10/19

 

マルチノード Kubernetes クラスターを構成します。

当例では以下のように 4 台のノードを使用して設定します。

前提条件として、各ノードの [Hostname], [MAC address], [Product_uuid] は一意である必要があります。
[MAC address] と [Product_uuid] は、通常の物理マシンや一般的な方法で作成した仮想マシンであれば、通常は一意となっています。
[Product_uuid] は [dmidecode -s system-uuid] コマンドで確認できます。

+----------------------+   +----------------------+
|   [ mgr.srv.world ]  |   |   [ dlp.srv.world ]  |
|     Manager Node     |   |     Control Plane    |
+-----------+----------+   +-----------+----------+
        eth0|10.0.0.25             eth0|10.0.0.30
            |                          |
------------+--------------------------+-----------
            |                          |
        eth0|10.0.0.51             eth0|10.0.0.52
+-----------+----------+   +-----------+----------+
| [ node01.srv.world ] |   | [ node02.srv.world ] |
|     Worker Node#1    |   |     Worker Node#2    |
+----------------------+   +----------------------+

[1] Manager ノードを除く Kubernetes クラスターを構成する全ノードで、システム要件を満たすよう各設定を適用しておきます。
[root@dlp ~]#
cat > /etc/sysctl.d/99-k8s-cri.conf <<EOF
net.bridge.bridge-nf-call-iptables=1
net.ipv4.ip_forward=1
net.bridge.bridge-nf-call-ip6tables=1
EOF

[root@dlp ~]#
sysctl --system
[root@dlp ~]#
modprobe overlay

[root@dlp ~]#
modprobe br_netfilter

[root@dlp ~]#
echo -e overlay\\nbr_netfilter > /etc/modules-load.d/k8s.conf
# EPEL からインストール

[root@dlp ~]#
dnf --enablerepo=epel -y install iptables-legacy

[root@dlp ~]#
alternatives --config iptables


There are 2 programs which provide 'iptables'.

  Selection    Command
-----------------------------------------------
*+ 1           /usr/sbin/iptables-nft
   2           /usr/sbin/iptables-legacy

# [iptables-legacy] に切り替え
Enter to keep the current selection[+], or type selection number: 2

# Swap オフの設定

[root@dlp ~]#
swapoff -a

[root@dlp ~]#
vi /etc/fstab
# Swap 行はコメント化
#/dev/mapper/cs-swap     none                    swap    defaults        0 0
[2] Manager ノードを除く Kubernetes クラスターを構成する全ノードで、コンテナーランタイム, Kubeadm, Kubelet をインストールします。
コンテナーランタイムには、当例では CRI-O を利用します。
[root@dlp ~]#
dnf -y install centos-release-okd-4.14

[root@dlp ~]#
sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/CentOS-OKD-4.14.repo

[root@dlp ~]#
dnf --enablerepo=centos-okd-4.14 -y install cri-o
[root@dlp ~]#
systemctl enable --now crio
[root@dlp ~]#
cat <<'EOF' > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-$basearch
enabled=0
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF

[root@dlp ~]#
dnf --enablerepo=kubernetes -y install kubeadm kubelet cri-tools iproute-tc container-selinux
[root@dlp ~]#
systemctl enable kubelet
関連コンテンツ