Search code examples
kuberneteskubectlkubernetes-secrets

Unable to create a Secret Using kubectl


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


Solution

  • 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!