Kubectl commands only working with minikube

646 views Asked by At

How come that when I use minikube, all my kubectl commands work properly e.g. kubectl get nodes. But the moment I stop minikube and try using k3d.

  1. Install k3d with choco install k3d
  2. Make a cluster in k3d
  3. Set the context to the created cluster

Somehow commands like kubectl get nodes and kubectl get pods don't work and return

Unable to connect to the server: dial tcp 145.93.104.168:61199: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or e
stablished connection failed because connected host has failed to respond.

Why can't I run the kubectl commands properly with k3d?

Kubectl config view:

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: DATA+OMITTED
    server: https://host.docker.internal:61199
  name: k3d-kwetter-cluster
- cluster:
    certificate-authority: C:\Users\ZRC\.minikube\ca.crt
    extensions:
    - extension:
        last-update: Thu, 07 Apr 2022 11:25:37 CEST
        provider: minikube.sigs.k8s.io
        version: v1.25.2
      name: cluster_info
    server: https://127.0.0.1:65229
  name: minikube
contexts:
- context:
    cluster: k3d-kwetter-cluster
    user: admin@k3d-kwetter-cluster
  name: k3d-kwetter-cluster
- context:
    cluster: minikube
    extensions:
    - extension:
        last-update: Thu, 07 Apr 2022 11:25:37 CEST
        provider: minikube.sigs.k8s.io
        version: v1.25.2
      name: context_info
    namespace: default
    user: minikube
  name: minikube
current-context: k3d-kwetter-cluster
kind: Config
preferences: {}
users:
- name: admin@k3d-kwetter-cluster
  user:
    client-certificate-data: REDACTED
    client-key-data: REDACTED
- name: minikube
  user:
    client-certificate: C:\Users\ZRC\.minikube\profiles\minikube\client.crt
    client-key: C:\Users\ZRC\.minikube\profiles\minikube\client.key

Extra context: I tried to not use minikube because I couldn't externally access my deployed application at all (NodePort, with ingress, port forwarding...I tried a lot of things, but those just didn't work. But now k3d isn't working either)

1

There are 1 answers

0
zhrgci On BEST ANSWER

In Docker Desktop, go to settings > Kubernetes > Enable Kuberenetes set to true.