欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

centos k8s 安装

程序员文章站 2024-03-11 10:01:43
...

更好的识别

vim /etc/hosts

192.168.1.2 test1

192.168.1.2 test2

关闭swap

swapoff -a

  fstab 删除 swap

  vim /etc/fstab

关闭selinux

vim /etc/selinux/config

SELINUX=disable
setenforce = 0

关闭防火墙

systemctl stop firewalld.service

systemctl disable firewalld.service

开启ip转发功能

vim /etc/sysctl.conf

net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
modprobe br_netfilter
sysctl -p

更换k8s源

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

# 将 SELinux 设置为 permissive 模式(相当于将其禁用)
sudo setenforce 0
sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config

sudo yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes

sudo systemctl enable --now kubelet

开机启动

[[email protected] ~]# systemctl enable kubelet



#添加模块
[[email protected] ~]#vim /etc/modules-load.d/containerd.conf

overlay
br_netfilter

[[email protected] ~]# modprobe overlay
[[email protected] ~]# modprobe br-netfilter

加载docer源(可以更换为阿里源)

sudo yum install -y yum-utils

sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo

安装 containerd

[[email protected] ~]# yum -y install containerd.io

[[email protected] ~]# mkdir -p /etc/containerd
[[email protected] ~]# containerd config default | sudo tee /etc/containerd/config.toml
vim /etc/containerd/config.toml

#95 行添加
SystemdCgroup = true
[[email protected] ~]# systemctl daemon-reload
[[email protected] ~]# systemctl restart containerd
[[email protected] ~]# systemctl enable containerd

#初始化
[[email protected] ~]# kubeadm init --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=10.168.1.181 --image-repository=registry.aliyuncs.com/google_containers