赞
踩
docker版本:20.10.25
k8s版本(kubeadm,kubelet和kubectl):1.20.10-0
- # 禁用 SELinux
- sudo setenforce 0
- sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
-
- # 关闭防火墙
- sudo systemctl stop firewalld
- sudo systemctl disable firewalld
-
- # 关闭 swap
- sudo swapoff -a
- sudo sed -i '/swap/d' /etc/fstab
角色 | IP |
---|---|
master | 192.168.11.139 |
node1 | 192.168.11.140 |
node2 | 192.168.11.141 |
- 每台机器都要添加
- $ vi /etc/hosts
- 192.168.11.139 master
- 192.168.11.140 node1
- 192.168.11.141 node2
安装的版本20.10.25-1.amzn2023.0.1
- $ sudo yum install -y docker-20.10.25-1.amzn2023.0.1
-
- 启动docker
- $ systemctl start docker
1) 添加 Kubernetes 仓库
- $ vi /etc/yum.repos.d/kubernetes.repo
-
- [kubernetes]
- name=Kubernetes
- baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
- enabled=1
- gpgcheck=1
- repo_gpgcheck=1
- gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
2) 安装 kubeadm, kubelet, 和 kubectl,三台机器都要安装
$ sudo yum install -y kubelet-1.20.10-0 kubeadm-1.20.10-0 kubectl-1.20.10-0
3) 初始化master节点
$ sudo kubeadm init --pod-network-cidr=10.244.0.0/16
4) 安装成功
5) 设置kubectl配置文件
- mkdir -p $HOME/.kube
-
- sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
-
- sudo chown $(id -u):$(id -g) $HOME/.kube/config
6) 安装 Pod 网络插件
$ sudo kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
7) 加入node工作节点
在node1和node2运行
- 从主节点复制 kubeadm join 命令
- $ kubeadm join 192.168.11.139:6443 --token 8u9xi5.eaffhbpk6yrsr52f \
- --discovery-token-ca-cert-hash sha256:883c0637ffc0825b79f6fb40c1c9473775b564b3532f5f3a64332cdxxxxx
- master节点查看
- $ kubectl get nodes
- NAME STATUS ROLES AGE VERSION
- master Ready control-plane,master 118m v1.20.10
- node1 Ready <none> 69m v1.20.10
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。