K8s cluster deployment error: nc: bad address 'xx'

host@host:~$ kubectl logs kafka-0 -c init-zookeeper
nc: bad address 'zookeeper-0.zookeeper-headless-service.default.svc.cluster.local'

I have deployed an k8s cluster. When the application pod was installed, the pod keep in the Init state. I try to find out where goes wrong, only get this error below.

pml@pml:~/bfn-mon/k8s$ kubectl get pods
NAME                                READY   STATUS     RESTARTS   AGE
broker-59f66ff494-lwtxq             0/1     Init:0/2   0          41m
coordinator-9998c64b8-ql7xz         0/1     Init:0/2   0          41m
kafka-0                             0/1     Init:0/1   0          41m
host@host:~$ kubectl logs kafka-0 -c init-zookeeper
nc: bad address 'zookeeper-0.zookeeper-headless-service.default.svc.cluster.local'

Would someone can tell what's going wrong? How can I fix it?

I would expect someone who did have the same problem, or know what's going wrong, and give some debug instructions.


  • During Pod startup, the kubelet delays running init containers until the networking and storage are ready. Then the kubelet runs the Pod's init containers in the order they appear in the Pod's spec.

    For pods stuck in an init state with a bad address, It means the PVC may not be recycled correctly so the storage is not ready so the pod will be init state until it gets cleared.

    From this link, you can follow below solutions:

    1. Check if PVs are created and bound to all expected PVCs.
    2. Run /opt/kubernetes/bin/kube-restart.sh to restart the cluster.