# 本篇主要记录在 Centos7 用 kubeadm 安装 kuberneters 单 master 集群的过程
# 环境
# 关闭 Swap
h | echo vm.swappiness=0 >> /etc/sysctl.conf |
| reboot |
如何去除 swap 分区
14.04 - Problem removing swap partition - Ask Ubuntu
h | lvremove /dev/mapper/centos-swap |
| lvextend centos/root /dev/vda2 |
| xfs_growfs /dev/mapper/centos-root |
| df -h |
特别注意,需要修改 grub 配置,防止重启后找不到 swap,以致于无法登陆服务器
h | |
| vim /etc/default/grub |
| vim /boot/grub2/grub.cfg |
| |
| |
| vim /etc/default/grub |
| |
| GRUB_CMDLINE_LINE 去掉rd.lvm.lv=centos/swap |
| |
| mount /dev/vda1 /tmp2 |
| cd tmp2/grub2/ |
| |
| |
Centos 进入 dracut 模式,报 /dev/centos/swap does not exist, 如何恢复_yanwei2020 的博客 - CSDN 博客_dracut 模式
# 安装 k8s
设置 yum 代理
h | /etc/yum.conf |
| proxy = http://example.com |
添加仓库
h | cat <<EOF | sudo tee /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 |
| exclude=kubelet kubeadm kubectl |
| EOF |
安装 kubeadm | Kubernetes
# 修改 kubelet 的根目录
h | vi /usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf |
| |
# 安装命令
h | sudo kubeadm init --pod-network-cidr=10.244.0.0/16 | grep token >> $HOME/temp/token.txt |
| --cri-socket unix:///var/run/cri-dockerd.sock |
| |
| kubeadm join 192.168.101.8:6443 --token 5d5o9m.czusq0ywj2i03zdv \ |
| --discovery-token-ca-cert-hash sha256:b0cd904c65cb68c5a85f0abc8fe4c929ebea04571e2a4606d8b5feebe8ae4e30 \ |
| --cri-socket unix:///var/run/cri-dockerd.sock |
Centos7k8sScript/k8s-master.sh at master · minskiter/Centos7k8sScript (github.com)