1

When using the kubectl cli in a Windows DOS prompt, I get a prompt to enter a username, that works fine but when I press enter after entering a username the prompt for a password appears and then immediately acts like I hit the enter key, no chance to enter the password, looks like this, from the screen print you can see that I am using kubectl version 1.15.

enter image description here

If I try this using Git Bash, it behaves the same but responds with the error shown below

enter image description here

Same deal where the password prompt is not waiting for input.

Anyone ever seen this or have any thoughts on how I can provide a username and password to kubectl without storing it a plain test in the config file?

Also, I am using a corporate Kubernates cluster, so no options to move to a more current version or do anything else that would require admin access.

vscoder
  • 929
  • 1
  • 10
  • 25
  • 1
    Hello. Please include exact steps you've taken to get to this point. How the `kubectl` was installed and what's the version of it (with minor releases). Additionally please tell how the `kubeconfig` file was created/configured. – Dawid Kruk May 11 '20 at 13:57
  • Kubectl was installed via a corporate installer, not sure how it works. The kubectl client version is listed above 1.15. The K8S cluster is at 1.14, within the major version -1 / +1 restriction. The kubeconfig was created using kubectl config commands. I did not add any users to the config, I will try that and see if it changes the behavior. – vscoder May 11 '20 at 16:44
  • 1
    To properly pinpoint the issue you are having, please provide information how is your kubernetes cluster authenticating the users. You can find possible options here: https://kubernetes.io/docs/reference/access-authn-authz/authentication/ . Additionally please include your .kube/config to check if the configuration is valid. Please make sure that all of the passwords are redacted from the file before posting! – Dawid Kruk May 12 '20 at 15:47
  • Dawid, thanks for replying and making an effort to help. I finally got a response from the K8S admins and they are helping with this. I have a personal version running on my pc at home and it works fine there, but that is the current version 1.18. Something about SSO not working at work. Anyways, I now have access to K8S dashboard so I can create my pods and services using that. Again, many thanks for your help. – vscoder May 12 '20 at 17:54

2 Answers2

3

Posting this answer as community wiki with general guidelines for issues similar to this:

TL;DR

The prompt for username and password is most probably caused by misconfigured .kube/config.

As for:

Anyone ever seen this or have any thoughts on how I can provide a username and password to kubectl without storing it a plain test in the config file?

There are a lot of possibilities for authentication in Kubernetes. All of them have some advantages and disadvantages. Please take a look on below links:


The prompt for username and password can appear when .kube/config file is misconfigured. I included one possible reason below:

Starting with correctly configured .kube/config for a minikube instance.

apiVersion: v1
clusters:
- cluster:
    certificate-authority: PATH_TO_SOMEWHERE/.minikube/ca.crt
    server: https://172.17.0.3:8443
  name: minikube
contexts:
- context:
    cluster: minikube
    user: minikube
  name: minikube
current-context: minikube
kind: Config
preferences: {}
users:
- name: minikube
  user:
    client-certificate: PATH_TO_SOMEWHERE/client.crt
    client-key: PATH_TO_SOMEWHERE/client.key

Issuing commands with above .kube/config should not prompt for user and password as below:

$ kubectl get pods
No resources found in default namespace.

Editing .kube/config and changing:

    user: minikube

to:

    user: not-minikube

Will lead to:

$ kubectl  get pods
Please enter Username: minikube
Please enter Password: 

Correctly configuring .kube/config is heavily dependent on a solution used (like minikube, kubeadm provisioned cluster, and a managed cluster like GKE). Please refer to official documentation of solution used.

Dawid Kruk
  • 8,982
  • 2
  • 22
  • 45
0

I found this post because I had the same problem, and I knew the cause after seeing people's answers. Comment to add.

I fixed the kube config with the command

aws eks update-kubeconfig --region region-code --name my-cluster

Arnis Juraga
  • 1,027
  • 14
  • 31