0

I am new to kubernetes I setup two nodes using virtualbox node for master and another for worker. I had to restart the master node to extend the size of the virtual machine disk size but after restarting I noticed network interface didn't notice before docker0 and I no longer can connect to the internet

root@kmaster:/home/master# ifconfig -a
docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:c0:68:28:15  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp0s3: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        inet 10.0.2.15  netmask 255.255.255.255  broadcast 0.0.0.0
        ether 08:00:27:d8:7b:e3  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 115563  bytes 23918431 (23.9 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 115563  bytes 23918431 (23.9 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

from /etc/network/interfaces

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

autp enp0s3
iface enp0s3 inet static
address 10.0.2.15

and when I am running I face this error

root@kmaster:/home/master# sudo ip route add default via 10.0.2.1
Error: Nexthop has invalid gateway.

Note: I run root@kmaster:/home/master# ip route flush dev enp0s3 before running sudo ip route add default via 10.0.2.1

and when trying to run kubeadm init --apiserver-advertise-address=10.0.2.15 --pod-network-cidr=10.0.2.0/24

I face this error

I0409 16:04:10.994564    9270 version.go:96] could not fetch a Kubernetes version from the internet: unable to get URL "https://dl.k8s.io/release/stable-1.txt": Get https://dl.k8s.io/release/stable-1.txt: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
I0409 16:04:10.994714    9270 version.go:97] falling back to the local client version: v1.14.0
[init] Using Kubernetes version: v1.14.0
[preflight] Running pre-flight checks
    [WARNING Service-Docker]: docker service is not enabled, please run 'systemctl enable docker.service'
    [WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". Please follow the guide at https://kubernetes.io/docs/setup/cri/
error execution phase preflight: [preflight] Some fatal errors occurred:
    [ERROR Port-6443]: Port 6443 is in use
    [ERROR Port-10251]: Port 10251 is in use
    [ERROR Port-10252]: Port 10252 is in use
    [ERROR FileAvailable--etc-kubernetes-manifests-kube-apiserver.yaml]: /etc/kubernetes/manifests/kube-apiserver.yaml already exists
    [ERROR FileAvailable--etc-kubernetes-manifests-kube-controller-manager.yaml]: /etc/kubernetes/manifests/kube-controller-manager.yaml already exists
    [ERROR FileAvailable--etc-kubernetes-manifests-kube-scheduler.yaml]: /etc/kubernetes/manifests/kube-scheduler.yaml already exists
    [ERROR FileAvailable--etc-kubernetes-manifests-etcd.yaml]: /etc/kubernetes/manifests/etcd.yaml already exists
    [ERROR Port-10250]: Port 10250 is in use
    [ERROR Port-2379]: Port 2379 is in use
    [ERROR Port-2380]: Port 2380 is in use
    [ERROR DirAvailable--var-lib-etcd]: /var/lib/etcd is not empty
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`

from /etc/resolv.conf

nameserver 8.8.8.8
options edns0
0

Looks like you have multiple issues here. I suspect they also start prior to initializing your cluster, as Kubernetes can't connect to the internet to download what it needs.

  1. destroy the current VM, and create a new one (recommend Bridged networking).
  2. verify the VM has network connectivity.
  3. install docker on the VM.
  4. enable the docker service (looks like you also missed this step) with: sudo systemctl enable docker (or as appropriate for your OS)
  5. verify the vm has network connectivity.
  6. proceed with kubernetes installation and cluster initialization.

I suspect you also don't want your pod-network-cidr to specify the same network as your VMs, or otherwise play with the HostNetwork setting.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.