Prerequisites
- Ubuntu 16 running in VirtualBox
VirtualBox Preferences
In VirtualBox Preferences define Host-only adaptor (should already exist and default to the following)
- Ip: 192.168.56.1
- Netmask: 255.255.255.0
- DHCP: Enabled
Create K8Master Node
Create VM
Create a VM with the following:
...
For Networking assign the following:
Adaptor 1: NATNATNet
Adaptor 2: Host-only adapter (vboxnet0)
...
Start VM and install Ubuntu Server 16
Networking Setup
Log into the VM and issue the following commands.
...
Code Block |
---|
enp0s3 Link encap:Ethernet HWaddr 08:00:27:ff:1a:7b inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0 inet6 addr: fe80::a00:27ff:feff:1a7b/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2885 errors:0 dropped:0 overruns:0 frame:0 TX packets:644 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:3903493 (3.9 MB) TX bytes:39345 (39.3 KB)... enp0s8 Link encap:Ethernet HWaddr 08:00:27:eb:d0:60 BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:19723 (19.7 KB) TX bytes:0 (0.0 B) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:161 errors:0 dropped:0 overruns:0 frame:0 TX packets:161 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1 RX bytes:11889 (11.8 KB) TX bytes:11889 (11.8 KB) ... |
From the above we can see that our vm has 2 network interfaces but only one is configured. The first interface is using NAT and has been assigned an IP address. We will need to add the second interface which is using the host-only network.
We are going to set this second interface (host-only) to a specific IP address: (192.168.56.100)
We might as well change the first interface to a static one too.
> sudo vi /etc/network/interfaces
Code Block |
---|
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). source /etc/network/interfaces.d/* # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto enp0s3 #iface enp0s3 inet dhcp iface enp0s3 inet dhcp static address 10.0.2.100 netmask 255.255.255.0 network 10.0.2.0 broadcast 10.0.2.255 gateway 10.0.2.1 dns-nameservers 10.0.2.1 8.8.8.8 auto enp0s8 iface enp0s8 inet static address 192.168.56.100 netmask 255.255.255.0 network 192.168.56.0 broadcast 192.168.56.255 |
...
From the VM, confirm that you can resolve DNS by issueing issuing the following command:
> nslookup google.com
We can also setup port forwarding via our NAT network to access our VM using
> ssh -p PORT test@localhost
Appendix - Virtual Box
Network Configurations
+-----------+-------------+-------------+----------------+----------------+
| | VM <-> Host | VM1 <-> VM2 | VM -> Internet | VM <- Internet |
+-----------+-------------+-------------+----------------+----------------+
| HostOnly | Yes | Yes | No | No |
| Internal | No | Yes | No | No |
| Bridged | Yes | Yes | Yes | Yes |
| NAT | No | No | Yes | Port forward |
| NATNet | No | Yes | Yes | Port forward |
+-----------+-------------+-------------+----------------+----------------+
Reference
Reference | URL |
---|---|
Kubernetes on Ubuntu | https://kubernetes.io/docs/getting-started-guides/ubuntu/ |
Install Kubernetes On Ubuntu | https://www.youtube.com/watch?v=UWg3ORRRF60 |
Building a Kubernetes Cluster in VirtualBox with Ubuntu | https://medium.com/@KevinHoffman/building-a-kubernetes-cluster-in-virtualbox-with-ubuntu-22cd338846dd |
Kubernetes cluster setup using virtual machines | https://www.profiq.com/kubernetes-cluster-setup-using-virtual-machines/ |