Use context: kubectl config use-context k8s-c1-H
You’re ask to find out following information about the cluster k8s-c1-H
:
- How many controlplane nodes are available?
- How many worker nodes are available?
- What is the Service CIDR?
- Which Networking (or CNI Plugin) is configured and where is its config file?
- Which suffix will static pods have that run on
cluster1-node1
?
Write your answers into file /opt/course/14/cluster-info
, structured like this:
1 2 3 4 5 6 7 8 |
# /opt/course/14/cluster-info 1: [ANSWER] 2: [ANSWER] 3: [ANSWER] 4: [ANSWER] 5: [ANSWER] |
Gathering Essential Kubernetes Cluster Information
Understanding the configuration and setup of your Kubernetes cluster is crucial for effective management and troubleshooting. In this guide, we’ll walk through how to gather key pieces of information about a Kubernetes cluster, including the number of control plane and worker nodes, the Service CIDR, the configured CNI plugin, and the naming convention for static pods.
Step 1: Checking the Number of Control Plane and Worker Nodes
First, let’s determine how many control plane and worker nodes are available in the cluster. You can retrieve this information using the following command:
1 2 3 |
kubectl get nodes |
Here’s an example output:
1 2 3 4 5 6 7 8 |
NAME STATUS ROLES AGE VERSION cluster1-controlplane1 Ready control-plane 27h v1.30.1 cluster1-node1 Ready <none> 27h v1.30.1 cluster1-node2 Ready <none> 27h v1.30.1 |
From this output, we can see that there is one control plane node and two worker nodes in the cluster.
Step 2: Finding the Service CIDR
The Service CIDR is the range of IP addresses assigned to Kubernetes services. To find this information, SSH into the control plane node and check the kube-apiserver configuration:
1 2 3 |
ssh cluster1-controlplane1 |
Once connected, run the following command to inspect the kube-apiserver manifest:
1 2 3 |
cat /etc/kubernetes/manifests/kube-apiserver.yaml | grep range |
The output will look something like this:
1 2 3 |
- --service-cluster-ip-range=10.96.0.0/12 |
This indicates that the Service CIDR for this cluster is 10.96.0.0/12
.
Step 3: Identifying the Configured CNI Plugin
Kubernetes uses a Container Network Interface (CNI) plugin to manage networking within the cluster. To identify which CNI plugin is configured and locate its configuration file, run the following commands:
1 2 3 4 5 6 |
find /etc/cni/net.d/ cat /etc/cni/net.d/10-weave.conflist |
Here’s an example of what you might find:
1 2 3 4 5 6 7 8 9 |
{ "cniVersion": "0.3.0", "name": "weave", ... } |
This output shows that the Weave CNI plugin is configured, and its configuration file is located at /etc/cni/net.d/10-weave.conflist
.
Step 4: Understanding Static Pod Naming Convention
Static pods running on a specific node have a unique suffix based on the node’s hostname. The naming convention for these pods follows the pattern: -
. For example, static pods running on cluster1-node1
would have the suffix -cluster1-node1
.
Cluster Information Summary
After gathering all the relevant information, you can summarize it as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# Cluster Information Summary # How many control plane nodes are available? 1: 1 # How many worker nodes are available? 2: 2 # What is the Service CIDR? 3: 10.96.0.0/12 # Which Networking (or CNI Plugin) is configured and where is its config file? 4: Weave, /etc/cni/net.d/10-weave.conflist # Which suffix will static pods have that run on cluster1-node1? 5: -cluster1-node1 |
This information is crucial for understanding your Kubernetes cluster’s architecture and for performing effective troubleshooting and management tasks.
Conclusion
By following the steps in this guide, you’ve gathered essential information about your Kubernetes cluster, including node roles, the Service CIDR, the configured CNI plugin, and static pod naming conventions. These details form the foundation for managing and scaling your Kubernetes environment efficiently.