1. Lab environment

Getting to know the lab environment.

Login

The necessary URLs and credentials to access the lab environment will be provided by your trainer. Use Chrome/Chromium for the best experience.

Webshell

The first thing we are going to do is to explore our lab environment and the different components.

The provided lab environment contains an Eclipse Theia IDE1. Your IDE will look something like this:

Eclipse Theia IDE

  • On the left side you can open the Explorer which you can use for managing files and directories
  • The terminal is accessible using the menubar on top, clicking Terminal, then New Terminal or using Ctrl+Shit+^

The available environment in the webshell contains all the needed tools like kubectl and virtctl as well as the configuration needed to access the Kubernetes cluster.

Let’s verify that by executing the following command in a freshly created terminal window:

kubectl version

The files in the home directory under /home/project are stored in a persistent volume, so please make sure to store all your data in this directory and use it as starting point for all our lab files. You can create files within your webshell or using the explorer.

If you have a terminal running you can interact with the Kubernetes cluster. For example, you can list your context or get the pods of the current namespace:

kubectl config get-contexts

This should result in something like this:

CURRENT   NAME    CLUSTER   AUTHINFO   NAMESPACE
          local   local     local      webshell-<username>

The following command will show that the current webshell is also running as a pod within your namespace:

kubectl get pods --namespace webshell-<username>

So the expected outcome is a webshell pod:

NAME                             READY   STATUS    RESTARTS   AGE
<username>-webshell-885dbc579-lwhtd   2/2     Running   0          11d

Namespace

We are going to use the following namespace for the lab tasks:

  • lab-<username>

General lab notes

Placeholders

In this lab we will use the following placeholders or naming conventions:

  • $USER: If you see this somewhere else than here (you shouldn’t if you followed the URL in the email), make sure the environment variable $USER is containing your username
  • $APPDOMAIN: If you see this somewhere else than here (you shouldn’t if you followed the URL in the email), make sure the environment variable $APPDOMAIN is containing the cluster’s application domain
  • [...]: Means that some lines in the listing or command have been omitted for readability

Exiting a console of a virtual machine

In various labs we will connect to the console of a virtual machine using the virtctl console. Your terminal will look like this:

virtctl console kubevirtvm

When the terminal is connected to the virtual machine the following line appears:

Successfully connected to kubevirtvm console. The escape sequence is ^

This simple escape sequence ^ does not work within the webshell terminal. You have the following options to exit the console:

  • Press Ctrl+AltGr+]] (yes, press ] twice). This might not work in all browsers. Use Chrome for the best experience.
  • Close the webshell terminal and open a new one with Ctrl+Shift+^

Hints

We usually provide help for a task you have to complete. For example, if you have to implement a method you most likely find the solution in a Task hint like this one:

Task hint

Your yaml should look like this:

kind: VirtualMachine
metadata:
  name: kubevirtvm
spec:
  runStrategy: Halted
  template:
    spec:
      domain:
        devices: {}
        memory:
          guest: 64Mi
        resources: {}
status: {}

Using Kubernetes context

In our labs we specify the namespace for the commands by explicitly defining the --namespace parameter. We deem this best practice as it makes it harder to execute commands in the wrong namespace.

However, some people prefer to use the context by, e.g., using the following commands:

kubectl config set-context $(kubectl config current-context) --namespace $USER

If you get the following error from the command above you first have to initially set your current context:

error: current-context is not set
error: you must specify a non-empty context name or --current

Set the current context with:

kubectl config use-context local

And repeat the following command:

kubectl config set-context $(kubectl config current-context) --namespace $USER

Highlighting important things

We will use the following styling to highlight various things.