Debian 12 bookworm
Sponsored Link

Kubernetes : Kubeadm インストール2023/07/28

 

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

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

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

-----------+---------------------------+--------------------------+------------
           |                           |                          |
       eth0|10.0.0.25              eth0|10.0.0.71             eth0|10.0.0.72
+----------+-----------+   +-----------+-----------+   +-----------+-----------+
|  [ ctrl.srv.world ]  |   |  [snode01.srv.world]  |   |  [snode02.srv.world]  |
|     Control Plane    |   |      Worker Node      |   |      Worker Node      |
+----------------------+   +-----------------------+   +-----------------------+

[1] 全ノードで、Containerd をインストールし、システム要件を満たすよう各設定を適用しておきます。
root@ctrl:~#
apt -y install containerd iptables apt-transport-https gnupg2 curl sudo
root@ctrl:~#
cat > /etc/sysctl.d/99-k8s-cri.conf <<EOF
net.bridge.bridge-nf-call-iptables=1
net.bridge.bridge-nf-call-ip6tables=1
net.ipv4.ip_forward=1
EOF
root@ctrl:~#
sysctl --system
root@ctrl:~#
modprobe overlay; modprobe br_netfilter

root@ctrl:~#
echo -e overlay\\nbr_netfilter > /etc/modules-load.d/k8s.conf
# iptables のバックエンドは [iptables-legacy]
# nftables になっている場合は要変更

root@ctrl:~#
update-alternatives --config iptables

There are 2 choices for the alternative iptables (providing /usr/sbin/iptables).

  Selection    Path                       Priority   Status
------------------------------------------------------------
* 0            /usr/sbin/iptables-nft      20        auto mode
  1            /usr/sbin/iptables-legacy   10        manual mode
  2            /usr/sbin/iptables-nft      20        manual mode

Press <enter> to keep the current choice[*], or type selection number: 1
update-alternatives: using /usr/sbin/iptables-legacy to provide /usr/sbin/iptables (iptables) in manual mode

# swap は要無効化

root@ctrl:~#
swapoff -a

root@ctrl:~#
vi /etc/fstab
# swap 行はコメント化
#/dev/mapper/debian--vg-swap_1 none            swap    sw              0       0

# Cgroup v1 への切り替え (デフォルトは v2)

root@ctrl:~#
vi /etc/default/grub
# 10行目 : 追記

GRUB_CMDLINE_LINUX="
systemd.unified_cgroup_hierarchy=0
"
root@ctrl:~#
update-grub

root@ctrl:~#
reboot
[2] 全ノードで Kubeadm, Kubelet, Kubectl をインストールします。
当例では Kubernetes Version=1.26.6 を指定してインストールします。
root@ctrl:~#
curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg -o /etc/apt/keyrings/kubernetes-keyring.key

root@ctrl:~#
echo "deb [signed-by=/etc/apt/keyrings/kubernetes-keyring.key] https://apt.kubernetes.io/ kubernetes-xenial main" | tee /etc/apt/sources.list.d/kubernetes.list

root@ctrl:~#
apt update

root@ctrl:~#
apt -y install kubelet=1.26.6-00 kubeadm=1.26.6-00 kubectl=1.26.6-00

root@ctrl:~#
apt-mark hold kubelet kubeadm kubectl

kubelet set on hold.
kubeadm set on hold.
kubectl set on hold.

root@ctrl:~#
ln -s /opt/cni/bin /usr/lib/cni

関連コンテンツ