æéãæ¢ãŸãããããŒãžã§ã³ããããŒãžã§ã³ãžã®æãããŠããDockerã«ã¯æ°ããæ©èœããããŸãã æ°ããããŒãžã§ã³ã®Changelogãèªããšãããã«ããããšãããããçŸåšãããåªããæ©èœãå®è¡ã§ããããšãããããŸãã
ç§ã®å Žåã¯ããã§ããã ã·ã³ãã«ã«ä¿ã€ãšããååã«åŸã£ãŠãç§ãããªããã°ãªããªãå€ãã®ã¿ã¹ã¯ãããŠããããšã«æ³šæãããã ã€ãŸããã»ãšãã©ã®å Žåãç°¡åãªããŒã«ãšæé ã䜿çšããŠåé¡ã解決ã§ããå Žåããã®æ¹æ³ãéžæããŸãã åçŽãŸãã¯è€éãªã¹ããããŸãã¯ããŒã«ã¯äž»èŠ³çãªè©äŸ¡ã§ããããšãç解ããŠããŸããã ããŒã ã§äœæ¥ããŠããå ŽåãããŒã«ãéžæããéã«ãããã®åºæºãé©åãªå ŽåããããŸãã
- ãã®ããŒã«ã¯ã€ã³ãã©ã¹ãã©ã¯ãã£ã§äœ¿çšãããŠããŸããïŒ
- æ°ãããã®ãå¿ èŠãªå Žåããã§ã«ãããã®ã䜿çšããããšã¯å¯èœã§ããïŒ
- ãµãŒãã¹ã®ãµãŒãã¹ïŒæŽæ°ãåèµ·åïŒã¯ä»ã®ãµãŒãã¹ãšã©ããããç°ãªããŸããïŒ
- <...>
ãã®èšäºã§ã¯ãDockerã®ãããã¯ãŒãã³ã°ã®åŽé¢ã«ã€ããŠèª¬æããŸãã ãã¹ãŠãé çªã«èª¬æããŸãããä»åã¯ããã¹ããããã¯ãŒã¯ã䜿çšããããããæ¹æ³ã§NATã䜿çšããªãããšã¯èšããŸããã
Dockerããããã¯ãŒã¯ã§ã©ã®ããã«æ©èœãããã«ã€ããŠã¯ã ãã¡ããã芧ãã ãã ã äž»ãªãã€ã³ãã匷調ããŸãã
- ããã©ã«ãã®ããªããžãããã¯ãŒã¯ã
- ãã¹ããããã¯ãŒã¯;
- ãŠãŒã¶ãŒå®çŸ©ãããã¯ãŒã¯ã
ç§ã®å ¬éã¹ããŒãã®äžéšã§åã«è¿°ã¹ãããã«ãã³ã³ããã®ãããã¯ãŒã¯ããã©ãŒãã³ã¹ãæ倧ã«ããå¿ èŠããããŸãã æ¬çªã«ã€ããŠè©±ãå Žåãã³ã³ããã«ã¯NATã䜿çšããŸããã
é·ãéïŒãããŠãªãä»æ¥ãŸã§ãããé ãã®ãïŒã-- net = hostãã©ã¡ãŒã¿ãŒã䜿çšããŠã³ã³ãããŒãèµ·åããããã«ãã£ãŠã³ã³ãããŒå ã§ããã€ãã£ããã®ethãååŸããŸãã ã¯ãããã®å Žåã1ã€ã®å©ç¹-åé¢-ç§ãã¡ã¯ãã¡ããè² ããŸã...ããããç§ãã¡ã®ç¹å®ã®å Žåã®è³åŠäž¡è«ãèŠãŠãç§ãã¡ã¯æå³çã«ãã®æ±ºå®ã«æ¥ãŸããããªããªã åããã¹ãå ã§å®è¡äžã®ã¢ããªã±ãŒã·ã§ã³éã§ãããã¯ãŒã¯ãåé¢ããã¿ã¹ã¯ã¯èããããŸããã§ããã Dockerã¢ããªã±ãŒã·ã§ã³ã®ç¹å®ã®å Žæ-Badooã«ã€ããŠæžããŠããããšãæãåºããŠãã ããã
ãµãŒãã¹ã«ã€ããŠäœãç¥ã£ãŠããŸããïŒ
- ãµãŒããŒã«ãµãŒãã¹ãé 眮ãããããããããŸãã
- åãµãŒãã¹ãšãã®ã¿ã€ãïŒãŸãã¯å€æ°ããå Žåã¯ã¿ã€ãïŒã®ããŒããããããããŸãã
- ããŒãã¯äžæã§ãªããã°ãªããªããšããåæããããŸãã
äžèšã«åºã¥ããŠã以äžãä¿èšŒããŸãã
- --net = hostã䜿çšããŠåããã·ã³äžã§è€æ°ã®ãµãŒãã¹ãå®è¡ãããšãããŒãã®äº€å·®ã¯çºçããŸããããã¹ãŠãéå§ãããŠåäœããŸãã
- 1ã€ã®ethã€ã³ã¿ãŒãã§ãŒã¹ã ãã§ã¯äžååãªå Žåã¯ãå¥ã®ethã€ã³ã¿ãŒãã§ãŒã¹ãç©ççã«æ¥ç¶ããããšãã°DNSãä»ããŠãã€ã³ã¿ãŒãã§ãŒã¹éã§è² è·ãåæ£ããŸãã
ãã¹ãŠãé 調ã§ãããªãç§ã¯äœããå€æŽããªããã°ãªããªãã£ãã®ã§ããïŒ
ããã¯å€æ¹ã§ãäœãããããšã¯ãããŸããã§ãã...以åã¯ããµãŒãã¹ãã³ã³ããã«ç§»ãç¶ãããšèšãããŠããŸããã ãã®ãããªã·ããªãªã«åŸãå Žåãéåžžã¯èµ·ãããŸãããæãé£ãããã®ã¯åŸã§äœ¿çšããŸãã ããã®çç±ã¯ãããããããããããŸããïŒ
- ãµãŒãã¹ã¯éèŠã§ãã
- ã³ã³ããã«å¯ŸããŠæãéæã§é«éãªãµãŒãã¹ãæäŸããããã®ååãªçµéšã®æ¬ åŠ;
- ãããªãã®å¥œã¿ã«äœãä»ã®ãã®ãè¿œå ãããããšãã§ããŸãã
ããŠã ãã®ãããªãµãŒãã¹ã1ã€ãããŸãïŒçŸåšããããŸãïŒã ä»æ¥ãŸã§ã¯åé¡ãªãåäœããŸãããããã€ãã®æ¬ ç¹ããããŸãã
- 1ã€ã®ã³ã¢ã§åäœããŸãïŒã¯ããèµ·ãããŸãïŒã
- æåã®ã®ã£ãããåããã«ã¯ãããã€ãã®ãµãŒãã¹ã€ã³ã¹ã¿ã³ã¹ãå®è¡ãã taskset /-cpuset-cpusã䜿çšã§ããããšã«æ³šæããŠãã ããã
- ãµãŒãã¹ã¯ã倧éã«ããããã¯ãŒã¯ã䜿çšããçºä¿¡æ¥ç¶ã«ã¯å€æ°ã®ããŒããå¿ èŠã§ãã
ããã¯ããµãŒãã¹ãéå§ããåã®æ¹æ³ã§ãã
- ãµãŒãã¹ã®åŒãäžããäºå®ãããŠãããã·ã³ã§ã¯ãè¿œå ã®IPã¢ãã¬ã¹ïŒãŸãã¯è€æ°ïŒãè¿œå ããå¿ èŠããããŸãã-ip a add ïŒããã§ããã®ã¢ãããŒãã®å€ãã®æ¬ ç¹ãããã«ææã§ããŸãïŒã
- äžèšã«ã€ããŠã¯ãããšãã°ãç°ãªããã·ã³ã§2ã€ã®åäžã®ã¢ãã¬ã¹ãååŸããªãããšãå¿ããªãã§ãã ããã
- ããŒã¢ã³ã®æ§æã§ã¯ãè¿é£ãŸãã¯ãã¹ãã·ã¹ãã ã®ãã¹ãŠã®ããŒãããé£ã¹ãªããããã«ãåäœããã¢ãã¬ã¹ãæå®ãã䟡å€ããããŸããã
æ°ããã¡ãœãããçºæããã®ãé¢åãªå Žåãã©ã®ããã«åé¡ã解決ã§ããŸããïŒ
- ãã¹ãŠããã®ãŸãŸã«ããŸãããã³ã³ããã«å ã¿ãŸãã
- åãè¿œå IPã¢ãã¬ã¹ããã¹ãŠdockerhostã«äžããŸãã
- ç¹å®ã®ã¢ãã¬ã¹ã«ã¢ããªã±ãŒã·ã§ã³ãããã€ã³ããããŸãã
ã©ã®ããã«ã¿ã¹ã¯ã«ã¢ãããŒãããããšã«ããŸãããïŒ æåã¯ãã¡ãããããã¯ãã¹ãŠå®éšã®ããã«èŠããŸãããããªããããé ãã®ã-å®éšã§ããã åœæã¯Dockerã§ExperimentalïŒããŒãžã§ã³1.11.2ïŒãšããŒã¯ãããŠããMACVLANãã¯ãããžãŒã¯ãã®ãµãŒãã¹ã«ãŽã£ããã§ããããã«æããŸããããããŒãžã§ã³1.12ã§ã¯ãã§ã«ãã¹ãŠã®æ©èœãã¡ã€ã³æ©èœã§å©çšå¯èœã§ãã
MACVLANã¯åºæ¬çã«ãMACãšVLANã®éçãªäžèŽã«åºã¥ããLinuxã¹ã€ããã§ãã ç¡å·®å¥ã¢ãŒãã§ã¯ãªãããŠããã£ã¹ããã£ã«ã¿ãªã³ã°ã䜿çšããŸãã MACVLANã¯ããã©ã€ããŒããVEPAãããªããžããã¹ã¹ã«ãŒã¢ãŒãã§åäœã§ããŸãã MACVLANã¯ãLinuxã®ãªããŒã¹VLANã§ãã ãã®ãã¯ãããžãŒã«ããã1ã€ã®å®éã®ã€ã³ã¿ãŒãã§ãŒã¹ãååŸããããã«åºã¥ããŠç°ãªãMACã¢ãã¬ã¹ãæã€è€æ°ã®ä»®æ³ã€ã³ã¿ãŒãã§ãŒã¹ãäœæã§ããŸãã
ãŸããIPVLANãã¯ãããžãŒãæè¿ç»å ŽããŸããïŒ https://www.kernel.org/doc/Documentation/networking/ipvlan.txt ïŒã MACVLANãšã®äž»ãªéãã¯ãIPVLANãL3ã¢ãŒãã§åäœã§ããããšã§ãã ãã®èšäºã§ã¯ãMACVLANïŒããªããžã¢ãŒãïŒã®äœ¿çšãæ€èšããŸããçç±ã¯æ¬¡ã®ãšããã§ãã
- ã¢ã¯ãã£ããªãããã¯ãŒã¯æ©åšã®1ã€ã®ãªã³ã¯ãã1ã€ã®MACã¢ãã¬ã¹ã®å¶éã¯ãããŸããã
- ãã¹ãäžã®ã³ã³ããã®æ°ã¯ããã»ã©å€ããªããããMacã®å®¹éãéå°ã«ãªãå¯èœæ§ããããŸãã æéã®çµéãšãšãã«ãç§ãã¡ã®ãã®ç¬éã¯ãã¡ããå€ãããŸãã
- L3ã¯ãã®æ®µéã§ã¯å¿ èŠãããŸããã
MACVLANãšIPVLANã®è©³çŽ°ã«ã€ããŠã¯ã httpïŒ //hicu.be/macvlan-vs-ipvlanãåç §ããŠãã ãã ã
ããã§ã¯ãDockerã§çè«ãšãã®ä»çµã¿ãèªãããšãã§ããŸãïŒ https : //github.com/docker/docker/blob/master/experimental/vlan-networks.md
çè«ã¯çŽ æŽãããã§ãããããã§ããªãŒããŒããããååšããå Žæã§ããããšãããããŸãã ã€ã³ã¿ãŒãããã§ã®MACVLAN垯åå¹ ã®æ¯èŒãã¹ãïŒããšãã°ã httpïŒ //comp.photo777.org/docker-network-performance/ããã³http://delaat.net/rp/2014-2015/p92/reportãåç §ã㊠ãã ãã ã pdf ïŒã ãã§ãªããå®éšã®äžå¯æ¬ ãªéšåã¯ãå®éšå®€æ¡ä»¶ã§ã®ãã¹ãã§ãã äžèšã§èšãã®ã¯è¯ãããšã§ããããæã§è§Šã£ãŠãèªåã§çµè«ãåºãããšã¯èå³æ·±ãå¿ èŠã§ãã
ãããè¡ããïŒ
MACVLANãDockerã§æ©èœãããã©ããã確èªããã«ã¯ãåŸè ã«å®éšçãªãµããŒããå«ããå¿ èŠããããŸãã
ã¢ã»ã³ããªäžã«ãã®æ©èœãå«ãŸããŠããªãå Žåããã°ã§æ¬¡ã®ãšã©ãŒã¡ãã»ãŒãžã確èªã§ããŸãã
# docker network create -d macvlan --subnet=1.1.1.0/24 --gateway=1.1.1.1 -o parent=eth0 cppbig_vlan Error response from daemon: plugin not found
ãããŠãããã»ã¹ãã°ã«ã¯æ¬¡ã®ãã®ããããŸãïŒ
docker[2012]: time="2016-08-04T11:44:44.095241242Z" level=warning msg="Unable to locate plugin: macvlan, retrying in 1s" docker[2012]: time="2016-08-04T11:44:45.095489283Z" level=warning msg="Unable to locate plugin: macvlan, retrying in 2s" docker[2012]: time="2016-08-04T11:44:47.095750785Z" level=warning msg="Unable to locate plugin: macvlan, retrying in 4s" docker[2012]: time="2016-08-04T11:44:51.095970433Z" level=warning msg="Unable to locate plugin: macvlan, retrying in 8s" docker[2012]: time="2016-08-04T11:44:59.096197565Z" level=error msg="Handler for POST /v1.23/networks/create returned error: plugin not found"
ãã®ãããªã¡ãã»ãŒãžã衚瀺ãããå ŽåãDockerã§MACVLANãµããŒããæå¹ã«ãªã£ãŠããªãããšãæå³ããŸãã
ãã¹ãã¯iperfã䜿çšããŠã·ã³ããªãã¯ã§ãã ã åãªãã·ã§ã³ã«ã€ããŠãæåã«1ã€ã®ã¯ã©ã€ã¢ã³ããèµ·åãã次ã«8ã€ã®ã¯ã©ã€ã¢ã³ãã䞊è¡ããŠèµ·åããŸããã 2ã€ã®ãªãã·ã§ã³ããããŸããã
- --net =ãã¹ã ;
- --net = macvlan
ãã¹ãã®è©³çŽ°ã衚瀺ãã
ãµãŒããŒãèµ·åããŸãã
ã¯ã©ã€ã¢ã³ããéå§ããŸãã
ãµãŒããŒäžã§çµæãååŸããŸãã
ã¯ã©ã€ã¢ã³ãã§ïŒ
8ã€ã®ã¯ã©ã€ã¢ã³ãã䞊è¡ããŠèµ·åããŸãã
ãµãŒããŒäžã§çµæãååŸããŸãã
ã¯ã©ã€ã¢ã³ãã§ïŒ
2.ãµãŒããŒã¯MACVLANã®äœ¿çšãéå§ããŸãã
ã¯ã©ã€ã¢ã³ããéå§ããŸãã
ãµãŒããŒäžã§çµæãååŸããŸãã
ã¯ã©ã€ã¢ã³ãã§ïŒ
8ã€ã®ã¯ã©ã€ã¢ã³ãã䞊è¡ããŠèµ·åããŸãã
ãµãŒããŒäžã§çµæãååŸããŸãã
ã¯ã©ã€ã¢ã³ãã§ïŒ
# docker run -it --net=host --name=iperf_w_host_net --entrypoint=/bin/bash dockerio.badoo.com/itops/sle_12_base:latest # iperf3 -s -p 12345 ----------------------------------------------------------- Server listening on 12345 -----------------------------------------------------------
ã¯ã©ã€ã¢ã³ããéå§ããŸãã
# iperf3 -c 1.1.1.2 -p 12345 -t 30
ãµãŒããŒäžã§çµæãååŸããŸãã
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth
[ 5] 0.00-30.04 sec 0.00 Bytes 0.00 bits/sec sender
[ 5] 0.00-30.04 sec 2.45 GBytes 702 Mbits/sec receiver
ã¯ã©ã€ã¢ã³ãã§ïŒ
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-30.00 sec 2.46 GBytes 703 Mbits/sec 0 sender
[ 4] 0.00-30.00 sec 2.45 GBytes 703 Mbits/sec receiver
8ã€ã®ã¯ã©ã€ã¢ã³ãã䞊è¡ããŠèµ·åããŸãã
# iperf3 -c 1.1.1.2 -p 12345 -t 30 -P 8
ãµãŒããŒäžã§çµæãååŸããŸãã
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth
[ 5] 0.00-30.03 sec 0.00 Bytes 0.00 bits/sec sender
[ 5] 0.00-30.03 sec 314 MBytes 87.7 Mbits/sec receiver
[ 7] 0.00-30.03 sec 0.00 Bytes 0.00 bits/sec sender
[ 7] 0.00-30.03 sec 328 MBytes 91.5 Mbits/sec receiver
[ 9] 0.00-30.03 sec 0.00 Bytes 0.00 bits/sec sender
[ 9] 0.00-30.03 sec 305 MBytes 85.2 Mbits/sec receiver
[ 11] 0.00-30.03 sec 0.00 Bytes 0.00 bits/sec sender
[ 11] 0.00-30.03 sec 312 MBytes 87.3 Mbits/sec receiver
[ 13] 0.00-30.03 sec 0.00 Bytes 0.00 bits/sec sender
[ 13] 0.00-30.03 sec 316 MBytes 88.3 Mbits/sec receiver
[ 15] 0.00-30.03 sec 0.00 Bytes 0.00 bits/sec sender
[ 15] 0.00-30.03 sec 310 MBytes 86.7 Mbits/sec receiver
[ 17] 0.00-30.03 sec 0.00 Bytes 0.00 bits/sec sender
[ 17] 0.00-30.03 sec 313 MBytes 87.5 Mbits/sec receiver
[ 19] 0.00-30.03 sec 0.00 Bytes 0.00 bits/sec sender
[ 19] 0.00-30.03 sec 321 MBytes 89.7 Mbits/sec receiver
[SUM] 0.00-30.03 sec 0.00 Bytes 0.00 bits/sec sender
[SUM] 0.00-30.03 sec 2.46 GBytes 704 Mbits/sec receiver
ã¯ã©ã€ã¢ã³ãã§ïŒ
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-30.00 sec 315 MBytes 88.1 Mbits/sec 0 sender
[ 4] 0.00-30.00 sec 314 MBytes 87.8 Mbits/sec receiver
[ 6] 0.00-30.00 sec 330 MBytes 92.3 Mbits/sec 0 sender
[ 6] 0.00-30.00 sec 328 MBytes 91.6 Mbits/sec receiver
[ 8] 0.00-30.00 sec 306 MBytes 85.6 Mbits/sec 0 sender
[ 8] 0.00-30.00 sec 305 MBytes 85.3 Mbits/sec receiver
[ 10] 0.00-30.00 sec 313 MBytes 87.5 Mbits/sec 0 sender
[ 10] 0.00-30.00 sec 312 MBytes 87.4 Mbits/sec receiver
[ 12] 0.00-30.00 sec 317 MBytes 88.8 Mbits/sec 0 sender
[ 12] 0.00-30.00 sec 316 MBytes 88.4 Mbits/sec receiver
[ 14] 0.00-30.00 sec 312 MBytes 87.1 Mbits/sec 0 sender
[ 14] 0.00-30.00 sec 310 MBytes 86.8 Mbits/sec receiver
[ 16] 0.00-30.00 sec 314 MBytes 87.9 Mbits/sec 0 sender
[ 16] 0.00-30.00 sec 313 MBytes 87.6 Mbits/sec receiver
[ 18] 0.00-30.00 sec 322 MBytes 90.2 Mbits/sec 0 sender
[ 18] 0.00-30.00 sec 321 MBytes 89.8 Mbits/sec receiver
[SUM] 0.00-30.00 sec 2.47 GBytes 707 Mbits/sec 0 sender
[SUM] 0.00-30.00 sec 2.46 GBytes 705 Mbits/sec receiver
2.ãµãŒããŒã¯MACVLANã®äœ¿çšãéå§ããŸãã
# docker run -it --net=cppbig_vlan --name=iperf_w_macvlan_net --ip=1.1.1.202 --entrypoint=/bin/bash dockerio.badoo.com/itops/sle_12_base:latest # iperf3 -s -p 12345 ----------------------------------------------------------- Server listening on 12345 -----------------------------------------------------------
ã¯ã©ã€ã¢ã³ããéå§ããŸãã
# iperf3 -c 1.1.1.202 -p 12345 -t 30
ãµãŒããŒäžã§çµæãååŸããŸãã
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth
[ 5] 0.00-30.04 sec 0.00 Bytes 0.00 bits/sec sender
[ 5] 0.00-30.04 sec 2.45 GBytes 701 Mbits/sec receiver
ã¯ã©ã€ã¢ã³ãã§ïŒ
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-30.00 sec 2.46 GBytes 703 Mbits/sec 0 sender
[ 4] 0.00-30.00 sec 2.45 GBytes 702 Mbits/sec receiver
8ã€ã®ã¯ã©ã€ã¢ã³ãã䞊è¡ããŠèµ·åããŸãã
# iperf3 -c 1.1.1.202 -p 12345 -t 30 -P 8
ãµãŒããŒäžã§çµæãååŸããŸãã
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth
[ 5] 0.00-30.03 sec 0.00 Bytes 0.00 bits/sec sender
[ 5] 0.00-30.03 sec 306 MBytes 85.4 Mbits/sec receiver
[ 7] 0.00-30.03 sec 0.00 Bytes 0.00 bits/sec sender
[ 7] 0.00-30.03 sec 319 MBytes 89.1 Mbits/sec receiver
[ 9] 0.00-30.03 sec 0.00 Bytes 0.00 bits/sec sender
[ 9] 0.00-30.03 sec 307 MBytes 85.8 Mbits/sec receiver
[ 11] 0.00-30.03 sec 0.00 Bytes 0.00 bits/sec sender
[ 11] 0.00-30.03 sec 311 MBytes 87.0 Mbits/sec receiver
[ 13] 0.00-30.03 sec 0.00 Bytes 0.00 bits/sec sender
[ 13] 0.00-30.03 sec 317 MBytes 88.6 Mbits/sec receiver
[ 15] 0.00-30.03 sec 0.00 Bytes 0.00 bits/sec sender
[ 15] 0.00-30.03 sec 322 MBytes 90.1 Mbits/sec receiver
[ 17] 0.00-30.03 sec 0.00 Bytes 0.00 bits/sec sender
[ 17] 0.00-30.03 sec 313 MBytes 87.5 Mbits/sec receiver
[ 19] 0.00-30.03 sec 0.00 Bytes 0.00 bits/sec sender
[ 19] 0.00-30.03 sec 310 MBytes 86.7 Mbits/sec receiver
[SUM] 0.00-30.03 sec 0.00 Bytes 0.00 bits/sec sender
[SUM] 0.00-30.03 sec 2.45 GBytes 700 Mbits/sec receiver
ã¯ã©ã€ã¢ã³ãã§ïŒ
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-30.00 sec 307 MBytes 85.8 Mbits/sec 0 sender
[ 4] 0.00-30.00 sec 306 MBytes 85.5 Mbits/sec receiver
[ 6] 0.00-30.00 sec 320 MBytes 89.6 Mbits/sec 0 sender
[ 6] 0.00-30.00 sec 319 MBytes 89.2 Mbits/sec receiver
[ 8] 0.00-30.00 sec 308 MBytes 86.2 Mbits/sec 0 sender
[ 8] 0.00-30.00 sec 307 MBytes 85.9 Mbits/sec receiver
[ 10] 0.00-30.00 sec 313 MBytes 87.5 Mbits/sec 0 sender
[ 10] 0.00-30.00 sec 311 MBytes 87.1 Mbits/sec receiver
[ 12] 0.00-30.00 sec 318 MBytes 89.0 Mbits/sec 0 sender
[ 12] 0.00-30.00 sec 317 MBytes 88.6 Mbits/sec receiver
[ 14] 0.00-30.00 sec 324 MBytes 90.5 Mbits/sec 0 sender
[ 14] 0.00-30.00 sec 322 MBytes 90.2 Mbits/sec receiver
[ 16] 0.00-30.00 sec 314 MBytes 87.9 Mbits/sec 0 sender
[ 16] 0.00-30.00 sec 313 MBytes 87.6 Mbits/sec receiver
[ 18] 0.00-30.00 sec 311 MBytes 87.1 Mbits/sec 0 sender
[ 18] 0.00-30.00 sec 310 MBytes 86.8 Mbits/sec receiver
[SUM] 0.00-30.00 sec 2.46 GBytes 704 Mbits/sec 0 sender
[SUM] 0.00-30.00 sec 2.45 GBytes 701 Mbits/sec receiver
çµæãããããããã«ããªãŒããŒãããããããŸããããã®å ŽåãéèŠã§ã¯ãªããšèŠãªãããšãã§ããŸãã
èšèšã«ããæè¡ã®å¶éïŒãã¹ãããã®ã³ã³ãããŒã®å¯çšæ§ããã³ã³ã³ãããŒããã®ãã¹ãã®å¯çšæ§ã¯ãããŸããã ãã®ãããªæ©èœãå¿ èŠãªçç±ã¯æ¬¡ã®ãšããã§ãã
- ãµãŒãã¹ã®å¯çšæ§ãã§ãã¯ã®äžéšã¯ããµãŒãã¹ãå®è¡ãããŠãããã¹ãã§å®è¡ãããZabbixãã«ããŒã«ãã£ãŠãã§ãã¯ãããŸãã
- ãã¹ãã·ã¹ãã ã«ãããã£ãã·ã¥DNSã䜿çšããå¿ èŠããããŸãã ç§ãã¡ã®å Žåãããã¯Unboundã§ãã
- ãã¹ãã·ã¹ãã ã§å®è¡ãããŠããä»ã®ãµãŒãã¹ãžã®ã¢ã¯ã»ã¹ã䜿çšããå¿ èŠããããŸãã
- ããã¯ãããã¹ã<==>ã³ã³ãããã«ã¢ã¯ã»ã¹ããå¿ èŠãããçç±ã®äžéšã«ãããŸããã ãã®ãããªããŒãã®ã¢ãŒããã¯ãã£ãäžæ©ã§ååŸããŠåæ§ç¯ããããšã¯äžå¯èœã§ãã
ãã®å¶éãå æããããã®ãªãã·ã§ã³ïŒ
- ãã·ã³ã§2ã€ä»¥äžã®ç©çãªã³ã¯ã䜿çšããŸãã ããã«ãããé£æ¥ããã€ã³ã¿ãŒãã§ã€ã¹ãä»ãã察話ãå¯èœã«ãªããŸãã ããšãã°ãeth1ãMACVLANå°çšã«æå®ãããã¹ãã·ã¹ãã ã§eth0ãåŒãç¶ã䜿çšããŸãã ãã¡ããããã®ãªãã·ã§ã³ã¯æªããããŸããããããã«ã¯ããã®ãããªãµãŒãã¹ãéå§ããäºå®ã®ãã¹ãŠã®ãã·ã³ã§åãæ°ã®ãªã³ã¯ãç¶æããå¿
èŠããããŸãã ãããå®è£
ããã®ã¯è²»çšãããããé«éã§ã¯ãªããåžžã«å¯èœã§ã¯ãããŸããã
- ãã¹ãã·ã¹ãã ã§å¥ã®è¿œå IPã¢ãã¬ã¹ã䜿çšããä»®æ³MACVLANã€ã³ã¿ãŒãã§ã€ã¹ã§ãã³ã°ã¢ããããŸããããã¯ãã¹ãã·ã¹ãã ã§çºçãããå¿
èŠããããŸãã åã®æãä»åãšåãããã«ããµããŒãã®é¢ã§ãïŒãå¿ããªãã§ãã ããã/ãå¿ããªãã§ãïŒé£ããã§ãã ãããŠãç§ãã¡ã®ãµãŒãã¹èªäœããã®ãããªãµãŒãã¹ãéå§ããããã«æçµçã«è¿œå ã®ã¢ãã¬ã¹ãå¿
èŠãšããããšã以åã«èšã£ãã®ã§ãç§ãã¡ã¯å¿
èŠã§ãïŒ
- ãã¹ãã·ã¹ãã ã®ã¡ã€ã³ã€ã³ã¿ãŒãã§ãŒã¹ã®ã¢ãã¬ã¹ïŒ1ïŒ;
- ãµãŒãã¹ã®ã¢ãã¬ã¹ïŒ2ïŒ;
- ãµãŒãã¹ãšããåãããä»®æ³ã€ã³ã¿ãŒãã§ã€ã¹ã®ã¢ãã¬ã¹ïŒ3ïŒã
ãã®å Žåãå¿ èŠãªIPã¢ãã¬ã¹ãå€ãããããšãããããŸããããã¯ãéåžžãå°ã䜿çšãããŸãã éå°ãªIPã¢ãã¬ã¹ã«å ããŠããã®ä»®æ³ã€ã³ã¿ãŒãã§ã€ã¹ãä»ããŠã³ã³ãããžã®éçã«ãŒããç¶æããå¿ èŠãããããšãå¿ããŠã¯ãªããŸããã ããã¯å æã§ããªãè€éãã§ã¯ãããŸããããã·ã¹ãã å šäœã®è€éãã¯äºå®ã§ãã
æ°é ãã®ããèªè ã¯ããã¡ã€ã³ã€ã³ã¿ãŒãã§ã€ã¹ã®ã¢ãã¬ã¹ãä»®æ³ã€ã³ã¿ãŒãã§ã€ã¹ã«æäŸã§ããã®ã«ããªãã¡ã€ã³ã€ã³ã¿ãŒãã§ã€ã¹ãšMACVLANã€ã³ã¿ãŒãã§ã€ã¹ã®ã¢ãã¬ã¹ãªã®ãïŒããšãã質åãããŸãããã®å Žåãã·ã¹ãã ãå®éã®ã€ã³ã¿ãŒãã§ã€ã¹ã®ã¢ãã¬ã¹ãªãã®ãŸãŸã«ããŸããããŸã ãã®ãããªäžæ©ãèžã¿åºãæºåã¯ã§ããŠããŸããã
åã®2ã€ã®ããŒãžã§ã³ã§ã¯ããã¹ãŠã®ã€ã³ã¿ãŒãã§ã€ã¹ã®ã¢ãã¬ã¹ãåããããã¯ãŒã¯ã«å±ããŠãããšæ³å®ãããŠããŸããã ãã®ãããªãµããããã«100å°ã®ãµãŒããŒãããå Žåã§ãã3ã€ã®ã¢ãã¬ã¹ã§èµ·åããå Žåã / 24ã«å ¥ããªããšæ³åããã®ã¯ç°¡åã§ãã
- ãµãŒãã¹IPã ãã®ã¢ã€ãã¢ã®æ¬è³ªã¯ããµãŒãã¹çšã«åå¥ã®ãµãããããäœæããããšã§ãã ããã¯ã©ã®ããã«èŠããŸããïŒ
- ãã¿ã°ä»ãããã©ãã£ãã¯ããµãŒããŒã«éä¿¡ãå§ããŸãã
- ãã€ãã£ãVLANãdockerhostïŒeth0ïŒã®ã¡ã€ã³ãããã¯ãŒã¯ãšããŠæ®ããŸãã
- ãã¹ãã·ã¹ãã ã®IPã¢ãã¬ã¹ãªãã§ã802qã䜿çšããŠä»®æ³ã€ã³ã¿ãŒãã§ã€ã¹ãäžããŸãã
- ãµãŒãã¹ã«ã¯ãµãŒãã¹ãããã¯ãŒã¯ã®IPã¢ãã¬ã¹ã䜿çšããŸãã
ãã§ã«æããã«ãªã£ãŠããããã«ã3ã€ãææããŸãã ãã¹ãŠãæ©èœããããã«ããã«ã¯ãããã€ãã®ããšãè¡ãå¿ èŠããããŸãã
- ãã¿ã°ä»ãããã©ãã£ãã¯ãã€ã³ã¿ãŒãã§ã€ã¹ã«é
ä¿¡ããã«ã¯ã誰ãå¿
èŠã§ããïŒ ããã§ãããããã¯ãŒã¯æ
åœè
ïŒ ã¢ã¯ã»ã¹ããŒãã2ã€ã®VLANã«ãã£ãŒãããããŒãã«åãæ¿ããããã«äŸé ŒããŸãã
- ãã¹ãã§è¿œå ã®ã€ã³ã¿ãŒãã§ãŒã¹ãäžããŸãïŒ
# cat /etc/sysconfig/network/ifcfg-vlan8 BOOTPROTO='static' STARTMODE='auto' VLAN='yes' ETHERDEVICE='eth0' # ip -d link show vlan8 31: vlan8@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000 link/ether e4:11:5b:ea:b6:30 brd ff:ff:ff:ff:ff:ff promiscuity 1 vlan protocol 802.1Q id 8 <REORDER_HDR>
- Dockerã§MACVLANãããã¯ãŒã¯ãååŸãã
# docker network create -d macvlan --subnet=1.1.2.0/24 --gateway=1.1.2.1 -o parent=vlan8 c_services
- Dockerã®ãããã¯ãŒã¯ã衚瀺ãããããšã確èªããŸãã
# docker network ls | grep c_services a791089219e0 c_services macvlan
ç§ã¯ãã¹ãŠãããŸããããã¹ãŠã¯å€§äžå€«ã§ãã ããããããã¹ãã®äžè¬çãªã°ã©ãã£ãã¯ã¹ãèŠãããšã«ããŸããïŒãŸãã¯ãããæ£ç¢ºã«èšããšãååãããã«æ³šç®ããŸããïŒã ããã«ç§ãã¡ãèŠãåçããããŸãïŒ
ã¯ããããã§ãã¹ãã§ã®conntrackã®äœ¿çšã確èªã§ããŸãã
ã©ãããŠïŒ ãŸããMACVLANã®conntrackã¯å¿ èŠãããŸãããïŒïŒ ãã§ã«å€æ¹ã ã£ãã®ã§ãç§ã¯æãé©ãã¹ãçè«ã§ãããã¹ãããããšã«ããŸããã çè«çãªç¥èã確èªããããã«ãæ¥ç¶è¿œè·¡ã¯å®éã«ã¯å¿ èŠãããŸããã§ããã ããããªããã°ããã¹ãŠãæ©èœãç¶ããŸããã äœããã®çç±ã§conntrackã«é¢é£ä»ããããŠããã¢ãžã¥ãŒã«ã®ã¢ã³ããŒãã¯ãã³ã³ãããŒã®èµ·åæã«ã®ã¿äžå¯èœã§ããã ã¢ã€ãã¢ã¯ç§ãæ®ããç§ã¯å®¶ã«åž°ããå€æ¹ã®æã¯è³¢æã ãšæ±ºããŸããã
ç¿æ¥ãç§ã¯åã³ãã®å£°æã®æ£ç¢ºãã確信ããŸããã ããã§ãDockerãnf_conntrackãããŒãã§ããªãããã«ããäžåšçšãªãã¡ãœãããäœæããããšã«ããŸããã æåã¯ãåã«ååãå€æŽãïŒmodprobeãä»ããŠã¢ãžã¥ãŒã«ãããŒããããšãã«ãã©ãã¯ãªã¹ããç¡èŠãããããïŒããã®åŸãã³ã³ãããŒãå床起åããŸããã ã³ã³ããã¯äºæ³ã©ããäžæããçŽ æŽãããæ°åã«ãªããŸãããããã°ã«ã¯4ã€ã®ã«ãŒã«ãiptablesã«è¿œå ã§ããªããšããã¡ãã»ãŒãžã衚瀺ãããŸããã conntrackãå¿ èŠã§ããããšãããããŸãããïŒ è¿œå ããããªãã«ãŒã«ã¯æ¬¡ã®ãšããã§ãã
-t nat -A OUTPUT -d 127.0.0.11 -p udp --dport 53 -j DNAT --to-destination 127.0.0.11:35373 -t nat -A POSTROUTING -s 127.0.0.11 -p udp --sport 35373 -j SNAT --to-source :53 -t nat -A OUTPUT -d 127.0.0.11 -p tcp --dport 53 -j DNAT --to-destination 127.0.0.11:41214 -t nat -A POSTROUTING -s 127.0.0.11 -p tcp --sport 41214 -j SNAT --to-source :53
ããŒã53ïŒ ãªãŸã«ããŒã«é¢é£ããäœæ¥ããããŸãã ãããŠãé©ããããšã«ãçµã¿èŸŒã¿DNSãµãŒããŒã«ã€ããŠåŠã³ãŸããã ãã«ãã€ã³ã§ã¯ãããŸããããªãã·ã§ã³ã䜿çšããŠäœããã®åœ¢ã§ãªãã«ã§ããŸããïŒ ããããããã¯äžå¯èœã§ã:)
次ã«ãã¢ãžã¥ãŒã«ãè¿ãããµãŒãã¹ãéå§ããiptablesããã«ãŒã«ãä¿®æ£ããã¢ãžã¥ãŒã«ãã¢ã³ããŒãããããšããŸãã...ããããããã¯ãããŸããã§ããã modinfoãéžæããããšã«ãããã©ã®ã¢ãžã¥ãŒã«ãã©ã®ã¢ãžã¥ãŒã«ã«äŸåããŠãããã©ã®ã¢ãžã¥ãŒã«ã誰ããåŒã£åŒµã£ãŠããã®ããããããŸããã ãããã¯ãŒã¯ãäœæãããšããDockerã¯åŒ·å¶çã«modprobe xt_natãäœæããŸããããã¯ã nf_conntrackã«äŸåããŸã ã確èªã¯æ¬¡ã®ãšããã§ãã
# modinfo xt_nat filename: /lib/modules/4.4.0-3.1-default/kernel/net/netfilter/xt_nat.ko alias: ip6t_DNAT alias: ip6t_SNAT alias: ipt_DNAT alias: ipt_SNAT author: Patrick McHardy <kaber@trash.net> license: GPL srcversion: 9982FF46CE7467C8F2361B5 depends: x_tables,nf_nat intree: Y vermagic: 4.4.0-3.1-default SMP preempt mod_unload modversions
ç§ãèšã£ãããã«ããã¹ãŠã¯ãããã®ã¢ãžã¥ãŒã«ãªãã§æ©èœããŸãã ãããã£ãŠãç§ãã¡ã®å Žåããããã¯å¿ èŠãªããšçµè«ä»ããããšãã§ããŸãã åé¡ã¯æ®ã£ãŠããŸããããã«ããããããããªãå¿ èŠãªã®ã§ããããïŒ ç§ã¯ããŸãã«ãæ zyã§ã¯ãªãã£ããã2ã€ã®å ŽæãèŠãŸããïŒ
- Dockerã®åé¡;
- ãœãŒã¹ã³ãŒãã«ã
ãããŠãç§ã¯ããã§äœãèŠã€ããŸãããïŒ TrueïŒãŠãŒã¶ãŒå®çŸ©ãããã¯ãŒã¯ã®å ŽåãDockerã¯modprobeãå®è¡ããŸãã ã³ãŒããèŠãŠãèå³ã®ãã2ã€ã®ãã€ã³ãã確èªããŸãã
if out, err := exec.Command("modprobe", "-va", "nf_nat").CombinedOutput(); err != nil { logrus.Warnf("Running modprobe nf_nat failed with message: `%s`, error: %v", strings.TrimSpace(string(out)), err) } if out, err := exec.Command("modprobe", "-va", "xt_conntrack").CombinedOutput(); err != nil { logrus.Warnf("Running modprobe xt_conntrack failed with message: `%s`, error: %v", strings.TrimSpace(string(out)), err) }
ãããŠãããäžã€ãããŸãïŒ
if err := r.setupIPTable(); err != nil { return fmt.Errorf("setting up IP table rules failed: %v", err) }
ããããäœæããããäžèŠãªãã®ããã¹ãŠæšãŠãŸã:)æ°ããDockerã¢ã»ã³ããªãäœæããŸãã
èŠãŸãã ãã¹ãŠãæ£åžžã§ããã¹ãŠãæ©èœããŸãã
ãã®æ®µéã§ã¯ãåè·¯å šäœãå®éšå®€ã®ç¶æ ã§åäœããŠãããšæ³å®ã§ããŸãããæå°ã®ããšãè¡ãã ãã§ã-ããããµãŒãã¹ã«ã¢ã¿ããããŸãã ããŠããµãŒãã¹ã«æ»ã£ãŠããã®äžè¬çãªã¢ãŒããã¯ãã£ãèŠãŠãã ããã
ä»çµã¿ã®èª¬æïŒ
- ïŒ1ããã³6ïŒã¢ãã€ã«ã¯ã©ã€ã¢ã³ããç¹å®ã®URLãšã®æ¥ç¶ã確ç«ãããã®èåŸã«ãã©ã³ãµãŒãç«ã€;
- ïŒ2ïŒãã©ã³ãµãŒããµãŒãã¹ã®ç®çã®ã€ã³ã¹ã¿ã³ã¹ãéžæããã¯ã©ã€ã¢ã³ããšãµãŒãã¹ã®æ¥ç¶ã確ç«ã§ããããã«ããŸãã
- ïŒ3ããã³4ïŒæ¬¡ã«ããµãŒãã¹ã¯ã³ãŒãã䜿çšããŠã¯ã©ã€ã¢ã³ãããã¯ã©ã¹ã¿ãŒã«ãªã¯ãšã¹ãããããã·ããŸãããnginxã®åœ¢åŒã®ãã©ã³ãµãŒãä»ããŸãã ããã§ãnginxããµãŒãã¹ãšåããã·ã³äžã«ãªããã°ãªããªããšããèŠä»¶ã«æ»ããŸããã çŸæç¹ã§ã¯ãã³ã³ããå ã§ã¯ãªããã¹ãäžã«ããå¿ èŠããããšããå¶éããããŸãïŒããã«ãããåé¡ã¯ããã«è§£æ±ºãããŸãïŒã ãã®èšäºã§ã¯ããã®èŠä»¶ã®çç±ã«ã€ããŠã¯èª¬æããŸããããæ¡ä»¶ãšããŠåãå ¥ããŸãã
- ïŒ5ïŒãµãŒãã¹ã®åã€ã³ã¹ã¿ã³ã¹ã«ã¯ç¹å®ã®IDããããã³ãŒãã¯ã©ã®ç¹å®ã®ã€ã³ã¹ã¿ã³ã¹ãä»ããŠã¯ã©ã€ã¢ã³ãã«å¿çããããç解ããå¿ èŠããããŸãã
æåã®è¿äŒŒã§ã¯ããµãŒãã¹ã䜿çšããŠã€ã¡ãŒãžãåéããæ¢ã«ã³ã³ãããŒå ã§ãããèµ·åããããšã劚ãããã®ã¯ãããŸãããã1ã€ãããŸãã ããŸããŸãå€éšãã©ã³ãµãŒãšã®çžäºäœçšãå¿ èŠãšãããµãŒãã¹ã«ã¯ã次ã®ãããªç¹å®ã®éçã«ãŒãããããŸãã
# ip r default via 1.1.2.254 dev eth0 10.0.0.0/8 via 1.1.2.1 dev eth0 1.1.2.0/24 dev eth0 proto kernel scope link src 1.1.2.14 192.168.0.0/16 via 1.1.2.1 dev eth0
ã€ãŸã å éšãããã¯ãŒã¯ã«åºå ¥ããããã¹ãŠã®ãã®ã¯.1ãéããæ®ãã¯.254ãéããŸãã
ç§ãã¡ã®å Žåããªããããåé¡ãªã®ã§ããïŒ ã«ãŒãã§ã³ã³ãããèµ·åãããšã次ã®ããã«è¡šç€ºãããããã§ãã
# ip r default via 1.1.2.1 dev eth0 1.1.2.0/24 dev eth0 proto kernel scope link src 1.1.2.14
ã³ã³ããå ã®ã«ãŒããå€æŽããããšããŠãäœãèµ·ãããŸããã ç§ãã¡ã«ã¯ç¹æš©ããããŸããïŒ --priveleged ïŒã ãã¹ãããã³ã³ãããèµ·åããåŸãæåã§ã«ãŒããå€æŽããããšã¯æ®ã£ãŠããŸãïŒå€§ããªèª€è§£ããããŸãããããã«ã€ããŠã¯åŸã§è©³ãã説æããŸãïŒã 次ã®2ã€ã®ãªãã·ã§ã³ããããŸãã
- ã³ã³ããã®åå空éã䜿çšããŠæåã§å®è¡ããŸãã
- ãã€ãã¯ãŒã¯https://github.com/jpetazzo/pipeworkãåããåãããšãè¡ããŸãããããã䜿çšããŸãã
ç§ã¯ããã«ããªãããããšäžç·ã«æ®ããããšãã§ãããšèšããŸãããåŠçã®ããã«å±éºããããŸãïŒãããªãã¯å¿ãããåŸç¹ããã飲ãããšãã§ããã:)
çæ³ãç®æããŠããã®ãµãŒãã¹ãããã¯ãŒã¯ã®ããã©ã«ãgwãä»ããŠãã¹ãŠã®ã«ãŒããäœæããã«ãŒãã£ã³ã°ã®è€éãããã¹ãŠãããã¯ãŒã¯éšéã«è»¢éããŸããã ããã ãã§ã ãã£ãšæ£ç¢ºã«èšãã°ãç§ã¯ãã¹ãŠã...
ãã®ãšãç§ã«ã¯æãã-解決çã¯çŽ æŽãããã ãã¹ãŠãæåŸ ã©ããã«æ©èœããå Žåãããã¯ãããªããŸãããããã§çµããã§ã¯ãããŸããã§ããã å°ãåŸã«ããã®ã¹ããŒã ã䜿çšããŠãLTMãçµç±ããã«ãŒããæã€ãããã¯ãŒã¯ã®é察称ã«ãŒãã£ã³ã°ãååŸããããšãæããã«ãªããŸããã ããããããããããã«ãã©ã®ãµããããã䜿çšã§ãããã瀺ããŸãã
- ããã©ã«ãgwã1ã€ã®ã¿ã§ãå€éšãã©ã³ãµãŒãååšããªããããã¯ãŒã¯ã
- è€æ°ã®GWãæã€ãããã¯ãŒã¯ïŒããšãã°ãå€éšèŠæ±ãã©ã³ãµãŒã é£ç¹ã¯ãå
éšãã©ãã£ãã¯ãééãããªãããšã§ãã
ãããã¯ãŒã¯æ åœè ãšè©±ãåã£ãåŸã次ã®çµè«ãåºããŸããã
- ã«ãŒãã£ã³ã°ãè¡ããã¹ãŠã®ãããã¯ãŒã¯ãç£èŠãã責任ãè² ãæºåãã§ããŠããŸããã
- ç§ãã¡ã®åŽã§ã¯ããµãŒããŒäžã®ãã¹ãŠã®ãã®ãããªãããã¯ãŒã¯ã®éçã«ãŒãããµããŒãããæºåãã§ããŠããŸãã
ç°¡åãªããšããããå Žåãåé¡ãçªç¶è§£æ±ºããèµ·ããããå°é£ãããã«èããªããã°ãããã¯ããªãæ²ããçµæã«ã€ãªããå¯èœæ§ããããŸããã
ç§ã¯ãã€ãã以åã«æãã€ãããæåŠãããã¢ã€ãã¢ãå¿ããŠã¯ãªããªããšèšã£ãŠããŸãã ã³ã³ããå ã§éçã«ãŒãã䜿çšãããšããèãã«æ»ããŸããã
ãããã£ãŠãã³ã³ããã§ã®ãµãŒãã¹ã®åäœãä¿èšŒããæ¡ä»¶ã¯æ¬¡ã®ãšããã§ãã
- ãµãŒãã¹èªäœ;
- ãµãŒãã¹ã®å°çšIPã
- ãã¹ãŠã®ãµããããããã®ãµãŒãã¹ã®å¯çšæ§ãšã¢ãã¬ã¹ã
- ã³ã³ããã®èµ·åæã«ã«ãŒãã䜿çšããã³å€æŽããæ©èœïŒæãéèŠãªã®ã¯ãããã¯ãŸãã«å¿ããããšãã§ãããã®ã ããã§ãïŒã
ã³ã³ãããç¹æš©ã¢ãŒãïŒ --privileged ïŒã§èµ·åããããªãããŸãã¯èµ·åããããªãã æåã¯ãã³ã³ããã®èµ·åæã«è¿œå ããã³åé€ã§ããLinuxæ©èœã«ã€ããŠã¯èããŸããã§ããã ãããã®è©³çŽ°ã«ã€ããŠã¯ã ãã¡ããã芧ãã ãã ã ãã®ã¿ã¹ã¯ã§ã¯ã NET_ADMINãè¿œå ããã ãã§ååã§ã ã
ããã§å³ãå®æããèªåå®è¡ãžã®ã«ãŒãã£ã³ã°ã«å¿ èŠãªãã®ããã¹ãŠè¿œå ã§ããŸãã
æçµçµæã«è¿ãDockerfileã®å€èŠ³ãèŠãŠã¿ãŸãããã
DockerfileïŒ
FROM dockerio.badoo.com/itops/sle_12_base:latest MAINTAINER #MAINTEINER# RUN /usr/bin/zypper -q -n in iproute2 RUN groupadd -g 1001 wwwaccess RUN mkdir -p /local/SERVICE/{var,conf} COPY get_configs.sh /local/SERVICE/ COPY config.cfg /local/SERVICE/ ADD SERVICE-CERTS/ /local/SERVICE-CERTS/ ADD SERVICE/bin/SERVICE-BINARY-${DVERSION} /local/SERVICE/bin/ ADD SERVICE/conf/ /local/SERVICE/conf/ COPY routes.sh /etc/cont-init.d/00-routes.sh COPY env.sh /etc/cont-init.d/01-env.sh COPY finish.sh /etc/cont-finish.d/00-finish.sh COPY run /etc/services.d/SERVICE/ COPY finish /etc/services.d/SERVICE/ RUN touch /tmp/fresh_container ENTRYPOINT ["/init"]
泚æãã䟡å€ããããã®ïŒ
- ã³ã³ããå ã®ã¹ãŒããŒãã€ã¶ãŒãšããŠs6ãªãŒããŒã¬ã€ã䜿çšããŸãã
- ã«ãŒããç·šéã§ããããã«iprouteããã±ãŒãžãè¿œå ããŸãã
- ãµãŒãã¹ã®éå§åã«å®è¡ãããããã€ãã®ã¹ã¯ãªããã®èµ·åïŒãã£ã¬ã¯ããª/etc/cont-init.d/ïŒãè¿œå ãããµãŒãã¹ãçµäºããåŸã«å®è¡ãããã¹ã¯ãªãããè¿œå ããŸãããã³ã³ãããããããããåã«ïŒ/ etc / cont -finish.d /ïŒ;
- ã³ã³ãããåããŠèµ·åãããã©ãããç解ããããã«ããã¡ã€ã«/ tmp / fresh_containerãè¿œå ããŸãã æ®ãã®ã¹ã¯ãªããã®å 容ã衚瀺ãããšãå°ãæ確ã«ãªããŸãã
䜿çšãããã¹ã¯ãªããïŒ
- get_configs.shã¯ãã·ã¹ãã ã«èšå®ãä¿åããã³çæããããã®ãµãŒãã¹ã®èšå®ããããã©ããã確èªããã¹ã¯ãªããã§ãèšå®ãã³ã³ããã«é
ä¿¡ããæå¹æ§ããã§ãã¯ãããã¹ãŠãæ£åžžã§ããå Žåããããšãšãã«èµ·åããŸãã ããã«ã€ããŠã¯ã Docker Meetupã§è©³ãã説æããŸããã
- routes.sh-ã³ã³ããå
ã®ã«ãŒããæºåããã¹ã¯ãªããïŒ
#!/usr/bin/with-contenv sh if [ ! -x /usr/sbin/ip ];then echo -e "\e[31mCan't execute /usr/sbin/ip\e[0m"; [ $(pgrep s6-svscan) ] && s6-svscanctl -t /var/run/s6/services exit 1; else LTMGW=$(/usr/sbin/ip r show | /usr/bin/grep default | /usr/bin/awk {'print $3'} | /usr/bin/awk -F \. {'print $1"."$2"."$3".254"'}) DEFGW=$(/usr/sbin/ip r show | /usr/bin/grep default | /usr/bin/awk {'print $3'} | /usr/bin/awk -F \. {'print $1"."$2"."$3".1"'}) /usr/sbin/ip r replace default via ${LTMGW} /usr/sbin/ip r add 192.168.0.0/16 via 10.10.8.1 dev eth0 /usr/sbin/ip r add 10.0.0.0/8 via 10.10.8.1 dev eth0 echo -e "\e[32mAll job with routes done:\e[0m\n$(/usr/sbin/ip r show)" fi
- env.sh-ãµãŒãã¹ã®ç°å¢ãæºåããã¹ã¯ãªããã å€ãã®å Žåãã³ã³ããã®æåã®èµ·åæã«1åã ãå®è¡ãããŸãã
#!/usr/bin/with-contenv sh if [ ! -z "${ISTEST}" ];then exit 0;fi if [ ! -n "${SERVICETYPE}" ];then echo -e "\e[31mPlease set SERVICE type\e[0m"; [ $(pgrep s6-svscan) ] && s6-svscanctl -t /var/run/s6/services exit 1; fi bash /local/SERVICE/get_configs.sh || exit 1 echo -e "\e[32mSERVICE ${SERVICETYPE} is running\e[0m"
- finish.shã¯ããµãŒãã¹ããpidãã¡ã€ã«ãåçŽã«åé€ããã¹ã¯ãªããã§ãã ç¹å®ã®ãµãŒãã¹ã¯ïŒChuck Norrisã®ããã«ïŒãšãŠãã¯ãŒã«ãªã®ã§å®è¡ããŸããããå€ãpidãã¡ã€ã«ãæ€åºãããšéå§ãããŸãã:)
- runã¯ãã¢ããªã±ãŒã·ã§ã³ãèµ·åããã¹ã¯ãªããã§ãã
#!/usr/bin/with-contenv bash exec /local/SERVICE/bin/SERVICE-${DVERSION} -l /local/SERVICE/var/mobile-${SERVICETYPE}.log -P /local/SERVICE/var/mobile-${SERVICETYPE}.pid -c /local/SERVICE/conf/SERVICE.conf -v ${VERBOSITY}
- finish-ãµãŒãã¹ãäœæ¥ãå®äºããå Žåã«ã³ã³ãããæ¶æ»
ãããã¹ã¯ãªããïŒ
#!/bin/sh [ $(pgrep s6-svscan) ] && s6-svscanctl -t /var/run/s6/services
ãµãŒãã¹ãéå§ããè¡ã¯æ¬¡ã®ããã«ãªããŸãã
docker run -d --net=c_services --ip=1.1.2.17 --name=SERVICE-INSTANCE16 -h SERVICE-INSTANCE16.local --cap-add=NET_ADMIN --add-host='nginx.localhost:1.1.1.17' -e SERVICETYPE=INSTANCE16_eu1 -e HOST_IP=1.1.1.17 --volumes-from=badoo_loop dockerio.badoo.com/cteam/SERVICE:2.30.0_994
ããã«ãããã³ã³ãããžã®ãµãŒãã¹ã®è»¢éã¯æåãããšèŠãªãããšãã§ããŸãã ä»åŸã¯ãä»ã®ãµãŒãã¹ã§MACVLAN / IPVLANã䜿çšããããšã«æ³šæãããã®ã§ããããã®å®éšã¯äžäŸã§ãã
ã¢ã³ãã³ãããã«ãã«ã³èª
Badooã®ãµã€ãä¿¡é Œæ§ãšã³ãžãã¢