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.
If I try this using Git Bash, it behaves the same but responds with the error shown below
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.
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.