2. First steps
In this lab, we will interact with the Kubernetes cluster for the first time.
Warning
Please make sure you completed Setup before you continue with this lab.
Login
Note
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.
Namespaces
Note
If you work in our acend web based environment, your Namespace has already been created and you can skip this task.
A Namespace is a logical design used in Kubernetes to organize and separate your applications, Deployments, Pods, Ingresses, Services, etc. on a top-level basis. Take a look at the Kubernetes docs . Authorized users inside a namespace are able to manage those resources. Namespace names have to be unique in your cluster.
Task 2.1: Create a Namespace
Create a new namespace on the Kubernetes Cluster.. The kubectl help
output can help you figure out the right command.
Note
Please choose an identifying name for your Namespace, e.g. your initials or name as a prefix.
We are going to use <namespace>
as a placeholder for your created Namespace.
Solution
To create a new Namespace on your cluster use the following command:
kubectl create namespace <namespace>
Note
By using the following command, you can switch into another Namespace instead of specifying it for each kubectl
command.
Linux:
kubectl config set-context $(kubectl config current-context) --namespace <namespace>
Windows:
kubectl config current-context
SET KUBE_CONTEXT=[Insert output of the upper command]
kubectl config set-context %KUBE_CONTEXT% --namespace <namespace>
Some prefer to explicitly select the Namespace for each kubectl
command by adding --namespace <namespace>
or -n <namespace>
. Others prefer helper tools like kubens
(see ).