K8S 1.22.1集群快速搭建

  • 硬件环境准备

腾讯云购买 CVM 3台【集群最小规模】

https://buy.cloud.tencent.com/cvm?tab=custom&step=1&devPayMode=monthly&regionId=33
CVM1:竞价实例、南京、南京一区、标准型S5\2C 4G\0.09元/小时;带宽0.80元/GB
CVM2、3;除带宽外,其他一致

操作系统CentOS x64 8.2镜像

新建安全组「打开所有端口」、并关联所有主机

CVM1 119.*.*.* 10.206.0.2 VM-0-2-centos node2 【master】
CVM3 119.*.*.* 10.206.0.3 VM-0-3-centos node3 【node3】
CVM16 175.*.*.* 10.206.0.16 node16【node16】

  • 主机环境准备

➜  ~ ssh root@119.*.*.*

设置主机名

[root@VM-0-2-centos harbor]# sudo hostnamectl set-hostname node2
[root@VM-0-3-centos harbor]# sudo hostnamectl set-hostname node3
[root@VM-0-16-centos harbor]# sudo hostnamectl set-hostname node16

免密登录
[root@node2 harbor]# ssh-keygen -t rsa
#Your identification has been saved in /root/.ssh/id_rsa.
#Your public key has been saved in /root/.ssh/id_rsa.pub.

[root@node2 harbor]# ssh-copy-id root@node3
	#yes
[root@node2 harbor]# ssh-copy-id root@node16
	#yes

[root@node2 harbor]# ssh node3
[root@node2 harbor]# ssh node16

​​​​​​​​​

  • ​​​​​​​docker+docker-compose​​[所有节点]

[root@VM-0-2-centos ~]# uname -a
Linux VM-0-2-centos 4.18.0-305.3.1.el8.x86_64 #1 SMP Tue Jun 1 16:14:33 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
[root@VM-0-2-centos ~]# cat /etc/redhat-release
CentOS Linux release 8.4.2105

[root@VM-0-2-centos ~]# date
2021年 09月 03日 星期五 13:25:42 CST

yum update -y
rpm -qa | grep docker
yum remove docker docker-common docker-selinux docker-engine
yum install -y yum-utils device-mapper-persistent-data lvm2

[root@VM-0-2-centos ~]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
添加仓库自:https://download.docker.com/linux/centos/docker-ce.repo
[root@VM-0-2-centos ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
添加仓库自:http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum clean all
yum makecache
yum list docker-ce --showduplicates | sort -r

yum -y install docker-ce-20.10.8
sudo systemctl start  docker
[root@VM-0-2-centos ~]# sudo systemctl enable docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.

[root@VM-0-2-centos ~]# docker version
[root@VM-0-2-centos ~]# docker info
[root@VM-0-2-centos ~]# docker -h


cat /usr/lib/systemd/system/docker.service
[root@VM-0-2-centos ~]# touch /etc/docker/daemon.json
[root@VM-0-2-centos ~]# vim /etc/docker/daemon.json

[root@VM-0-2-centos ~]# sudo systemctl daemon-reload
[root@VM-0-2-centos ~]# sudo systemctl start docker.service
[root@VM-0-2-centos ~]# sudo systemctl status docker -l

[root@VM-0-2-centos ~]# docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
[root@VM-0-2-centos ~]# docker ps -a
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES


#http://get.daocloud.io/#install-docker
[root@VM-0-2-centos ~]# curl -L https://get.daocloud.io/docker/compose/releases/download/1.29.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   423  100   423    0     0    478      0 --:--:-- --:--:-- --:--:--   477
100 12.1M  100 12.1M    0     0  9059k      0  0:00:01  0:00:01 --:--:-- 56.8M

[root@VM-0-2-centos ~]# chmod +x /usr/local/bin/docker-compose

[root@VM-0-2-centos ~]# docker-compose --version
docker-compose version 1.29.2, build 5becea4c

  •  ​​​​​​​kubelet+kubeadm+kubectl​​​源​​[所有节点]

[root@node2 ~]# 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
> gpgke
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值