nerdexam
Linux_Foundation

CKA · Question #14

Check to see how many worker nodes are ready (not including nodes tainted noSchedule) and write the number to /opt/KUCC00104/kucc00104.txt.

The user must execute a kubectl command in the web terminal to identify and count ready worker nodes that are not tainted NoSchedule, then redirect the numerical count to the specified file.

Submitted by asante_acc· May 4, 2026Cluster Architecture, Installation & Configuration

Question

Check to see how many worker nodes are ready (not including nodes tainted noSchedule) and write the number to /opt/KUCC00104/kucc00104.txt.

Exhibits

CKA question #14 exhibit 1
CKA question #14 exhibit 2

Explanation

The user must execute a kubectl command in the web terminal to identify and count ready worker nodes that are not tainted NoSchedule, then redirect the numerical count to the specified file.

Approach. The core task requires identifying 'worker nodes' that are 'ready' and 'not tainted noSchedule', then writing the count to /opt/KUCC00104/kucc00104.txt. This is a command-line task in the provided web terminal.

  1. List all nodes and their status/roles: Use kubectl get nodes to get a summary of all nodes in the cluster, their status, and roles.
  2. Filter for 'Ready' status: The STATUS column in kubectl get nodes output indicates if a node is 'Ready'.
  3. Filter for 'worker nodes' and exclude 'nodes tainted noSchedule': Worker nodes typically do not have 'master' or 'control-plane' roles listed. Master nodes, by default, have the node-role.kubernetes.io/master:NoSchedule taint. Therefore, excluding nodes with the 'master' role usually satisfies the 'not tainted noSchedule' condition for healthy worker nodes.
  4. Count the filtered nodes: Use wc -l to count the resulting lines (node names).
  5. Redirect output: Save the final count to /opt/KUCC00104/kucc00104.txt.

The most effective command for this in a standard Kubernetes environment is: kubectl get nodes --no-headers | awk '$2 == "Ready" && !/master/ {print $1}' | wc -l > /opt/KUCC00104/kucc00104.txt

  • kubectl get nodes --no-headers: Lists all nodes without the initial header row, making text processing easier.
  • awk '$2 == "Ready" && !/master/ {print $1}': This awk command processes each line of kubectl get nodes output:
    • $2 == "Ready": Selects lines where the second field (STATUS column) is 'Ready'.
    • !/master/: Excludes lines that contain 'master' (typically in the ROLES column), effectively filtering out master nodes. This implicitly excludes nodes with the default NoSchedule taint. For healthy clusters, worker nodes are 'Ready' and usually not tainted NoSchedule unless explicitly done so for specific maintenance.
    • {print $1}: Prints the first field (NAME column) of the matching lines.
  • wc -l: Counts the number of lines (which correspond to the names of the filtered nodes).
  • > /opt/KUCC00104/kucc00104.txt: Redirects the final count to the specified file.

Common mistakes.

  • common_mistake. Common mistakes include:
  1. Not filtering out master nodes: Failing to use !/master/ or similar logic would lead to an incorrect count, as master nodes are typically tainted NoSchedule.
  2. Not filtering for 'Ready' status: Counting nodes that are NotReady would be incorrect.
  3. Forgetting to count or redirect: Not using | wc -l or not redirecting the output with > /opt/KUCC00104/kucc00104.txt will fail to meet the task requirements.
  4. Interacting with the YAML file: The YAML shown in the terminal is a visual distraction, intended to provide context about taints and tolerations, but the question does not ask to modify or apply it.
  5. Using overly complex commands: While jsonpath or jq could achieve a highly precise filter for taints, the awk solution is simpler, more commonly expected in certification exams for this type of task, and sufficiently addresses the problem's intent for typical cluster configurations.

Concept tested. This question tests the candidate's understanding of:

  • Kubernetes Node management: Listing and inspecting cluster nodes (kubectl get nodes).
  • Node Status: Interpreting the Ready status of a node.
  • Node Roles: Distinguishing between master and worker nodes.
  • Kubernetes Taints and Tolerations: Understanding the concept of taints, particularly NoSchedule and its default application on master nodes, and how it impacts pod scheduling.
  • Command-line text processing: Using tools like awk and wc to filter and count output from kubectl commands, and shell redirection (>).

Topics

#Node management#kubectl#Node status#Taints

Community Discussion

No community discussion yet for this question.

Full CKA Practice