Extend the Cluster with an Additional Service CIDR for the dev Team
Scenario
The cluster currently allocates all Service ClusterIPs from a single default
range. The dev team needs its own dedicated pool of Service IPs, but
reconfiguring the cluster's existing default Service CIDR is disruptive — it
requires editing the kube-apiserver manifest, restarting the apiserver, and
potentially recreating every existing Service.
Modern Kubernetes (1.33+) solves this with the ServiceCIDR API object —
an additional, completely separate IP range can be added for Services without
touching the default range or restarting anything.
A web-app Deployment is already running in the dev namespace, but it has
no Service yet.
Task
- Add a new
ServiceCIDRobject nameddev-team-cidrfor192.168.0.0/24, without modifying the existing defaultServiceCIDR. Wait for it to reportReady: True - Create a Service named
web-app-svcin thedevnamespace that selects pods with the labelapp: web-app. Configurespec.clusterIPwith a valid IP address from the192.168.0.0/24Service CIDR. Do not use the network address (192.168.0.0) or the broadcast address (192.168.0.255). - Confirm from inside a pod that DNS resolves
web-app-svc.dev.svc.cluster.localto the Service's ClusterIP and that the application responds with its custom message.
Hint 1 — Inspect the Existing Default ServiceCIDR First
Before creating anything new, take a look at what the cluster already has.
There is a built-in ServiceCIDR object that was created automatically at
cluster bootstrap — find it, read its CIDR, and make sure you understand its
name. You'll need to leave it completely untouched.
kubectl get servicecidr
kubectl get servicecidr <name> -o yaml
Documentation
Hint 2 — Create a New ServiceCIDR Object
A ServiceCIDR is a cluster-scoped resource under networking.k8s.io/v1.
Create one named dev-team-cidr that covers 192.168.0.0/24. The relevant
field to set is spec.cidrs.
After applying it, don't move on immediately — check its status.conditions
and wait until the Ready condition shows True. Only then will the API
server accept Service IPs from this range.
kubectl describe servicecidr dev-team-cidr
Documentation
Hint 3 — Think Carefully About How Kubernetes Assigns ClusterIPs
This is the trickiest part of the challenge. The Kubernetes IP allocator does
not prefer a newly added ServiceCIDR over the default one — it picks from a
shared pool, so a Service created without a specific IP will almost certainly
land in the default range, not 192.168.0.0/24.
To guarantee the Service gets an IP from the new range, pick any valid ClusterIP
from inside 192.168.0.0/24 and set it explicitly on the Service using
the spec.clusterIP field. The valid ClusterIP range for a /24 is .1 through
.254 — avoid .0 (network address) and .255 (outside the usable range).
Documentation
Hint 4 — Verify DNS and Connectivity from Inside the Cluster
Always verify DNS and connectivity from a pod running inside the cluster —
not from the host — since that is the actual path real workloads use. Use a
temporary busybox pod for the DNS lookup and a curlimages/curl pod for
the HTTP request, both in the dev namespace so they share the same DNS
search domain as the Service:
kubectl run dns-test --rm -it --restart=Never \
--image=busybox:latest -n dev -- nslookup web-app-svc.dev.svc.cluster.local
kubectl run curl-test --rm -it --restart=Never \
--image=curlimages/curl:latest -n dev -- \
curl http://web-app-svc.dev.svc.cluster.local
Documentation