Fedora 43

Kubernetes : Kubeadm インストール2025/11/21

 

Kubeadm をインストールして、マルチノード Kubernetes クラスターを構成します。

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

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

また、当例では Firewalld は無効の設定で進めます。

-----------+---------------------------+--------------------------+------------
           |                           |                          |
       eth0|10.0.0.30              eth0|10.0.0.51             eth0|10.0.0.52
+----------+-----------+   +-----------+----------+   +-----------+----------+
|   [ dlp.srv.world ]  |   | [ node01.srv.world ] |   | [ node02.srv.world ] |
|     Control Plane    |   |      Worker Node     |   |      Worker Node     |
+----------------------+   +----------------------+   +----------------------+

[1] 全ノードで、システム要件を満たすよう各設定を適用しておきます。
[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
# Swap オフの設定

[root@dlp ~]#
swapoff -a

[root@dlp ~]#
touch /etc/systemd/zram-generator.conf
# [firewalld] は無効化

[root@dlp ~]#
systemctl disable --now firewalld
[2] 全ノードで、コンテナーランタイム, Kubeadm, Kubelet, Kubectl をインストールします。
コンテナーランタイムには、当例では CRI-O を利用します。
[root@dlp ~]#
dnf -y install cri-o1.34 crun
[root@dlp ~]#
systemctl enable --now crio
[root@dlp ~]#
cat <<'EOF' > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://pkgs.k8s.io/core:/stable:/v1.34/rpm/
enabled=0
gpgcheck=1
gpgkey=https://pkgs.k8s.io/core:/stable:/v1.34/rpm/repodata/repomd.xml.key
EOF

[root@dlp ~]#
dnf --enablerepo=kubernetes -y install kubeadm kubelet kubectl cri-tools iproute-tc container-selinux
[root@dlp ~]#
systemctl enable kubelet
[3] 全ノードで、SELinux を有効にしている場合は、ポリシーの変更が必要です。
[root@dlp ~]#
vi k8s.te
# 以下の内容で新規作成

module k8s 1.0;

require {
        type cgroup_t;
        type iptables_t;
        class dir ioctl;
}

#============= iptables_t ==============
allow iptables_t cgroup_t:dir ioctl;

[root@dlp ~]#
checkmodule -m -M -o k8s.mod k8s.te

[root@dlp ~]#
semodule_package --outfile k8s.pp --module k8s.mod

[root@dlp ~]#
semodule -i k8s.pp

関連コンテンツ