kubernetes1.18.0 安装教程(centos7)
docker18.0版本k8s 1.18.0版本centos7安装docker(每个节点)官网步骤:https://docs.docker.com/engine/install/centos/卸载旧版本sudo yum remove docker \docker-client \docker-client-latest \docker-common \
·
docker18.0版本
k8s 1.18.0版本
centos7
1 安装docker(每个节点)
官网步骤:https://docs.docker.com/engine/install/centos/
卸载旧版本
yum -y remove docker-*
yum -y remove containerd*
rm -rf /var/lib/docker
yum list installed |grep docker
rpm -qa |grep docker
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
设置yum 源
sudo yum install -y yum-utils
sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
安装docker engine 18.0
sudo yum install docker-ce-20.10.14 docker-ce-cli-20.10.14 containerd.io docker-compose-plugin
启动docker
sudo systemctl start docker
sudo systemctl enable docker
2 环境准备(每个节点)
关闭防火墙
systemctl stop firewalld && systemctl disable firewalld
sed -i 's/enforcing/disabled/' /etc/selinux/config && setenforce 0
关闭swap
swapoff -a
sed -ri 's/.*swap.*/#&/' /etc/fstab
设置主机名
hostnamectl set-hostname master.local
hostnamectl set-hostname node01.local
hostnamectl set-hostname node02.local
修改hosts文件
192.168.1.300 master.local
192.168.1.301 node01.local
192.168.1.302 node02.local
修改内核参数:
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
sysctl --system
3 安装kubeadm/kubelet/kubectl(每个节点)
设置yum源
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
安装kubeadm/kubelet/kubectl
yum install -y kubelet-1.18.8 kubeadm-1.18.8 kubectl-1.18.8
systemctl enable kubelet
4 初始化主节点(主节点)
kubeadm init \
--kubernetes-version 1.18.8 \
--apiserver-advertise-address=0.0.0.0 \
--service-cidr=10.96.0.0/16 \
--pod-network-cidr=10.244.0.0/16 \
--image-repository registry.aliyuncs.com/google_containers
mkdir -p $HOME/.kube
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
chown $(id -u):$(id -g) $HOME/.kube/config
5 node加入主节点(node节点)
kubeadm join 192.168.1.200:6443 --token 1quyaw.xa7yel3xla129kfw \ --discovery-token-ca-cert-hash sha256:470410e1180b119ebe8ee3ae2842e7a4a852e590896306ec0dab26b168d99197
6 安装网络插件(主节点)
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
7 验证
kubectl get nodes
kubectl get pods -n kube-system -o wide
kubectl create deployment demoapp --image="ikubernetes/demoapp:v1.0"
更多推荐
已为社区贡献1条内容
所有评论(0)