>_ IzzyLab

Hands-on task

This task is step 1 of the course “Kubernetes: first steps”

Look around the cluster

easy~5 min

This sandbox runs its own Kubernetes cluster, and kubectl is already configured for it. Look around:

  • find out the name of the cluster's node and write it to /root/node.txt;
  • a pod stock-counter is running somewhere in the cluster — find out which namespace it lives in and write that namespace's name to /root/namespace.txt.

Each file holds just the name, on one line.

What you'll practise:
  • kubernetes
  • kubectl
  • kubectl get
  • namespace
  • node

Topic breakdown

Kubernetes (k8s for short) is a system that runs containers on a group of servers and keeps them running. That group of servers is called a cluster, and each server in it is a node. The cluster in our sandbox is small, just one node, but the commands are the same as in a big one.

In Kubernetes, containers live inside pods. A pod is the smallest unit the cluster runs: one container (sometimes several) with its own IP address.

To keep objects of different teams and projects from getting mixed up, they're sorted into namespaces — think of them as folders for cluster objects. Kubernetes keeps its own system pods in the kube-system namespace, and anything you create without specifying a namespace goes to default.

You talk to the cluster with the kubectl tool. The main command for looking around is kubectl get <type>:

kubectl get namespaces          # which namespaces the cluster has
kubectl get pods -n kube-system # pods in the kube-system namespace

The -n <namespace> flag picks a namespace; without it kubectl looks in default.

What's checked

  1. /root/node.txt contains the cluster node's name
  2. /root/namespace.txt contains the namespace of the stock-counter pod

What it looks like