Skip to content

How do I execute the kubectl command on a slave node #3954

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jepson66 opened this issue May 2, 2023 · 5 comments
Closed

How do I execute the kubectl command on a slave node #3954

jepson66 opened this issue May 2, 2023 · 5 comments
Labels

Comments

@jepson66
Copy link

jepson66 commented May 2, 2023

What should I do if I want to execute the kubectl command on the slave node?

@neoaggelos
Copy link
Contributor

Hi @jepson66

By default, MicroK8s worker nodes do not get an admin kubeconfig file. Instead what you can do is grab one from any of the control plane nodes and run kubectl manually, e.g.:

Print a kubeconfig file for the admin user by running this command on any of the control plane nodes:

microk8s config > kubeconfig

Then manually move this to ~/.kube/config on your worker node, and install kubectl, e.g. with sudo snap install kubectl --classic

cp /path/to/kubeconfig ~/.kube/config

# install kubectl, e.g. with snap
sudo snap install kubectl --classic
kubectl get pod

Hope this helps!

@jepson66
Copy link
Author

jepson66 commented May 3, 2023

OK, thank @neoaggelos, I'll try it.

@jepson66
Copy link
Author

jepson66 commented May 9, 2023

@neoaggelos,According to what you said, it is configured, but the slave node still cannot use the kubectl command
image

@ktsakalozos
Copy link
Member

@jepson66 is it possible you have an alias of microk8s.kuebctl to kubectl? Could you try calling directly /snap/bin/kubectl and use the --kubeconfig <path_to_kubeconfig> just to be sure we are not picking up any config we are not supposed to?

Copy link

stale bot commented Apr 9, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the inactive label Apr 9, 2024
@jepson66 jepson66 closed this as completed May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants