Skip to content

Creating a Kubernetes Cluster

Setting up a Kubernetes Cluster within netlab

To create a kubernetes cluster within the netlab. First you need to connect to it using VPN. The details are desribed in [[sources:netlab:connect_using_vpn|Introduction: Working with the Netlab]]

When connected to the VPN and logged into VCenter you can create a Kubernetes cluster from a pre-existing template. Since we need kubernetes we will start with a template which has pre-installed kubernetes software named microk8s. We will create a virtual machine from the corresponding template as an example.

Installing Kubernetes template

To do this, right-click "Templ_MicroK8S_ubuntu" in the left panel of the VMware vSphere Client and choose “New VM from this template” (you can also select the template and choose the corresponding action from the Actions drop-down menu). The asterisks contain the version numbers. Simply choose the latest.

Template MicroK8S

Here appear some questions about the location of your virtual machine: - Select Name and Location All virtual machines should preferably start with the user name, so it's clear to whoever the machine belongs. - Expand the "Netlab-DC" directory. - Expand the “_Courses” directory and choose your course (Teachers have a personal folder under the “_Personal” directory”) - Choose Next. - Select a compute resource (Expand the Resource Pool "_Courses-RP") - Select the resource pool for your course and click next - Select storage "DataCluster-Students" and click next (or NIM01-Teachers if you are a teacher) - Make sure Customize and Power on are unchecked and click next - Review settings and click finish

Using your VM

Change settings before starting the VM the first time as following: - Select your VM and right-click for “Edit Settings” - Make sure the network adapter 1 is connected to the K8SVLAN (0220-K8SVLAN) and that “connect at power on” is selected. - Make sure the CD/DVD drive 1 “connect at power on” is unselected - Click OK to save changes

Then right-click “Open Remote Console” or choose this from the “Actions” menu and start your VM You can now login (Default login/password is ubuntu/ubuntu) your VM from: - The opened console via “launch web console”. - A virtual Linux VM can also be command-line operated remotely by SSH by installing and enabling openssh-server

Kubernetes Commands

Kubernetes has been pre-installed on the node. The installed package is microk8s from ubuntu. It’s a fully supported lightweight kubernetes distribution.

Microk8s can be managed via the cli using the microk8s utility

$sudo microk8s kubectl get nodes

You should get the following response (probably a newer version)

NAME STATUS ROLES AGE VERSION ubuntu Ready 17d v1.20.2-34+350770ed07a558

note that it will take some time for microk8s to fully boot.

When wanting to execute the commands without sudo, you have to add the ubuntu