centos8 kubernetes k8s v1.22.1 搭配containerd搭建集群
2021/10/23 7:13:07
本文主要是介绍centos8 kubernetes k8s v1.22.1 搭配containerd搭建集群,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
系统环境配置
#关闭防火墙 systemctl stop firewalld systemctl disable firewalld #关闭selinux sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config setenforce 0 #关闭swap swapoff -a sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab #同步服务器时间 timedatectl set-timezone Asia/Shanghai yum install chrony -y systemctl enable chronyd systemctl start chronyd chronyc sources #配置网络转发 cat > /etc/sysctl.d/k8s.conf << EOF net.bridge.bridge-nf-call-ip6tables = 1 net.bridge.bridge-nf-call-iptables = 1 net.ipv4.ip_forward = 1 EOF #加载配置生效 modprobe br_netfilter sysctl -p /etc/sysctl.d/k8s.conf
安装containerd
wget -O /etc/yum.repos.d/docker-ce.repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo yum install containerd -y #创建目录并生成配置文件 mkdir -p /etc/containerd containerd config default > /etc/containerd/config.toml # 替换配置文件,设置阿里云加速仓库,启用systemd管理cgroup sed -i "s#k8s.gcr.io#registry.cn-hangzhou.aliyuncs.com/google_containers#g" /etc/containerd/config.toml sed -i '/containerd.runtimes.runc.options/a\ \ \ \ \ \ \ \ \ \ \ \ SystemdCgroup = true' /etc/containerd/config.toml sed -i "s#https://registry-1.docker.io#https://bncakk5o.mirror.aliyuncs.com#g" /etc/containerd/config.toml #启动containerd systemctl daemon-reload systemctl enable containerd systemctl restart containerd
安装k8s
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=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 yum install -y kubelet-1.22.1 kubeadm-1.22.1 kubectl-1.22.1 #设置运行时 crictl config runtime-endpoint /run/containerd/containerd.sock #设置为开机启动kubelet systemctl daemon-reload systemctl enable kubelet && systemctl restart kubelet #初始化集群 kubeadm init \ --apiserver-advertise-address=192.168.56.108 \ --image-repository registry.aliyuncs.com/google_containers \ --kubernetes-version v1.22.1 \ --service-cidr=10.1.0.0/16 \ --pod-network-cidr=10.50.0.0/16 \ --cri-socket= #初始化完成后会再末尾生成提示,按照下列提示操作,将kubeadm join复制到其他node节点执行即可。 To start using your cluster, you need to run the following as a regular user: mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config Alternatively, if you are the root user, you can run: export KUBECONFIG=/etc/kubernetes/admin.conf You should now deploy a pod network to the cluster. Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at: https://kubernetes.io/docs/concepts/cluster-administration/addons/ Then you can join any number of worker nodes by running the following on each as root: kubeadm join 192.168.56.108:6443 --token v5u33x.o9x2p89x2e5x659n \ --discovery-token-ca-cert-hash sha256:c704c9c42840b0bf27f1c91681cc9dabb4d0e67ba2a0ac557009b9a31961a87b
其他node节点除了不用初始化init,其他配置均一致。
节点加入后,会处于notready状态,是因为没有安装网络插件,这里安装calico,执行下列命令即可
kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml
这篇关于centos8 kubernetes k8s v1.22.1 搭配containerd搭建集群的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-15在Kubernetes (k8s) 中搭建三台 Nginx 服务器怎么实现?-icode9专业技术文章分享
- 2024-11-05基于Kubernetes的自定义AWS云平台搭建指南
- 2024-11-05基于Kubernetes Gateway API的现代流量管理方案
- 2024-11-05在Kubernetes上部署你的第一个应用:Nginx服务器
- 2024-11-05利用拓扑感知路由控制Kubernetes中的流量
- 2024-11-05Kubernetes中的层次命名空间:更灵活的资源管理方案
- 2024-11-055分钟上手 Kubernetes:精简实用的 Kubectl 命令速查宝典!
- 2024-10-30K8s 容器的定向调度与亲和性
- 2024-10-28云原生周刊:K8s未来三大发展方向 丨2024.10.28
- 2024-10-25亚马逊弹性Kubernetes服务(EKS)实战:轻松搭建Kubernetes平台