Exploring the Kubernetes Cluster via the Command Line

Hands-On Lab

March 31st, 2019

 

Photo of Chad Crowell

Chad Crowell

DevOps Training Architect II in Content

Length

00:30:00

Difficulty

Beginner

The kubectl command line tool is an extremely extensive and powerful utility. It has many uses, but for this hands-on lab, we will be using it to familiarize ourselves with the Kubernetes cluster in order to find out more information about how the cluster is built. After completing this lab, we will have a hands-on understanding of how to move about the cluster and check on the different resources and components of the Kubernetes cluster.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Exploring the Kubernetes Cluster via the Command Line

We have been given a Kubernetes cluster to inspect. In order to better understand the layout and the structure of this cluster, we must run the appropriate commands.

Log in to the Kube Master server using the credentials on the lab page (either in your local terminal, using the Instant Terminal feature, or using the public IP), and work through the objectives listed.

List all the nodes in the cluster.

Use the following command to list the nodes in your cluster:

kubectl get nodes

We should see three nodes: one master and two workers.

List all the pods in all namespaces.

Use the following command to list the pods in all namespaces:

kubectl get pods --all-namespaces

List all the namespaces in the cluster.

Use the following command to list all the namespaces in the cluster:

kubectl get namespaces

Here, we should see four namespaces: default, kube-public, kube-system, and web.

Check to see if there are any pods running in the default namespace.

Use the following command to list the pods in the default namespace:

kubectl get pods

We should see that there aren't any pods in the default namespace.

Find the IP address of the API server running on the master node.

Use the following command to find the IP address of the API server:

kubectl get pods --all-namespaces -o wide

See if there are any deployments in this cluster.

Use the following command to check for any deployments in the cluster:

kubectl get deployments

We should see there aren't any deployments in the cluster.

Find the label applied to the etcd pod on the master node.

Use the following command to view the label on the etcd pod:

kubectl get pods --all-namespaces --show-labels -o wide

Conclusion

That's it — congratulations on completing this lab!