Inside Docker container Kubectl gives Unable to connect to the server: dial tcp i/o timeout

374 Views Asked by At

I'm trying to follow this tutorial https://www.youtube.com/watch?v=9EUyMjR6jSc. I'm working on Ubuntu 20.04LTS, I installed k3d and this is ~/.kube/config information

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: ...
    server: https://192.168.0.13:16443
  name: k3d-dev
contexts:
- context:
    cluster: k3d-dev
    user: admin@k3d-dev
  name: k3d-dev
current-context: k3d-dev
kind: Config
preferences: {}
users:
- name: admin@k3d-dev
  user:
    client-certificate-data:...
    client-key-data:...

Docker version is Version: 20.10.2. According to the tutorial I need to run a halyard container and inside the container I can access the local kubernetes (in this case k3d). The halyard container comes with kubectl, so i just need to create a ~/.kube/config with the above info, but i still get the Unable to connect to server message. The cluster is up and running as I get this info if I run kubectl cluster-info

Kubernetes control plane is running at https://192.168.0.13:16443
CoreDNS is running at https://192.168.0.13:16443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
Metrics-server is running at https://192.168.0.13:16443/api/v1/namespaces/kube-system/services/https:metrics-server:/proxy

Inside the halyard container

bash-5.0$ kubectl version
Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.10", GitCommit:"1bea6c00a7055edef03f1d4bb58b773fa8917f11", GitTreeState:"clean", BuildDate:"2020-02-11T20:13:57Z", GoVersion:"go1.12.12", Compiler:"gc", Platform:"linux/amd64"}
Unable to connect to the server: dial tcp 192.168.0.13:16443: i/o timeout
bash-5.0$ kubectl config view
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: DATA+OMITTED
    server: https://192.168.0.13:16443
  name: k3d-dev
contexts:
- context:
    cluster: k3d-dev
    user: admin@k3d-dev
  name: k3d-dev
current-context: k3d-dev
kind: Config
preferences: {}
users:
- name: admin@k3d-dev
  user:
    client-certificate-data: REDACTED
    client-key-data: REDACTED
bash-5.0$ kubectl config current-context
k3d-dev
0

There are 0 best solutions below