centos7环境下部署k8s
程序员文章站
2022-03-07 11:09:06
...
环境配置
系统:CentOS Linux release 7.8.2003
配置:4C4G
k8s-1:192.168.31.200
k8s-2:192.168.31.201
k8s-3:192.168.31.202
k8s-4:192.168.31.203
步骤一:关闭防火墙、selinux、swap、修改host
# 关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
# 关闭selinux
sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
setenforce 0
# 关闭swap
swapoff -a
sed -ri 's/.*swap.*/#&/' /etc/fstab
#修改hosts
cat <<EOF>> /etc/hosts
192.168.31.200 k8s-1
192.168.31.201 k8s-2
192.168.31.202 k8s-3
192.168.31.203 k8s-4
EOF
步骤二:安装docker
wget http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo
yum install docker-ce -y
#docker加速
mkdir /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://p1qim8sk.mirror.aliyuncs.com"]
}
EOF
#启动docker
systemctl daemon-reload
systemctl start docker
systemctl enable docker
步骤三:安装kubernetes
#添加yum源
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
#有索引gpg检查失败的情况, 这时请用 yum install -y --nogpgcheck kubelet kubeadm kubectl 安装
yum install -y kubelet kubeadm kubectl
systemctl enable kubelet && systemctl start kubelet
步骤四:初始化master节点
kubeadm init --image-repository registry.aliyuncs.com/google_containers --apiserver-advertise-address 192.168.31.200 --pod-network-cidr=10.254.254.0/24
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
步骤五:node节点加入集群
kubeadm join 192.168.31.200:6443 --token 9zjgia.whekz6r4atnmceq3 --discovery-token-ca-cert-hash sha256:1cd9a718b27b4aeddcccb3c450f0912a6d66bd89e6cc72e7ab3b77ef9f292b9d
mkdir -p /root/.kube
sudo scp [email protected]:/etc/kubernetes/admin.conf /root/.kube/config
sudo chown $(id -u):$(id -g) /root/.kube/config
步骤六:建立pod网络
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
步骤七:集群验证
[[email protected] ~]#kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8s-1 Ready master 3m1s v1.19.1
k8s-2 Ready <none> 2m32s v1.19.1
k8s-3 Ready <none> 103s v1.19.1
k8s-4 Ready <none> 102s v1.19.1
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:http://blog.csdn.net/qq_22787879/article/details/108537787
上一篇: Java虚拟机栈jvm栈的作用
推荐阅读
-
win10下ASP.NET Core部署环境搭建步骤
-
ubuntu16.4下用jexus部署ASP.NET Core环境
-
Linux centos7环境下MySQL安装教程
-
win10下ASP.NET Core部署环境搭建步骤
-
ubuntu16.4下用jexus部署ASP.NET Core环境
-
4种Windows系统下Laravel框架的开发环境安装及部署方法详解
-
nuxt项目在windows环境下安装部署
-
Centos7系统下搭建.NET Core2.0+Nginx+Supervisor环境
-
CentOS7服务器环境下vsftpd安装及配置方法
-
在centos7下安装和部署java8和mysql