Why is kubectl describe secret not working?

3/29/2019

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?

-- Rajeev Ranjan
google-cloud-platform
kubernetes

2 Answers

3/29/2019

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
-- Cloudomation
Source: StackOverflow

3/29/2019

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.

-- Steve HOUEL
Source: StackOverflow