Docker cluster network planning and VM network configuration __virtualbox

Source: Internet
Author: User
Tags set time ssh docker swarm k8s aliyun
Docker cluster network planning and VM network configuration

"Summary" using either k8s (kubernetes) or Docker swarm requires a cluster of PCs or VMS, and network planning is the first step to starting a job. The goal of this article is to use VirtualBox on a stand-alone computer to create a CentOS 7 server cluster, especially the basics of network configuration, and to install CentOS servers.

Docker cluster network planning and VM network configuration 1 Machine Requirements 2 Network Configuration Basics 1 Virtual Machine Network configuration 2 VirtualBox network basic settings 3CentOS Virtual Cluster Network Setup 1 Install base CentOS 7 server 2 install Manager host 3 Installing WORKER1WORKER2 host 4 network configuration results and more complex scenarios 1 single-Physical machine virtual machine Communication 2 virtual machine communication across physical computers in LAN how to achieve 5 summary

1, machine requirements

Use k8s or Docker Swarm to do container service orchestration (orchestration) 12, requiring at least three servers. If you have only one machine, then you have to use a virtual machine. Your machine application to meet: Internet (wired, wireless Can) 2 cores (4 threads) CPU, preferably 4 cores (8 threads) 8G memory, preferably G or above can install run VirtualBox and other virtualization software

The host is Linux, with the SSH tool on its own. Host is Windows, you need to install the SSH tool, such as Git Bash or PuTTY. Host is Windows must not start CentOS graphics desktop, insufficient resources.

git Bash download and install: git for Windows 2, network configuration Basics

Typically, VirtualBox virtualization software is a virtual machine or container created by the Docker Engine (engine), which has a virtual NIC by default. The default network configuration for virtual machine network adapters is NAT, and Docker is bridge. What is the difference between NAT and bridge? 2.1 Virtual Machine network configuration

Virtual machine network settings are common in four ways 3:nat network address translation mode (Nat,network addressing translation) bridged Adapter bridge mode Internal Internal network mode host-only Adapter host mode

For a simple explanation of the role of the network, host represents the current host, the VM represents the virtual machine or container in the host, you can use the following table to represent the communication relationship:

Way HOST->VM Vm->host VM-> VM VM-> Extranet
Nat X? Ok X ?
Bridged X? Ok Ok
Internal X X Ok X
Host-only ? ? ? ?

of which: X means desperation, impossible communication x? NAT set port mappings can be accessed via firewall limited access OK with network segment? Familiar with the network segment, gateway, routing, etc., can be configured freely, bridged is the network two layer (link layer) protocol,VM and host in the local area network is equal

In order to meet the complex communication needs, we need to set up more than one network card, configured in different ways. 2.2 VirtualBox network basic Settings

To meet the communication between multiple virtual machines, VirtualBox must add a virtual NIC, for example:

Add network adapters under the VirtualBox menu-> admin-> Global Settings-> Network:

In this way, set up a new network card, with a new network segment 192.168.56.1/24,host has a new web site 192.168.56.1. If you want the virtual machine to automatically get the address, set up the DHCP server. Otherwise, the virtual machine needs to set a static IP address.

Use ipconfig in Windows system to see this network card.

Set up the network Bridge on this network card. Of course, we do not want to use it to access the extranet. 3, CentOS virtual cluster network settings

Suppose you want to install three mutual communication virtual machines Manager1, Worker1, Worker2, requirements are: access to the extranet Manager1, Worker1, Worker2 and host can be internal communication.

Obviously, it is not feasible to use only the default NAT, and you must use the virtual network card that you just added. So each virtual machine has two network adapters: the first configuration NAT supports extranet access the second block is configured as an internal network (192.168.56.0) to support internal communications

Note: The order of the network card is important ... 3.1 Installation Base CentOS 7 Server with VirtualBox to create centos-base virtual machine, set requirements: Memory set 1G, hard disk 30G, second network card host-only Mount Centos-7-x86_64-minim Al-????. ISO disc mirroring set time zone, country, open Network, set host name (centos-base), root password, static pending installation completed. Reboot.

Upgrade kernel yum install wget get wget "recommended configuration" configuration Yum Aliyun source Yum update complete version upgrade

The above steps can refer to: VirtualBox installation Centos 7 notes

network Check use Nmtui Text Interface network management tool NIC, if only one network card
Shutdown-h now shutdown adds a network card to the virtual machine (select Virtual machine, set below) to restart the virtual machine

After landing, input nmtui Edit a connection Select not ENP0S3 network card, edit ... As shown in the figure set NIC Ip/mask For example: 192.168.56.250/24, and select Autoconnection (can not set the gateway, etc., otherwise ...) ) Then, activate a connection Quit

Check IP address IP addresses ping host IP, such as the 192.168.56.1,www.sysu.edu.cn host can also ping the virtual machine, such as 192.168.56.250

SSH Client Login

This is the most important step, through SSH, the host can copy files with the virtual machine, paste the instructions on the learning materials. Run Git bash with ssh login ssh root@192.168.56.250 3.2 Install manager host

Copy base virtual machine base shutdown using Vbox replication virtual machine, VirtualBox control-> replication must initialize MAC address ... start a new virtual machine use Nmtui to modify the network address (192.168.58.110/24) and the host name (manager) deactive/active that network card to enable the new address to take effect using IP address to check IP addresses

Install the Docker engine

Use SSH to connect to this virtual machine: reference: CentOS 7 Installation Docker

If the official download is particularly slow, it is recommended to use the Aliyun mirror installation Docker Engine mirrored source station 3.3 Install Worker1,worker2 host

such as copy virtual machine, with Installation Manager 4, network configuration results and more complex scenario 4.1 Single physical machine, virtual machine communication

The above network can be expressed in a graph:

Obviously, if you do not want the worker to access the outside, directly remove the NAT network card is done. 4.2 How to realize the communication between the virtual machine and the physical computer in the LAN.

This needs to be set up according to communication needs and security needs, without a unified and simple solution that requires you to have strong knowledge of the network, routing, and firewalls. In the case of small-scale clusters, there are roughly two programmes.

Network Bridge Scheme

Host only with a network card, the host virtual machine using the Network Bridge, then the host and the virtual machine address, gateway can use the same scheme.

NAT Forwarding Scheme

Oracle communicates across different physical host hosts among multiple VirtualBox virtual machines 5, summary

Computer network, communication and security is a major discipline, the introduction of the content can only meet the general needs of the cluster deployment, for learning to deploy Docker cluster enough.

Finish

Reference Docker clustering Tools compared:kubernetes vs Docker Swarm https://technologyconversations.com/2015/11/04/ Docker-clustering-tools-compared-kubernetes-vs-docker-swarm/↩ "Translation" Docker cluster tool alignment: Kubernetes vs Docker Swarm http:// Chuansong.me/n/1947305↩virtualbox Virtual Machine Network settings (four ways) Https://www.douban.com/group/topic/15558388/↩

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.