Validation

Similar to the container exercises, check the health state of the Kubernetes cluster.

Exercise - kubectl

Open your terminal application and run the kubectl command without any parameters in order to display a generic help and most options

kubectl

Exercise - version information

Execute the following command:

kubectl version

You get an output similar to the following:

Client Version: v1.28.4
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.27.7

This displays the version of the Kubernetes cluster (Server version) and the version of the client.

Exercise - cluster information

Now run the following command:

kubectl cluster-info

This command shows some information about the cluster. You should see an output similar to this:

Kubernetes control plane is running at https://fer2dns-awed5bfr.hcp.westeurope.azmk8s.io:443
CoreDNS is running at https://fer2dns-awed5bfr.hcp.westeurope.azmk8s.io:443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
Metrics-server is running at https://fer2dns-awed5bfr.hcp.westeurope.azmk8s.io:443/api/v1/namespaces/kube-system/services/https:metrics-server:/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

Exercise - physical nodes

Somewhat more meaningful information is the amount of nodes in your cluster:

kubectl get nodes

This will result in

NAME                               STATUS   ROLES   AGE     VERSION
aks-fer2pool-24896946-vmss000000   Ready    agent   3h29m   v1.27.7
aks-fer2pool-24896946-vmss000001   Ready    agent   3h29m   v1.27.7
aks-fer2pool-24896946-vmss000002   Ready    agent   3h29m   v1.27.7

You can see here that your cluster environment consists of three nodes.

Exercise - option -o wide

Now run the following command with the following change:

kubectl get nodes -o wide

What did you notice, what did the option (-o wide) add?

Solution

The output of the “kubectl get” command is extended. You can also get the output in a different format like ‘json’ or ‘yaml’, or quickly filter on ‘jsonpath’ or ‘go-template’. For more Info, please refer to the CLI help. You should get an output similar to the following:

NAME                               STATUS   ROLES   AGE     VERSION   INTERNAL-IP   EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION      CONTAINER-RUNTIME
aks-fer2pool-24896946-vmss000000   Ready    agent   3h30m   v1.27.7   10.224.0.4    <none>        Ubuntu 22.04.3 LTS   5.15.0-1051-azure   containerd://1.7.5-1
aks-fer2pool-24896946-vmss000001   Ready    agent   3h30m   v1.27.7   10.224.0.5    <none>        Ubuntu 22.04.3 LTS   5.15.0-1051-azure   containerd://1.7.5-1
aks-fer2pool-24896946-vmss000002   Ready    agent   3h30m   v1.27.7   10.224.0.6    <none>        Ubuntu 22.04.3 LTS   5.15.0-1051-azure   containerd://1.7.5-1