skip to Main Content

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

5

Answers


  1. Chosen as BEST ANSWER

    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!


  2. 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
    
    Login or Signup to reply.
  3. 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
    
    Login or Signup to reply.
  4. 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.

    Login or Signup to reply.
  5. Try setting the KUBECONFIG env manually.

    export KUBECONFIG=/etc/kubernetes/admin.conf
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search