kubectl asking for username and password

July 2, 2019 474 views
DigitalOcean Kubernetes

I have just set up a Kubernetes cluster on DigitalOcean. I have followed the suggested tutorial but when I try and run the commands I keep getting prompted for a username and password which I have not been provided with.

I have seen a few posts where people say it will be emailed to me but it’s been well over an hour since the set-up completed and I have still not been emailed with anything (yes, I checked the usual places)

Commands I ran:
$> doctl kubernetes cluster kubeconfig save MY-CLUSTER
Notice: adding cluster credentials to kubeconfig file found in “/Users/anthonybudd/.kube/config”
Notice: setting current-context to do-sfo2-ideea-prod
$> kubctl get nodes
Please enter Username:

Tutorial
https://www.digitalocean.com/docs/kubernetes/how-to/connect-to-cluster/

Any help or insights would be appreciated.

5 comments
  • Hi there,

    That is bizarre behavior. Does it work when you download the kubeconfig from the cloud panel?

    Regards,

    John Kwiatkoski
    Senior Developer Support Engineer

  • Yes, that does work.

    Commands:
    $> doctl version
    doctl version 1.20.1-release

    $> mv ~/Downloads/ideea-prod-kubeconfig.yaml ~/.kube

    $> cd ~/.kube && kubectl –kubeconfig=“ideea-prod-kubeconfig.yaml” get nodes
    NAME STATUS ROLES AGE VERSION
    ideea-prod-pool-1-o5a6 Ready <none> 5m v1.14.1
    ideea-prod-pool-1-o5al Ready <none> 5m v1.14.1
    ideea-prod-pool-1-o5at Ready <none> 5m v1.14.1

    But when I follow the commands in the tutorial it doesn’t.

    $> doctl kubernetes cluster kubeconfig save ideea-prod
    Notice: adding cluster credentials to kubeconfig file found in “/Users/anthonybudd/.kube/config”
    Notice: setting current-context to do-sfo2-ideea-prod
    $> kubectl get pods
    Please enter Username:

  • kubectl can switch between multiple clusters and ~/.kube/config can track multiple entries. Perhaps it got munged. Try copying ~/.kube/config to a temporary place and start with a fresh config file from the DOKS cloud panel.

  • Would you mind opening up a support ticket to help get this resolved?

5 Answers
anthonybudd July 2, 2019
Accepted Answer

After pulling my hair out for a few hours and seriously questioning why I moved to DO, I’ve got to the bottom of the issue…

Manually downloading the config file and using doctl will retrieve different files. The manually downloaded config file has the auth details and the doctl one doesn’t.

Don’t use.
doctl kubernetes cluster kubeconfig save ideea-prod

It’s a bug on your side 👍

On to my next issue.

$> kubectl get nodes
NAME STATUS ROLES AGE VERSION
ideea-prod-pool-1-o5a6 Ready <none> 1h v1.14.1
ideea-prod-pool-1-o5al Ready <none> 1h v1.14.1
ideea-prod-pool-1-o5at Ready <none> 1h v1.14.1

$> kubectl apply -f deployment.yml
Error from server (NotFound): the server could not find the requested resource

@DigitalOcean why am I being charged $30 per month to beta test your kubernetes service? 😑

I can confirm this is happening with doctl, but not with the manual download.

Specifically, the doctl result has:

users:
- name: do-nyc1-cmattoon
  user: {}

While the manually downloaded one has:

users:
- name: do-nyc1-cmattoon
  user:
    client-certificate-data: "…"
    client-key-data: "…"

I am prompted with Username as well.

My workaround has been to use the doctl k8s cluster config show command and pipe it to a file.

Then use the KUBECONFIG environment variable to include both files, something like ~/.kube/config:~/.kube/myDOconfig

That way the file includes a proper users certificates.

Using doctl k8s cluster config save redirects the users part to the doctl command, which may work for others but not for me.

Have another answer? Share your knowledge.