1

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

Community
  • 1
  • 1
Mike730
  • 495
  • 1
  • 5
  • 14

5 Answers5

1

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
  • 1,399
  • 1
  • 14
  • 21
  • Thanks Vishnu, I believe that I have to create a config file as I get no such file or directory error please advise on how to get a config file created so as to run kubectl create secret command – Mike730 May 14 '20 at 16:17
  • When you run the above commands it will automatically create the config file. Currently where you are running this ? Is it in AWS EKS cluster or Google cloud GKE? or are you running it locally? like minikube? – Vishnu Nair May 14 '20 at 18:09
0

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
  • 2,214
  • 1
  • 24
  • 37
  • Hi Sacha, Still the same I tried [root@1161 cdp]# kubectl create secret generic db-user --from-file=./username.txt error: Missing or incomplete configuration info. Please point to an existing, complete config file: – Mike730 May 10 '20 at 16:20
0

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
  • 1,865
  • 2
  • 16
  • 20
  • Thanks for your response, [mk@1161 kubectl_lab]$ kubectl config current-context error: current-context is not set How to set kubeconfig one time? please advise – Mike730 May 14 '20 at 16:12
  • First you can try to look at all of your context, by using `kubectl config view` https://kubernetes.io/docs/reference/kubectl/cheatsheet/#kubectl-context-and-configuration – irvifa May 14 '20 at 18:26
0

Try setting the KUBECONFIG env manually.

export KUBECONFIG=/etc/kubernetes/admin.conf
Harika
  • 11
  • 4
  • Thanks Harika, What configuration am I setting here? [mk@1161 /]$ cd etc/kubernetes/ [mk@inblr1161 kubernetes]$ ls addons I believe that I have to create an admin.conf file but I'm not sure what would I fill in? please advise – Mike730 May 14 '20 at 16:14
  • 1.How did you install kubernetes ? yum install ? – Harika May 14 '20 at 18:58
  • Afaik Any kubernetes platform comes with kubectl installed properly. I believe no kubectl commands will be running for you, not only creating secrets. Please check this link in case installed kubeadm manually and setting the kubernetes env (https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/#more-information) _To make kubectl work for your non-root user, run these commands, which are also part of the kubeadm init output:_ – Harika May 14 '20 at 21:02
  • Hi Harika, I was able to set KUBECONFIG env manually export KUBECONFIG=~/.kube/config and created config file manually config-file --- apiVersion: v1 clusters: - cluster: api-version: v1 server: "my-server" insecure-skip-tls-verify: true name: default-cluster contexts: - context: cluster: default-cluster namespace: "my-namespace" user: default-user name: default-context current-context: default-context kind: Config users: - name: default-user user: token: "my-token" – Mike730 Jun 03 '20 at 11:03
0

I had to create a config file manually and then set KUBECONFIG env by doing

export KUBECONFIG=~/.kube/config

My_Config file

apiVersion: v1 clusters: - cluster: api-version: v1 server: "my-server" insecure-skip-tls-verify: true name: default-cluster contexts: - context: cluster: default-cluster namespace: "my-namespace" user: default-user name: default-context current-context: default-context kind: Config users: - name: default-user user: token: "my-token"

secret/my-secret created

Thanks all for your support, Appreciate it!

Mike730
  • 495
  • 1
  • 5
  • 14