Namespaces are a central component of any Kubernetes infrastructure. This lab will give you the opportunity to work with namespaces in a functioning cluster. You will be able to practice the process of creating, using, and navigating Kubernetes namespaces.
You are working for BeeBox, a subscription service company that provides weekly shipments of bees to customers. The company is in the process of containerizing their infrastructure and running their software on Kubernetes. As part of this process, the company is working on determining what namespaces it will need in the Kubernetes cluster.
You have been asked to access the cluster and perform some maintenance tasks related to the cluster's namespaces.
- The dev team would like a namespace they can work in that is separate from namespaces used to run production workloads. Create a new namespace called
dev
. - One of the members of your security team would like to audit the namespaces that currently exist in the cluster. Get a list of the current namespaces and save it to a file located at
/home/cloud_user/namespaces.txt
on the control plane node. - Someone on the team created a pod with the name
quark
, but they are not sure which namespace it is in. Determine which namespace this pod is in, and save the name of that namespace to a file located at/home/cloud_user/quark-namespace.txt
on the control plane node.
- Create the
dev
Namespace- Log in to the control plane node. Create a namespace in the cluster
called
dev
.
- Log in to the control plane node. Create a namespace in the cluster
called
- Get a List of the Current Namespaces
- List all of the current namespaces in the cluster. Save this list to
the file
/home/cloud_user/namespaces.txt
.
- List all of the current namespaces in the cluster. Save this list to
the file
- Find the
quark
Pod's Namespace- Locate a pod called
quark
. Determine which namespace the pod is in, and save the name of that namespace to the file/home/cloud_user/quark-namespace.txt
.
- Locate a pod called
Log in to the provided control plane node server using the credentials provided:
ssh cloud_user@<PUBLIC_IP_ADDRESS>
-
Create a namespace in the cluster called
dev
:kubectl create namespace dev
-
List the current namespaces:
kubectl get namespace
-
Save the namespaces list to a file:
kubectl get namespace > /home/cloud_user/namespaces.txt
-
Verify the list saved to the file:
cat namespaces.txt
We should see the list of namespaces.
-
Locate the
quark
pod:kubectl get pods --all-namespaces
-
Copy the name of the namespace where the
quark
pod is located. -
Create a file in which to save its name: :
vi /home/cloud_user/quark-namespace.txt
-
Paste in the name of the
quark
pod's namespace. -
Save and exit the file by pressing Escape followed by
:wq
.