Single Node Kubernetes Cluster - Installing Ubuntu Server on Windiws with Hyper-V


14 Jul 2019  Michal Fabjanski  3 mins read.

Today we will start playing with Kubernetes. We will start by installing Ubuntu 19.04 Server on the Hyper-V virtual machine. Next, we will create a single node Kubernetes cluster. You can also use Minikube (a tool for running Kubernetes locally) for Windows instead of Ubuntu Server - but I wanted it to resemble a real development environment.
We will use a ssh connection from windows to manage our cluster on Ubuntu Server.

Requirements

  • Internet connection on the system that has Hyper-V installed.
  • Hyper-V enabled

Configuring Hyper-V Virtual Switch Manager

Your virtual machine will need access to your host windows’ internet connection. To do this we must configure Virtual Switch Manager.
Open the Hype-V panel and click on the “Virtual Switch Manager”:
virtual-switch-manager

  1. Create a new External Virtual Switch:
    virtual-switch-manager

  2. Set a name and select your network adapter in the External Network virtual-switch-manager

  3. Go to Control Panel\Network and Internet\Network Connections. You will see your newly created connection:
    virtual-switch-manager

  4. Right-click your Windows connection (In my case it is Ethernet). Click Properties, select Sharing tab and check the box All other network users to connect through this computers Internet connection.:
    virtual-switch-manager

That’s all. Now you should have Internet access in your virtual machine.

Creating Hyper-V virtual machine

Now we can create VM with Ubuntu 19.04:

  1. Open Start
  2. Search for Hyper-V Manager
  3. Select New and click on Virtual Machine:
    virtual-switch-manager
  4. Choose a name, leave the default Generation 1 option and click next.
  5. Select the amount of RAM. I set 8192MB
  6. Select the virtual switch which you created earlier:
    virtual-switch-manager
  7. On the Connect virtual hard disk tab you can set disk size. I allocated 25Gb.
  8. On the Installation options tab select Install an operating system from a bootable CD/DVD-ROM option and provide a path for the Ubuntu ISO file. Click next and finish.

Installing Ubuntu 19.04 Server using Hyper-V Virtual Machine

We have prepared a virtual switch and a virtual machine. Now we can install Ubuntu.

  1. Open Hyper-V, right-click the newly created Virtual machine (in my case name is Ubuntu). Select Connect.
    virtual-switch-manager
  2. Click the Start:
    virtual-switch-manager
  3. Click the Install Ubuntu Server:
    virtual-switch-manager
  4. Leave default values in the next steps
  5. Enter the username and password to your account
  6. Set Install OpenSSH server:
    virtual-switch-manager
  7. Restart the virtual machine to finish the setup.

To connect to a ubuntu server in a virtual machine go to the Hyper-V -> Virtual Machines. Right-click on the virtual machine and then click on Connect.
virtual-switch-manager

Connecting to Hyper-V Ubuntu Virtual Machine via SSH

In next posts, we will connect to the virtual machine via SSH. We will need two programs:

  • Putty - a free SSH client
  • WinSCP - a popular free SFTP client for Windows. We will use it to transfer files to the virtual machine.

To connect to a virtual machine, run the ubuntu server in Hyper-V. After starting Ubuntu, enter the command in the terminal:

 
ifconfig

Copy inet IP and use it in Putty / WinSCP to connect to VM: virtual-switch-manager

Use the default settings and default port 22:

virtual-switch-manager

Enter the user login and password you set during the Ubuntu installation to connect: virtual-switch-manager

After entering login details and clicking enter - you will get access to the Ubuntu Server in your Putty terminal.

virtual-switch-manager

Connection via WinSCP looks the same as in the case of Putty.

We already have a prepared environment. In the next post, we will set and configure a Kubernetes cluster.