v1.0
Managed Kubernetes
K8s Basics
Networking / Ingress
Storage
Data Services
Automating PMK
Troubleshooting

How to run a PMK Kubernetes Cluster on a Virtual Machine on Mac

The following tutorial enables you to run a simple single node Kubernetes cluster on your Mac laptop or desktop using PMK.

This type of setup is useful for:

  • Developers wanting to test and validate changes locally,
  • DevOps engineers who want a test PMK cluster to learn and experiment with Kubernetes and PMK.

Here is a summary of the steps involved:

  • Install VirtualBox on your macOS machine (laptop or desktop)
  • Create an Ubuntu 18.04 VM in VirtualBox
  • Create a single node PMK cluster using this VM

Step 1: Install VirtualBox on macOS

Install VirtualBox on macOS (via Download)

On macOS, there are two popular ways to install VirtualBox.

The first is to download the latest edition of VirtualBox for your platform. At the time of this writing, it is version 6.1.2 for macOS

Once the file is downloaded, it will be in the ‘Downloads’ folder. Mount the DMG file by double-clicking on it, which will launch another window that contains the actual installer. That installer is called VirtualBox.pkg.


Launch VirtualBox.pkg and follow through the next installation steps.


Step 1b. Click “Continue” to allow the prerequisite checks.


Step 1c. Continue the installation by clicking “Install” on the bottom left. It will prompt for a password for admin access to update the network configuration.


Step 1d. Once install is successful, Click “Close” on the installer wizard. VirtualBox is now installed and ready to be used.


Install VirtualBox on macOS (via Homebrew)

On macOS, there is a developer focused community project called Homebrew (https://brew.sh/) that provides a locally installed utility that can be used to install and update projects provided by the community.

VirtualBox is available via this method and can be installed with a single command line.

MacBook-Air

Terminal
Copy

Step 2: Retrieve Ubuntu LTS

In a web browser, go to http://releases.ubuntu.com/18.04/ and scroll down to the “Server” download section to get the “64-bit PC (AMD64) server install image” image. This will take a few minutes, as it is 873Mb.

Step 3: Create VirtualBox Virtual Machine

In the Application folder, users will see VirtualBox listed there.

Launch VirtualBox. It will be a clean slate to start building your new virtual machine.

Next, click the blue “New” button to create a new virtual machine. Select Linux and Ubuntu for the options, and choose a name that makes sense for you.

PMKFT recommends 16Gb of RAM and 4 cores per server node. Since this is a local test environment, not a full server, those are not strictly needed; but, the more memory you can allocate, the better the system will perform. MacBook Pro and iMacs routinely have 16 GB of RAM, so allocating 8 GB would be ideal for almost all test scenarios.

Next, let it create a virtual disk (it doesn’t matter which format) and dynamically allocate the space. The more disk space you can allocate, the better. 20 GB fills up fast when you start to play with container images in Kubernetes. Click “Create” after going through these screens.

Now you have a completed image, ready to start.

Step 4: Install Ubuntu

The first time the new virtual machine starts up, it will want the location of the ISO file that it will install from.

Select your language and then choose to “Install Ubuntu Server”

Select your language again, followed by country; tell it to not detect the keyboard layout, and select the appropriate keyboard. If you don’t really care and have a standard US English setup, then press enter four times, and it will start the installation.

After installation completes, add a hostname.

Next, add a username and password.

Users can accept the defaults for the next several screens, including ‘not to encrypt the home directory,’, and _to use LVM for disks_’ since it is a test box.

The screen after it will require you to select “Yes” to write the changes to the disk. The default is “No,” so you can’t just blindly continue.

Same with the next sequence – you can accept the defaults until the screen where it wants you to confirm, “Yes” to continue.

The next screen that prompts for information asks for a proxy, which you can just leave empty to continue.

Select whether you want the instance to patch itself.

Select whether you want any packages. The default selection is an acceptable answer; no additional packages are required.

Allow it to install the GRUB bootloader.

And we have a fully functional Ubuntu 18.04 LTS server that just needs to restart.

Now you can use this server to create a single node PMK cluster.

Step 5: Setup SSH access for your VM

By default, you will not be able to ssh into this VM, even from the host. To enable ssh access, you need to install sshd in the VM and make changes to the VM’s networking configuration to allow ssh access from outside.

  • Log into your Ubuntu server you just created on virtual box. Note: on first login, users will be prompted to create a password.
  • Next, install the OpenSSH server software to set up SSH access for your VM.
Bash
Copy

Ssh is now configured on the VM, but the VM is still not accessible from outside. This is because the VM we just created is configured with NAT as the default networking option. In this configuration, we need to enable port forwarding for the VM and forward port 22 (the ssh port) to the host level, so that any ssh requests for the VM can be received at the host level and routed to the VM.

  • Stop your VM
  • In the VirtualBox UI, select the VM on the left-hand panel, then click on ‘Settings’ ⇾ ‘Network’
  • You will see ‘Adapter1’ configured with ‘NAT’. Expand the ‘Advance’ menu, then click ‘port forwarding’. Click + button on the right to create a new port forwarding rule for this VM.
  • Specify the following parameters in the rule: Name: SSH Protocol: TCP Host IP: 127.0.0.1 Host Port: 2222 IP Guest: Empty Port Guest: 22
  • Start your VM
  • Now open a terminal window on your host machine and run the following command to ssh into the VM
Bash
Copy

Your ssh access is now configured!

Step 6: Create a Single Node Kubernetes Cluster using PMK CLI

  • Log into your Ubuntu server you just created on virtual box.
  • Download and install the PMK CLI by running the following command on your Ubuntu terminal.
Bash
Copy
  • Once the CLI is installed, you can attach the node to Platform9 by running the command below.
Bash
Copy

When the prep-node command completes, you can return to the Platform9 SaaS Management Plane and build your cluster.

  Last updated