设备说明 | 主机名 | 接口 | IP地址 |
---|---|---|---|
虚拟机1 | Master | Eth0 | 10.0.0.10/24 |
虚拟机2 | Node1 | Eth0 | 10.0.0.20/24 |
虚拟机3 | Harbor | Eth0 | 10.0.0.30/24 |
Master:
Node1:
Harbor:
hostnamectl set-hostname 主机名
sed -ri 's/.*swap.*/#&/' /etc/fstab
重启虚拟机,再连接
systemctl stop firewalld.service
systemctl disable firewalld.service
sed -i "s/^SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
vi /etc/hosts
添加如下内容:
10.0.0.10 master
10.0.0.20 node1
10.0.0.30 harbor
yum -y install ntp
vi /etc/ntp.conf
修改内容如下:
删除原有的server 0/1/2/3/4,并添加如下内容
server ntp1.aliyun.com prefer
server ntp2.aliyun.com
timedatectl set-timezone Asia/Shanghai
ntpdate ntp1.aliyun.com
systemctl restart ntpd
systemctl enable ntpd
yum -y install ntpdate
ntpdate master
指定master为时间同步服务器,其余两台同步master节点时间
ssh-keygen
ssh-copy-id master
ssh-copy-id node1
ssh-copy-id harbor
yum install -y yum-utils
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install -y docker-ce docker-ce-cli containerd.io
systemctl start docker
systemctl enable docker
docker run hello-world
yum install wget -y
wget https://ghproxy.com/https://github.com/goharbor/harbor/releases/download/v2.6.1/harbor-offline-installer-v2.6.1.tgz
tar -zxvf harbor-offline-installer-v2.6.1.tgz -C /usr/local/
cd /usr/local/harbor/
cp harbor.yml.tmpl harbor.yml
vi harbor.yml
修改以下内容:
hostname = 10.0.0.30
port: 8081
注释掉以下内容:
# https related config
# https:
# # https port for harbor, default is 443
# port: 443
# # The path of cert and key files for nginx
# certificate: /your/certificate/path
# private_key: /your/private/key/path
./install.sh
根据在harbor.yml文件中配置的端口与IP地址(或域名)进行访问
修改daemon.json文件(所有节点都要执行)
vi /etc/docker/daemon.json
添加如下内容:
{
"registry-mirrors": ["https://cyowm7vy.mirror.aliyuncs.com"]
}{"insecure-registries":["10.0.0.30:80"]}
重新加载配置并重启docker服务
systemctl daemon-reload
systemctl restart docker
vi /etc/docker/daemon.json
添加如下内容:
{"exec-opts": ["native.cgroupdriver=systemd"]
}
重启docker服务
systemctl daemon-reload
systemctl restart docker
yum install docker-compose -y
docker-compose version
vi /etc/yum.repos.d/kubernetes.repo
内容如下:
[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
yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
systemctl enable --now kubelet
感谢大家,点赞,收藏,关注,评论!