部署k8s集群-containerd
k8s
1.配置
2.统一配置和安装
1.时间同步
yum install chrony
vim /etc/chrony.conf
server ntp1.aliyun.com iburst
2.防火墙和selinx
systemctl stop firewalld iptables
systemctl disable firewalld iptables
3.禁用swap分区
4.升级操作系统内核
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.orgyum -y install https://www.elrepo.org/elrepo-release-7.0-4.el7.elrepo.noarch.rpmyum --enablerepo="elrepo-kernel" -y install kernel-ml.x86_64grub2-set-default 0grub2-mkconfig -o /boot/grub2/grub.cfgrebootuname -r //验证
vim /etc/sysctl.d/kubernetes.conf
net.bridge.bridge-nf-call-ip6tables = 1net.bridge.bridge-nf-call-iptables = 1net.ipv4.ip_forward = 1vm.swappiness=0
sysctl -p /etc/sysctl.d/kubernetes.confmodprobe br_netfilter
lsmod | grep br_netfilter //查看是否成功
yum install ipset ipvsadm -y
vim /etc/sysconfig/modules/ipvs.modules
#!/bin/bashmodprobe -- ip_vsmodprobe -- ip_vs_rrmodprobe -- ip_vs_wrrmodprobe -- ip_vs_shmodprobe -- nf_conntrack
5.k8s基本环境
[kubernetes]name=Kubernetesbaseurl=http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64enabled=1gpgcheck=0repo_gpgcheck=0gpgkey=http://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpghttp://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
修改文件
2.集群创建-containerd
安装必要的一些系统工具yum install -y yum-utils device-mapper-persistent-data lvm2添加软件源信息yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repoyum install containerd -y
初始化默认配置containerd config default | tee /etc/containerd/config.toml修改containerd配置更改cgroupsed -i "s#SystemdCgroup\ \=\ false#SystemdCgroup\ \=\ true#g" /etc/containerd/config.toml修改镜像源sed -i "s#k8s.gcr.io#registry.aliyuncs.com/google_containers#g" /etc/containerd/config.toml配置crictlcat <<EOF | tee /etc/crictl.yamlruntime-endpoint: unix:///run/containerd/containerd.sockimage-endpoint: unix:///run/containerd/containerd.socktimeout: 10debug: falseEOFsystemctl daemon-reloadsystemctl restart containerdsystemctl enable containerd
拉取镜像
kubeadm config images pull --config kubeadm.yml
kubeadm init --config=kubeadm.yml --upload-certs --v=6
也可以使用命令行的方式进行修改
kubeadm init --apiserver-advertise-address=192.168.40.132 --apiserver-bind-port=6443 --cri-socket="unix:///var/run/containerd/containerd.sock" --image-repository registry.aliyuncs.com/google_containers --kubernetes-version=1.24.2 --pod-network-cidr=10.244.0.0/16 --service-cidr=10.96.0.0/12
效果也是一样的
2.添加woker节点
初始化完成会弹出以下提示,箭头处是直接在node1和node2上执行
圈起来的地方是在主机执行
kubectl get nodes //查看主机
3.安装网络插件
wget http://down.i4t.com/k8s1.24/kube-flannel.yml
修改为本地的网卡名字
kubectl apply -f kube-flannel.yml
更多推荐
所有评论(0)