kelseyhightower / kubernetes-the-hard-way

Bootstrap Kubernetes the hard way. No scripts.
Apache License 2.0
39.89k stars 13.7k forks source link

Invalid CIDR address: ${POD_CIDR} #722

Open roberto-maggi opened 1 year ago

roberto-maggi commented 1 year ago

Hi you all, I just enrolled in Kubernetes cert and following the steps to install the cluster as it should be done, but I'm having an upsetting problem.

I'm stuck at the "Deploying the DNS Cluster Add-on" section:

The immediate problem was that launching

kubectl exec -ti busybox -- nslookup kubernetes

it went in timeout

Then I tried to investigate and the pods where stuck in "ContainerCreating"

root@controller-0:~# kubectl get pods --namespace kube-system NAME READY STATUS RESTARTS AGE coredns-8494f9c688-4c28l 1/1 Running 0 59m coredns-8494f9c688-s87k2 0/1 ContainerCreating 0 16m root@controller-0:~# kubectl get pods NAME READY STATUS RESTARTS AGE busybox 0/1 ContainerCreating 0 25s

andchecking the events I got get only this:

root@controller-0:~# kubectl get events --sort-by=.metadata.creationTimestamp LAST SEEN TYPE REASON OBJECT MESSAGE 51m Normal RegisteredNode node/worker-2 Node worker-2 event: Registered Node worker-2 in Controller 51m Normal RegisteredNode node/worker-1 Node worker-1 event: Registered Node worker-1 in Controller 51m Normal RegisteredNode node/worker-0 Node worker-0 event: Registered Node worker-0 in Controller 39m Warning FailedCreatePodSandBox pod/busybox Failed to create pod sandbox: rpc error: code = Unknown desc = failed to setup network for sandbox "c202166128707eff8752d947f7d2821d17eb7b12cfac1d4e9413f33c21d2b96d": invalid CIDR address: ${POD_CIDR} 39m Normal Scheduled pod/busybox Successfully assigned default/busybox to worker-1

It looks like it cannot translate the variable ${POD_CIDR} to the actual value that the system can, however, to get

root@controller-0:~# echo ${POD_CIDR} 10.240.0.0/24 root@controller-0:~#

I tried to hard code, just for testing, the CIDR, both in /etc/cni/net.d/10-bridge.conf and in var/lib/kubelet/kubelet-config.yaml but the only difference I could get was that it indicated that it had already an IP different that 10.240.0.1/24 .

Could you help me understanding what's going on? Thanks in advance. Rob

roberto-maggi commented 1 year ago

At last I went through it in the most non elegant way, simply substituting ${POD_CIDR} with the actual numeric range. Can anyone help me understanding what's the actual problem ?