openEuler安裝Kubernetes

hard4code發表於2024-06-20

openEuler kubeadm安裝Kubernetes


禁用或關閉服務

firewalld

systemctl stop firewalld
systemctl disable firewalld

selinux

sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config

swap 分割槽

sed -i '/swap/s/\(.*\)/#\1/g' /etc/fstab

設定後需重啟生效

設定核心

ipv4轉發

sed -i 's/net.ipv4.ip_forward=0/net.ipv4.ip_forward=1/g' /etc/sysctl.conf

網橋過濾轉發

cat >/etc/sysctl.d/k8s.conf<<EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
vm.swappiness = 0
EOF

配置模組

cat >/etc/modules-load.d/k8s.conf<<EOF
overlay
br_netfilter
EOF

載入br_netfilter overlay模組

modprobe br_netfilter
modprobe overlay

更新核心配置

sysctl -p
sysctl -p /etc/sysctl.d/k8s.conf 

安裝ipset及ipvsadm

yum -y install ipset ipvsadm

配置ipvsadm模組載入

cat > /etc/sysconfig/modules/ipvs.module <<EOF
modprobe -- ip_vs
modprobe -- ip_vs_sh
modprobe -- ip_vs_rr
modprobe -- ip_vs_wrr
modprobe -- nf_conntrack
EOF

授權、執行、檢查是否載入

chmod 755 /etc/sysconfig/modules/ipvs.module &&  /etc/sysconfig/modules/ipvs.module

檢視對應的模組是否載入成功

lsmod | grep -e ip_vs -e nf_conntrack_ipv4

設定hostname

  • 本機ip 10.211.55.20
  • hostname dev

編輯hosts檔案

sed -i '$s/\(.*\)/\1\n10.211.55.20 dev/' /etc/hosts

設定hostname

hostnamectl hostname dev

安裝軟體源

kubernetes

cat >/etc/yum.repos.d/kubernetes.repo<<EOF
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF

docker-ce

cat >/etc/yum.repos.d/dockerce.repo<<EOF
[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=https://repo.huaweicloud.com/docker-ce/linux/centos/7/$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://repo.huaweicloud.com/docker-ce/linux/centos/gpg

安裝軟體

yum install -y docker-ce containerd.io kubeadm kubectl kubelet

相關文章