diff --git a/content/en/docs/01/_index.md b/content/en/docs/01/_index.md index eb0a6c8..732042c 100644 --- a/content/en/docs/01/_index.md +++ b/content/en/docs/01/_index.md @@ -10,11 +10,13 @@ description: > ## Login -{{% alert title="Note" color="info" %}} Authentication depends on the specific Kubernetes cluster environment. You may need special instructions if you are not using our lab environment. Details will be provided by your teacher. {{% /alert %}} +{{% alert title="Note" color="info" %}} Authentication depends on the specific Kubernetes cluster environment. The **URL** and **Credentials** to access the lab environment will provided by the teacher. Use Chrome for the best experience.{{% /alert %}} ## Webshell +The first thing we're going to do is to explore our lab environment and get in touch with the different components. + The provided lab environment contains an _Eclipse Theia IDE_[^1]. Your IDE will look something like this: ![Eclipse Theia IDE](theia.png) @@ -23,40 +25,38 @@ The provided lab environment contains an _Eclipse Theia IDE_[^1]. Your IDE will * The Terminal is accessible using `Ctrl+Shit+^` or using the Menubar `Terminal > New Terminal` 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. 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: +the configuration needed to access the kubernetes cluster. + +Let's verify that by executing the following command in a freshly created terminal window: ```shell -theia(user4) /home/project $ kubectl config get-contexts -CURRENT NAME CLUSTER AUTHINFO NAMESPACE - local local local user4 - -theia(user4) /home/project $ kubectl get pods -NAME READY STATUS RESTARTS AGE -user4-webshell-885dbc579-lwhtd 2/2 Running 0 11d +kubectl version ``` +The files in the home directory under `/home/project` are stored in a persistence volume, so please make sure to store all your persistence 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 file explorer. Using the shell they will show up in the file -explorer and vice versa. Your workplace is persistent and is available for the whole training duration. - +explorer and vice versa. -### 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: +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: ```shell -virtctl console kubevirtvm +kubectl config get-contexts ``` - -When the terminal is connected to the virtual machine vm the following line appears: +should result in something like this: ```shell -Successfully connected to kubevirtvm console. The escape sequence is ^ +CURRENT NAME CLUSTER AUTHINFO NAMESPACE + local local local ``` -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) -* Close the webshell terminal and open a new one with `Ctrl+Shift+^` +```shell +kubectl get pods --namespace=$USER +``` +will show that the current webshell is also running as pod within your namespace: +```shell +NAME READY STATUS RESTARTS AGE +-webshell-885dbc579-lwhtd 2/2 Running 0 11d +``` ## Namespace @@ -67,37 +67,36 @@ We're going to use the following Namespace for the labs Alternatively there is a namespace `-dev` available. -{{% alert title="Note" color="info" %}} -By using the following command, you can switch into another Namespace instead of specifying it for each `kubectl` command. -```bash -kubectl config set-context $(kubectl config current-context) --namespace -``` +## General Lab Notes -If you get the following error from the command above you first have to initially set your current context: -```shell -error: current-context is not set -error: you must specify a non-empty context name or --current -``` -Set the current context with: -```shell -kubectl config use-context local -``` +### Placeholders -Some prefer to explicitly select the Namespace for each `kubectl` command by adding `--namespace ` or `-n `. -{{% /alert %}} +In this lab we will use the following placeholders or naming conventions: +* `` your username (for example `user4`) +* `$USER` the environment variable containing your username. Execute `echo $USER` to verify that in your terminal session +* `[...]` means that some lines in the listing or command have been omitted for readability. -## General Lab Notes +### Exiting a console of a virtual machine -### Placeholders +In various labs we will connect to the console of a virtual machine using the `virtctl console`. Your terminal will look like this: -In this lab we will use the following placeholders or naming conventions: +```shell +virtctl console kubevirtvm +``` -* `$USER` your username (for example `user4`) -* `[...]` means that some lines in the listing or command have been omitted for readability. +When the terminal is connected to the virtual machine vm the following line appears: +```shell +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) +* Close the webshell terminal and open a new one with `Ctrl+Shift+^` ### Hints @@ -125,6 +124,37 @@ status: {} {{% /details %}} +### Using Kubernetes Context instead of explicitly specifying the namespace + +In our labs we specify the namespace for the commands explicitly by the `--namespace` parameter. + +{{% alert title="Note" color="info" %}} + +Some engineers prefer to use the context by using the following commands: + +```bash +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: +```shell +error: current-context is not set +error: you must specify a non-empty context name or --current +``` + +Set the current context with: +```shell +kubectl config use-context local +``` + +And repeat the following command: + +```bash +kubectl config set-context $(kubectl config current-context) --namespace $USER +``` +{{% /alert %}} + + ### Highlighting important things We will use the following styling to highlight various things. diff --git a/content/en/docs/02/21_create-vm.md b/content/en/docs/02/21_create-vm.md index a753333..276eb14 100644 --- a/content/en/docs/02/21_create-vm.md +++ b/content/en/docs/02/21_create-vm.md @@ -133,7 +133,7 @@ spec: Since you have completed the yaml configuration for the VM it's now time to create it our VM in the kubernetes cluster. ```shell -kubectl create -f {{% param "labsubfolderprefix" %}}{{% param "labfoldernumber" %}}-firstvm.yaml +kubectl create -f vm_{{% param "labsubfolderprefix" %}}{{% param "labfoldernumber" %}}-firstvm.yaml ``` The output should be: