安装flanneld
[root@hdss7
-22 ~]
[root@hdss7
-22 src
]
[root@hdss7
-21 src
]
总用量
452336
-rw
-r
--r
-- 1 root root
9850227 6月
22 21:16 etcd
-v3
.1.20-linux
-amd64
.tar
.gz
-rw
-r
--r
-- 1 root root
9565743 6月
22 20:24 flannel
-v0
.11.0-linux
-amd64
.tar
.gz
-rw
-r
--r
-- 1 root root
443770238 6月
22 21:11 kubernetes
-server
-linux
-amd64
-v1
.15.2.tar
.gz
[root@hdss7
-21 src
]
[root@hdss7
-21 src
]
[root@hdss7
-21 src
]
[root@hdss7
-21 flannel
-v0
.11.0]
总用量
34436
-rwxr
-xr
-x
1 root root
35249016 1月
29 2019 flanneld
-rwxr
-xr
-x
1 root root
2139 10月
23 2018 mk
-docker
-opts
.sh
-rw
-r
--r
-- 1 root root
4300 10月
23 2018 README
.md
[root@hdss7
-21 flannel
-v0
.11.0]
[root@hdss7
-22 opt
]
[root@hdss7
-22 flannel
]
总用量
34436
-rwxr
-xr
-x
1 root root
35249016 1月
29 2019 flanneld
-rwxr
-xr
-x
1 root root
2139 10月
23 2018 mk
-docker
-opts
.sh
-rw
-r
--r
-- 1 root root
4300 10月
23 2018 README
.md
复制证书(完成与etcd的通信)
[root@hdss7
-21 flannel
]
[root@hdss7
-21 flannel
]
[root@hdss7
-21 cert
]
root@
10.4.7.200's password
:
ca
.pem
100% 1346 2.0MB
/s
00:00
[root@hdss7
-21 cert
]
root@
10.4.7.200's password
:
client
.pem
100% 1371 1.7MB
/s
00:00
[root@hdss7
-21 cert
]
root@
10.4.7.200's password
:
client
-key
.pem
100% 1675 1.7MB
/s
00:00
[root@hdss7
-21 cert
]
总用量
12
-rw
-r
--r
-- 1 root root
1346 7月
2 11:26 ca
.pem
-rw
------- 1 root root
1675 7月
2 11:27 client
-key
.pem
-rw
-r
--r
-- 1 root root
1371 7月
2 11:26 client
.pem
创建配置文件
[root@hdss7
-22 cert
]
[root@hdss7
-21 flannel
]
[root@hdss7
-21 flannel
]
FLANNEL_NETWORK
=172.7.0.0/16
FLANNEL_SUBNET
=172.7.21.1/24
FLANNEL_MTU
=1500
FLANNEL_IPMASQ
=false
[root@hdss7
-21 flannel
]
[root@hdss7
-21 flannel
]
./flanneld \
--public
-ip
=10.4.7.21 \
--etcd
-endpoints
=https
://10.4.7.12:2379,https
://10.4.7.21:2379,https
://10.4.7.22:2379 \
--etcd
-keyfile
=./cert
/client
-key
.pem \
--etcd
-certfile
=./cert
/client
.pem \
--etcd
-cafile
=./cert
/ca
.pem \
--iface
=ens33 \
--subnet
-file=./subnet
.env \
--healthz
-port
=2401
[root@hdss7
-21 flannel
]
[root@hdss7
-21 flannel
]
在etcd中增加网络配置信息
[root@hdss7
-21 flannel
]
[root@hdss7
-21 etcd
]
988139385f78284: name
=etcd
-server
-7-22 peerURLs
=https
://10.4.7.22:2380 clientURLs
=http
://127.0.0.1:2379,https
://10.4.7.22:2379 isLeader
=false
5a0ef2a004fc4349: name
=etcd
-server
-7-21 peerURLs
=https
://10.4.7.21:2380 clientURLs
=http
://127.0.0.1:2379,https
://10.4.7.21:2379 isLeader
=false
f4a0cb0a765574a8
: name
=etcd
-server
-7-12 peerURLs
=https
://10.4.7.12:2380 clientURLs
=http
://127.0.0.1:2379,https
://10.4.7.12:2379 isLeader
=true
[root@hdss7
-21 etcd
]
{"Network": "172.7.0.0/16", "Backend": {"Type": "host-gw"}}
[root@hdss7
-21 etcd
]
{"Network": "172.7.0.0/16", "Backend": {"Type": "host-gw"}}
创建启动脚本
编辑supervisor启动脚本:
[program:flanneld-7-21] 部分记得修改
[root@hdss7-22 etcd]
[program:flanneld-7-21]
command=
/opt
/flannel
/flanneld
.sh
; the program
(relative uses PATH
, can take args
)
numprocs=1
; number of processes copies to
start (def 1
)
directory=
/opt
/flannel
; directory to cwd to before exec
(def no cwd
)
autostart=true
; start at supervisord
start (default: true
)
autorestart=true
; retstart at unexpected quit
(default: true
)
startsecs=30
; number of secs prog must stay running
(def
. 1
)
startretries=3
; max
exitcodes=0
,2
; 'expected' exit codes
for process (default 0
,2
)
stopsignal=QUIT
; signal used to
kill process (default TERM
)
stopwaitsecs=10
; max num secs to wait b4 SIGKILL
(default 10
)
user=root
; setuid to this UNIX account to run the program
redirect_stderr=true
; redirect proc stderr to stdout
(default false
)
stdout_logfile=
/data/logs
/flanneld
/flanneld
.stdout
.log
; stderr log path
, NONE
for none
; default AUTO
stdout_logfile_maxbytes=64MB
; max
stdout_logfile_backups=4
;
stdout_capture_maxbytes=1MB
; number of bytes in
'capturemode' (default 0
)
stdout_events_enabled=false
; emit events on stdout writes
(default false
)
[root@hdss7-21 etcd]
[root@hdss7-21 etcd]
[root@hdss7-21 etcd]
etcd
-server
-7
-21 RUNNING pid 12272
, uptime 5 days
, 23:36:17
flanneld
-7
-21 STARTING
kube
-apiserver
-7
-21 RUNNING pid 13277
, uptime 5 days
, 0:09:58
kube
-controller
-manager
-7
-21 RUNNING pid 64267
, uptime 1 day
, 1:32:05
kube
-kubelet
-7
-21 RUNNING pid 17290
, uptime 3 days
, 17:30:48
kube
-proxy
-7
-21 RUNNING pid 55520
, uptime 3 days
, 14:16:13
kube
-scheduler
-7
-21 RUNNING pid 64261
, uptime 1 day
, 1:32:05
[root@hdss7-22 flannel]
验证不同宿主机中的容器是否能够通信
[root@hdss7-21 etcd
]
PING 172.7.21.2
(172.7.21.2
) 56
(84
) bytes of data.
64 bytes from 172.7.21.2: icmp_seq
=1 ttl
=64 time
=0.092 ms
64 bytes from 172.7.21.2: icmp_seq
=2 ttl
=64 time
=0.098 ms
64 bytes from 172.7.21.2: icmp_seq
=3 ttl
=64 time
=0.043 ms
64 bytes from 172.7.21.2: icmp_seq
=4 ttl
=64 time
=0.094 ms
[root@hdss7-21 etcd
]
<!DOCTYPE html
>
<html
>
<head
>
<title
>Welcome to nginx
!</title
>
<style
>
body
{
width: 35em
;
margin: 0 auto
;
font-family: Tahoma, Verdana, Arial, sans-serif
;
}
</style
>
</head
>
<body
>
<h1
>Welcome to nginx
!</h1
>
<p
>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.
</p
>
<p
>For online documentation and support please refer to
<a href
="http://nginx.org/">nginx.org
</a
>.
<br/
>
Commercial support is available at
<a href
="http://nginx.com/">nginx.com
</a
>.
</p
>
<p
><em
>Thank you
for using nginx.
</em
></p
>
</body
>
</html
>
[root@hdss7-22 flannel
]
PING 172.7.21.1
(172.7.21.1
) 56
(84
) bytes of data.
64 bytes from 172.7.21.1: icmp_seq
=1 ttl
=64 time
=0.200 ms
64 bytes from 172.7.21.1: icmp_seq
=2 ttl
=64 time
=0.624 ms
64 bytes from 172.7.21.1: icmp_seq
=3 ttl
=64 time
=0.483 ms
64 bytes from 172.7.21.1: icmp_seq
=4 ttl
=64 time
=0.669 ms
网络连接ping不通的问题处理
[root@hdss7-22 flannel
]
0
[root@hdss7-22 flannel
]
net.ipv4.ip_forward
= 1
[root@hdss7-22 flannel
]