kubesphere / kubekey

Install Kubernetes/K3s only, both Kubernetes/K3s and KubeSphere, and related cloud-native add-ons, it supports all-in-one, multi-node, and HA 🔥 ⎈ 🐳
https://kubesphere.io
Apache License 2.0
2.28k stars 537 forks source link

Cannot use kubectl after kk create cluster #371

Open LinuxSuRen opened 3 years ago

LinuxSuRen commented 3 years ago

When I finished the cluster creating task via kk create cluster --with-kubesphere --with-kubernetes v1.17.9

I try to execute a simple command which is kubectl get ns. But errors happend. You can see the output below:

Unable to connect to the server: x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "kubernetes")

A special case that is worth noticing. I run the below commands many times on my machine.

sudo kk create cluster --with-kubesphere --with-kubernetes v1.17.9
sudo kk delete cluster
pixiake commented 3 years ago

You can try to execute kubectl get ns --kubeconfig /etc/kubernetes/admin.conf. If the above command can work, it is possible that kubeconfig was not updated.

LinuxSuRen commented 3 years ago

As you said. It works well via kubectl get ns --kubeconfig /etc/kubernetes/admin.conf.

I did more tests. First, delete the .kube directory via rm -rf ~/.kube. Then install it again. After the installation was done. I got the following errors: The connection to the server localhost:8080 was refused - did you specify the right host or port?

Guest what? I don't have the .kube directory. So I guess this should be a bug exists.

pixiake commented 3 years ago

OK, We'll check this issue later.

LinuxSuRen commented 3 years ago

/kind bug /good-first-issue /help

ks-ci-bot commented 3 years ago

@LinuxSuRen: This request has been marked as suitable for new contributors.

Please ensure the request meets the requirements listed here.

If this request no longer meets these requirements, the label can be removed by commenting with the /remove-good-first-issue command.

In response to [this](https://github.com/kubesphere/kubekey/issues/371): >/kind bug >/good-first-issue >/help Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.