Unable to create a Secret Using kubectl

5/10/2020

I am trying to follow steps from ref URL: Secrets-Kubernetes to create a Secret Using kubectl, I was able to create files

  1. username.txt
  2. password.txt

which show under pwd

[root@1161 cdp]# ls
password.txt  username.txt

and now when I try to execute the next statement which is

kubectl create secret generic db-user-pass --from-file=./username.txt --from-file=./password.txt

I get following error:

error: Missing or incomplete configuration info.  Please point to an existing, complete config file:
 1. Via the command-line flag --kubeconfig
 2. Via the KUBECONFIG environment variable
 3. In your home directory as ~/.kube/config

 To view or setup config directly use the 'config' command.

Note: I'm running the statement behind corporate proxy, Please advise on how to proceed further

This is on centos 7

kubectl version --client
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.2",
GitCommit:"52c56ce7a8272c798dbc29846288d7cd9fbae032", GitTreeState:"clean",
BuildDate:"2020-04-16T11:56:40Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}

Best Regards, MK

-- MAK
kubectl
kubernetes
kubernetes-secrets

4 Answers

5/11/2020

Can you please do kubectl config current-context? Wondering if you already authenticated on the right cluster or not. If not you have to option whether directly passing the file kubeconfig each time you call the command or set it one time.

-- irvifa
Source: StackOverflow

5/11/2020

Try setting the KUBECONFIG env manually.

export KUBECONFIG=/etc/kubernetes/admin.conf
-- Harika
Source: StackOverflow

5/10/2020

Have you tried creating the secret files one at a time. For example this works for me

kubectl.exe create secret generic server-secrets --from-file=sachaserver-secrets-properties
-- sacha barber
Source: StackOverflow

5/11/2020

Please check if you have setup the Kubectl config credentials correctly.

You can fetch the credentials like below:

For google:

gcloud container clusters get-credentials <cluster name> --zone <zone> --project <project id>

For AWS:

aws eks --region region update-kubeconfig --name cluster_name
kubectl get pods --kubeconfig ~/.kube/config
-- Vishnu Nair
Source: StackOverflow