Hello, on my first attempt used the default context with doct auth init. Now I am using a different context. If I give:
doctl auth init --context 3di
Using token for context 3di
Validating token... ✔
but then when I do kubectl get pods I get all sort of errors.
kubectl get pods
Error: Unable to initialize DigitalOcean API client: access token is required. (hint: run 'doctl auth init')
13819 memcache.go:265] "Unhandled Error" err="couldn't get current server API group list: Get : getting credentials: exec: executable doctl failed with exit code 1"
So how do I tell kubectl to use the doctl initialized context?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hey Hoygen! 👋
You’re absolutely correct! To make
kubectl
work with the desired context, you need to configure the kubeconfig to point to the correct Kubernetes cluster managed by DigitalOcean. Here’s a step-by-step summary:Run this command to get the list of clusters and their IDs:
Use this command to save the kubeconfig for your cluster and set the current context:
This ensures
kubectl
uses the correct credentials and context when interacting with your cluster.To double-check the context is set correctly, run:
You should see the context name associated with your cluster.
Finally, test your connection with:
Let me know if you run into any other issues!
- Bobby
ok I think I figured out, but eventually I’ll gladly accept more answers. at first I had to find the desired cluster id:
and then I had to set the kubectl current context to that cluster ID
please correct me if I am wrong.