docker集群
1、安装好4台docker机器(1c2g)
docker-maneger:192.168.80.1
docker-2:192.168.80.2
docker-3:192.168.80.3
docker-4:192.168.80.4
LB-1:ens33:192.168.0.207 ens37:192.168.80.208
2、开启路由功能
$ vim snat.sh
iptables -F
iptables -t nat -F
echo 1 >/proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -s 192.168.80.0/24 -o ens33 -j SNAT --to-source 192.168.0.207
[root@LB-1 ~]# bash snat.sh
[root@LB-1 ~]# iptables -L -t nat -vn
Chain PREROUTING (policy ACCEPT 1 packets, 147 bytes)
pkts bytes target prot opt in out source destination
Chain INPUT (policy ACCEPT 1 packets, 147 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 1 packets, 108 bytes)
pkts bytes target prot opt in out source destination
Chain POSTROUTING (policy ACCEPT 1 packets, 108 bytes)
pkts bytes target prot opt in out source destination
0 0 SNAT all -- * ens33 192.168.80.0/24 0.0.0.0/0 to:192.168.0.207
关闭防火墙、selinux
systemctl stop firewalld
systemctl disable firewalld
sed -i's/=enforcing/=disabled/'
3、在管理节点docker机器上配置swarm
docker swarm init --advertise-addr 192.168.80.1
在工作节点上加入
docker swarm join \
--token SWMTKN-1-4crsq2chuxhtd4a1bb0eo0bh1gpvgjchgx6141zhe7xe0oh8of-0nwyw4o5l3rimiv6c3jsd2yl4 \
192.168.80.1:2377
4、获取centos7的镜像
docker pull docker.io/sglim2/centos7
5、在manager节点上配置Dockerfile,自制nginx镜像
FROM docker.io/sglim2/centos7
MAINTAINER Ekko
ENV company dtstack
WORKDIR /
COPY nginx-1.18.0.tar.gz /
RUN yum install -y zlib zlib-devel openssl-devel pcre pcre-devel gcc gcc-c++ autoconf automake make \
&& tar xf nginx-1.18.0.tar.gz \
&& cd nginx-1.18.0 \
&& ./configure --prefix=/usr/local/nginx --