Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is kubectl describe secret not working?

I created a secret in kubernetes using the command below -

kubectl create secret generic -n mynamespace test --from-file=a.txt

Now I try to view it using below commands but am unsuccessful -

kubectl describe secrets/test
kubectl get secret test -o json

This is the error I get in either case -

Error from server (NotFound): secrets "test" not found

What can be the cause? I am using GCP for the kubernetes setup. Can the trial version of GCP be the cause for it?

like image 840
Rajeev Ranjan Avatar asked Dec 13 '22 12:12

Rajeev Ranjan


2 Answers

Try to access the secret in the namespace where it was created in:

kubectl -n mynamespace describe secrets/test
kubectl -n mynamespace get secret test -o json
like image 73
Cloudomation Avatar answered Dec 28 '22 22:12

Cloudomation


You create your secret on a specific namespace and not the default one and when you use kubectl describe it will be bind to the default one.

Good thinks to know when you use a specific namespace for your secret is that they can only be referenced by pods in that same namespace.

like image 41
Steve HOUEL Avatar answered Dec 28 '22 22:12

Steve HOUEL