[英]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我正在尝试按照参考 URL 中的步骤操作: Secrets-Kubernetes to create a Secret Using kubectl,我能够创建文件
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
这是 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最好的问候, MK
Please check if you have setup the Kubectl config credentials correctly.请检查您是否正确设置了 Kubectl 配置凭据。
You can fetch the credentials like below:您可以获取如下凭据:
For google:对于谷歌:
gcloud container clusters get-credentials <cluster name> --zone <zone> --project <project id>
For AWS:对于 AWS:
aws eks --region region update-kubeconfig --name cluster_name
kubectl get pods --kubeconfig ~/.kube/config
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
Can you please do kubectl config current-context
?你能做
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.
如果不是,您必须选择是每次调用命令时直接传递文件 kubeconfig 还是设置一次。
Try setting the KUBECONFIG env manually.尝试手动设置 KUBECONFIG 环境。
export KUBECONFIG=/etc/kubernetes/admin.conf
I had to create a config file manually and then set KUBECONFIG env by doing我必须手动创建一个配置文件,然后通过执行设置 KUBECONFIG env
export KUBECONFIG=~/.kube/config
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" apiVersion:v1 集群:- 集群:api-version:v1 服务器:“my-server” insecure-skip-tls-verify:真实名称:默认集群上下文:- 上下文:集群:默认集群命名空间:“my-namespace " 用户:默认用户名:默认上下文当前上下文:默认上下文种类:配置用户:- 名称:默认用户用户:令牌:“我的令牌”
secret/my-secret created
Thanks all for your support, Appreciate it!谢谢大家的支持,点赞!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.