> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Lab Solution Service Networking optional

> Guided lab for inspecting Kubernetes cluster networking, including node and pod IP ranges, Service ClusterIP, CNI configuration, kube-proxy deployment and logs

In this lesson you'll inspect cluster networking by checking node interfaces, CNI logs, the kube-apiserver configuration, and kube-system workloads. These steps help answer common Kubernetes networking questions such as node subnets, Pod IP allocation, Service ClusterIP ranges, and how kube-proxy is deployed and configured.

<Callout icon="lightbulb" color="#1CB2FE">
  Before you begin, you need kubectl access to the cluster and shell access on a control-plane node (or appropriate permissions to view pod logs and static manifests). Use `kubectl` from a machine with cluster credentials.
</Callout>

***

## Question 1 — What network range are the nodes in the cluster part of?

Inspect the nodes to get their internal IPs, then verify the node's interface addresses on a control-plane or any node.

Run:

```bash theme={null}
kubectl get nodes -o wide
```

Example output:

```bash theme={null}
controlplane ~ ➜ kubectl get nodes -o wide
NAME           STATUS   ROLES           AGE   VERSION    INTERNAL-IP    EXTERNAL-IP   OS-IMAGE               KERNEL-VERSION       CONTAINER-RUNTIME
controlplane   Ready    control-plane   52m   v1.26.0    192.168.10.10  <none>        Ubuntu 20.04.5 LTS     5.4.0-1104-gcp        containerd://1.6.6
node01         Ready    <none>          51m   v1.26.0    192.168.10.3   <none>        Ubuntu 20.04.5 LTS     5.4.0-1104-gcp        containerd://1.6.6
```

On the control plane, check interfaces:

```bash theme={null}
ip addr
```

Example (truncated) output:

```bash theme={null}
...
4: weave: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1376 qdisc noqueue state UP group default qlen 1000
    inet 10.244.0.1/16 brd 10.244.255.255 scope global weave
...
207: eth0@if208: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue state UP group default
    inet 192.168.10.10/24 brd 192.168.10.255 scope global eth0
       valid_lft forever preferred_lft forever
217: eth1@if218: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
    inet 172.25.0.39/24 brd 172.25.0.255 scope global eth1
       valid_lft forever preferred_lft forever
...
```

Explanation:

* The node’s primary interface for cluster traffic is `eth0` with `inet 192.168.10.10/24`.
* Therefore the nodes are on the 192.168.10.0/24 subnet (a /24 provides host addresses in the last octet).

Answer: 192.168.10.0/24

***

## Question 2 — What is the range of IP addresses configured for Pods on this cluster?

This cluster uses Weave Net as the CNI. Pod IP allocation configuration is typically visible in the Weave Net pod logs (look for `ipalloc-range` or `IPALLOC_RANGE`).

List the weave pods:

```bash theme={null}
kubectl get pods -n kube-system
```

Example output:

```bash theme={null}
NAMESPACE     NAME                                   READY   STATUS    RESTARTS   AGE
kube-system   weave-net-rbx4p                        2/2     Running   1 (55m ago) 55m
kube-system   weave-net-vclkp                        2/2     Running   0          55m
...
```

Inspect the Weave Net pod logs:

```bash theme={null}
kubectl logs weave-net-rbx4p -n kube-system
```

Excerpt:

```bash theme={null}
Defaulted container "weave" out of: weave, weave-npc, weave-init (init)
INFO: 2023/05/03 04:01:05.724455 Command line options: map[..., ipalloc-range:10.244.0.0/16, ...]
INFO: 2023/05/03 04:01:07.759736 adding entry 10.244.0.0/16 to weaver-no-masq-local of 0
INFO: 2023/05/03 04:01:07.759757 added entry 10.244.0.0/16 to weaver-no-masq-local of 0 10.244.0.1
...
```

Explanation:

* Weave Net is allocating Pod IPs from `10.244.0.0/16`, as indicated by `ipalloc-range` and the weave bridge address (`10.244.0.1/16`).

Answer: 10.244.0.0/16

***

## Question 3 — What IP range is configured for Services within the cluster?

The Service ClusterIP range is configured via the kube-apiserver flag `--service-cluster-ip-range`. Inspect the static manifest typically located at `/etc/kubernetes/manifests/kube-apiserver.yaml` on a control-plane node or view the contents using `kubectl` if the manifest is exported elsewhere.

Example manifest snippet:

```yaml theme={null}
containers:
- command:
  - kube-apiserver
  ...
  - --service-cluster-ip-range=10.96.0.0/12
  ...
  image: registry.k8s.io/kube-apiserver:v1.26.0
  name: kube-apiserver
```

Answer: 10.96.0.0/12

<Callout icon="warning" color="#FF6B6B">
  Do not modify kube-apiserver static manifests unless you understand the impact. Changes to `--service-cluster-ip-range` require careful planning and could disrupt cluster services.
</Callout>

***

## Question 4 — How many kube-proxy pods are deployed in this cluster?

List kube-system pods:

```bash theme={null}
kubectl get pods -n kube-system
```

Example output:

```bash theme={null}
NAME                                      READY   STATUS    RESTARTS   AGE
coredns-787d4945fb-f4x5m                  1/1     Running   0          55m
etcd-controlplane                         1/1     Running   0          55m
kube-apiserver-controlplane               1/1     Running   0          55m
kube-controller-manager-controlplane      1/1     Running   0          55m
kube-proxy-125qk                          1/1     Running   0          55m
kube-proxy-l8gms                          1/1     Running   0          55m
kube-scheduler-controlplane               1/1     Running   0          55m
weave-net-rbx4p                           2/2     Running   1 (55m ago) 55m
weave-net-vclkp                           2/2     Running   0          55m
```

Explanation:

* There are two `kube-proxy` pods (one per node in this 2-node cluster).

Answer: 2

***

## Question 5 — What type of proxy is kube-proxy configured to use?

Inspect kube-proxy logs to see which proxier implementation it selected (e.g., `iptables`, `ipvs`, or `userspace`).

Example:

```bash theme={null}
kubectl logs kube-proxy-125qk -n kube-system
```

Excerpt:

```bash theme={null}
I0503 04:01:01.695677 1 node.go:163] Successfully retrieved node IP: 192.168.10.10
I0503 04:01:01.695829 1 server_others.go:535] "Using iptables proxy"
I0503 04:01:01.800897 1 server_others.go:176] "Using iptables Proxier"
I0503 04:01:01.800956 1 server_others.go:183] "kube-proxy running in dual-stack mode" ipFamily=IPv4
...
```

Answer: iptables

For more on proxier implementations see the kube-proxy documentation: [https://kubernetes.io/docs/reference/command-line-tools-reference/kube-proxy/](https://kubernetes.io/docs/reference/command-line-tools-reference/kube-proxy/)

***

## Question 6 — How does the cluster ensure kube-proxy runs on all nodes?

Kubernetes commonly deploys node-local agents (like kube-proxy and many CNIs) as a DaemonSet so a copy runs on each eligible node.

Verify DaemonSets:

```bash theme={null}
kubectl get daemonset -n kube-system
```

Or view all resources:

```bash theme={null}
kubectl get all --all-namespaces
```

Example relevant output:

```bash theme={null}
NAMESPACE     NAME                                               READY   STATUS    RESTARTS   AGE
kube-system   pod/kube-proxy-125qk                               1/1     Running   0          56m
kube-system   pod/kube-proxy-l8gms                               1/1     Running   0          56m
...

NAMESPACE     NAME                                  DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR
kube-system   daemonset.apps/kube-proxy             2         2         2       2            2           kubernetes.io/os=linux
kube-system   daemonset.apps/weave-net              2         2         2       2            2           <none>
...
```

Explanation:

* `daemonset.apps/kube-proxy` with desired=2 ensures kube-proxy runs on each node matching the DaemonSet's nodeSelector/tolerations.
* DaemonSets guarantee one (or more) pods per eligible node and are the usual mechanism for per-node agents.

Answer: kube-proxy is deployed as a DaemonSet, ensuring one pod per node.

***

## Summary

| Item | Result |
| - | - |
| Node network range | 192.168.10.0/24 |
| Pod IP range (CNI — Weave Net) | 10.244.0.0/16 |
| Service ClusterIP range | 10.96.0.0/12 |
| Number of kube-proxy pods | 2 |
| kube-proxy proxier type | iptables |
| How kube-proxy is scheduled on nodes | Deployed as a DaemonSet |

***

## Links and references

* Kubernetes networking concepts: [https://kubernetes.io/docs/concepts/cluster-administration/networking/](https://kubernetes.io/docs/concepts/cluster-administration/networking/)
* Weave Net CNI documentation: [https://www.weave.works/docs/net/latest/](https://www.weave.works/docs/net/latest/)
* kube-proxy command-line reference: [https://kubernetes.io/docs/reference/command-line-tools-reference/kube-proxy/](https://kubernetes.io/docs/reference/command-line-tools-reference/kube-proxy/)
* DaemonSet concept: [https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/](https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/)

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/cka-certification-course-certified-kubernetes-administrator/module/44bc9a9f-319c-40ee-babd-0f7b53a70de7/lesson/af6f5867-b78e-4b4b-804c-ab49d9662008" />
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.